• Bluetooth GATTSCharacteristic GPy

    Discussion bluetooth gatt gpy network pycom
    13
    0 Votes
    13 Posts
    677 Views
    A
    Dear @shanefowler25, @shanefowler25 said in Bluetooth GATTSCharacteristic GPy: I just wasn't able to do a GET request for my application. May I humbly ask whether you wanted to connect using SSL here? I'm just asking because we didn't test these details thoroughly with our custom builds yet. @shanefowler25 said in Bluetooth GATTSCharacteristic GPy: Hopefully sometime in the future, there will be another update to the firmware that allows users to use Wifi/Bluetooth or Cellular/Bluetooth, without the program crashing and resetting the board. Issues around this "coexist" thing have even bitten Espressif Systems for quite a while, as outlined above. In this manner, the Pycom firmware is pretty much innocent here as it depends very much on the details coming from the ESP-IDF in this regard. @shanefowler25 said in Bluetooth GATTSCharacteristic GPy: My program would still crash when I used to Bluetooth to break the while loop of my program. While we are avid WiFi users, some people from our community are also approaching BLE these days. @poesel reported his observations on [1] and [2] already, but unfortunately he is currently traveling without being able to confirm our latest build would work better for him. He is using a GPy as well. @shanefowler25 said in Bluetooth GATTSCharacteristic GPy: I figured out a workaround that works for the application that I'm trying to do. Good that you found something that works for you. As we are currently trying to collect experiences from people affected by this issue on [3], we still ask anyone who could test the latest dragonfly builds. So, if you might find some time for that beyond working on your program, we would be more than happy to hear about the outcome. Thanks already and happy hacking. With kind regards, Andreas. [1] https://forum.pycom.io/topic/5358/1-20-0rc13-guru-meditation [2] https://community.hiveeyes.org/t/investigating-core-panics-with-ble-on-pycom-devices/2715 [3] https://community.hiveeyes.org/t/testing-the-custom-dragonfly-builds-on-pycom-devices/2746
  • 0 Votes
    9 Posts
    1k Views
    A
    Dear @jcaron, Bringing 0x2901 CUD support to the Pycom BLE stack You would need to modify the code you pointed out in [3] to add another descriptor for the description (it currently adds a 0x2902 CCC and you want to also add a 0x2901 CUD).   For each descriptor, you need to use esp_ble_gatts_add_char_descr then wait for xQueueReceive, apparently.   You would also have to add the user description as an allowed argument (line 1192) and process that like the other optional parameters.   [3] https://github.com/pycom/pycom-micropython-sigfox/blob/4d3322a60501cac1a06558a0c5c816e198570888/esp32/mods/modbt.c#L1276-L1290 Thanks for outlining the procedure in detail how to go forward on this. While I might feel like I could eventually accept this challenge while receiving further guidelines from folks more fluent with C++ as well as FreeRTOS, the ESP-IDF and the Bluetooth Softwarestack incorporated into the Firmware, we are currently a bit swamped between different other things. Saying this, we are humbly asking members from the Pycom core team here if adding this feature could be worth the effort? We can assure you we will kindly be the first betatesters of added functionality in this regard. Maybe @semireg (@caylanlarson) and @husigeza who worked together [1] on the important improvement re. processing the Bluetooth.CHAR_SUBSCRIBE_EVENT might add their thoughts here? Thanks already and with kind regards, Andreas. [1] https://github.com/pycom/pycom-micropython-sigfox/pull/121
  • 0 Votes
    1 Posts
    593 Views
    No one has replied
  • Reading data from bluetooth device

    LoPy bluetooth gatt
    7
    0 Votes
    7 Posts
    3k Views
    L
    @seb I write this code to be able to find where it doesn't work from network import Bluetooth import time bt = Bluetooth() print("searching") bt.start_scan(-1) print("connection") conn = bt.connect('C47C8D643FAF') print("connected") def characteristic_callback(char): v = int.from_bytes(char.value(), "little") print("Got new value: {}".format(v)) print("before services") services = conn.services() print("services") for service in services: print("Service: {}".format(service.uuid())) if service.uuid() == b'XXXXXXXXXXXXX': characteristics = service.characteristics() for characteristic in characteristics: print("Characteristic: {}".format(characteristic.uuid())) if characteristic.uuid() == b'XXXXXXXXXXXX': characteristic.callback(trigger=Bluetooth.CHAR_NOTIFY_EVENT, handler=characteristic_callback, arg=None) So, in the terminal it print searching connection connected before services So it never reach the line : services = conn.services() in the page https://wiki.hackerspace.pl/projects:xiaomi-flora , it's specified that "You need to write 0xA01F to the handle 0x0033 to enable real-time data reading " How can I write the value 0xA01F in the handle 0x0033 ? Thanks in advance for your precious help.
  • 0 Votes
    3 Posts
    1k Views
    T
    @jmarcelino SOLVED Thanks for the help. Was able to adapt the example to connect to my Lopy and get a specific service with no issues. Some tips for anybody else trying to do access a GATT service. If you use the Pycom example it will print out a services.uuid like this b'\xdet-\xf0p\x13\x12\xb5DK\xb1\xc5 \xff\x95\xa4' . But if you are trying to access the service using the UUID as it appears it will not work. So what I did (as suggested by jmarcelino) was use binascii.hexlify to get a hex value. Which in this case was -----de742df0701312b5444bb1c520ff95a4' ,then use that as the value with binascci.unhexlify as the uuid input like this service.uuid()==binascii.unhexlify(b'de742df0701312b5444bb1c520ff95a4'): Another way to get the uuid is to use the Android Nordic Semiconductor nRF Connect app (or similar) to get the hex value for the UUID and then use unhexlify as above.