()
return 0
Main function. The comments below try to explain what each section of
        the code does.
Main function. The comments below try to explain what each section of
        the code does.
Main function . The comments below try to explain what each section of the code does .
def main():
    """
        Main function. The comments below try to explain what each section of
        the code does.
    """

    # pygatt uses pexpect and if your device has a long list of characteristics,
    # pexpect will not catch them all. We increase the search window to
    # 2048 bytes for the this example. By default, it is 200.
    # Note: We need an instance of GATToolBackend per each device connection
    adapter = pygatt.GATTToolBackend(search_window_size=2048)

    try:
        # Start the adapter
        adapter.start()
        # Connect to the device with that given parameter.
        # For scanning, use adapter.scan()
        device = adapter.connect("1C:87:74:00:E5:A0")
        # Set the security level to medium
        device.bond()
        # Observes the given characteristics for indications.
        # When a response is available, calls data_handle_cb
        device.subscribe("00002a1c-0000-1000-8000-00805f9b34fb",
                         callback=data_handler_cb,
                         indication=True)

        input("Press enter to stop program...\n")

    finally:
        # Stop the adapter session
        adapter.stop()

    return 0
def main ( ) : # pygatt uses pexpect and if your device has a long list of characteristics, # pexpect will not catch them all. We increase the search window to # 2048 bytes for the this example. By default, it is 200. # Note: We need an instance of GATToolBackend per each device connection adapter = pygatt . GATTToolBackend ( search_window_size = 2048 ) try : # Start the adapter adapter . start ( ) # Connect to the device with that given parameter. # For scanning, use adapter.scan() device = adapter . connect ( "1C:87:74:00:E5:A0" ) # Set the security level to medium device . bond ( ) # Observes the given characteristics for indications. # When a response is available, calls data_handle_cb device . subscribe ( "00002a1c-0000-1000-8000-00805f9b34fb" , callback = data_handler_cb , indication = True ) input ( "Press enter to stop program...\n" ) finally : # Stop the adapter session adapter . stop ( ) return 0