• 0 Votes
    2 Posts
    74 Views
    M
    Hi Fredrik, First of all, CHAR_NOTIFY_EVENT works well on FiPy. Could you tell me which version you are using? I tried my example on different versions and I haven't seen a missing descriptor error. You can try the examples below. Please let me know about your experiment. BR, Meric Subscribe_Event def chr1_handler(chr, data): global battery global update events = chr.events() print("events: ",events) if events & (Bluetooth.CHAR_READ_EVENT | Bluetooth.CHAR_SUBSCRIBE_EVENT): chr.value(battery) print("transmitted :", battery) if (events & Bluetooth.CHAR_SUBSCRIBE_EVENT): update = ~update bluetooth = Bluetooth() bluetooth.set_advertisement(name='FiPy 45', manufacturer_data="Pycom", service_uuid=0xec00) bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb) bluetooth.advertise(True) srv1 = bluetooth.service(uuid=0xec00, isprimary=True,nbr_chars=1) chr1 = srv1.characteristic(uuid=0xec0e, value='read_from_here') #client reads from here chr1.callback(trigger=(Bluetooth.CHAR_READ_EVENT | Bluetooth.CHAR_SUBSCRIBE_EVENT), handler=chr1_handler) def update_handler(update_alarm): global battery global update battery-=1 if battery == 1: battery = 100 if update: chr1.value(battery) update_alarm = Timer.Alarm(update_handler, 1, periodic=True) Notify_Event def char_notify_callback(char, arg): char_value = (char.value()) print("New value: {}".format(char_value)) bt = Bluetooth() bt.start_scan(-1) adv = None while(True): adv = bt.get_adv() if adv: try: if bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL)=="FiPy 45": conn = bt.connect(adv.mac) try: services = conn.services() for service in services: time.sleep(0.50) chars = service.characteristics() for char in chars: c_uuid = char.uuid() if c_uuid == 0xec0e: if (char.properties() & Bluetooth.PROP_NOTIFY): char.callback(trigger=Bluetooth.CHAR_NOTIFY_EVENT, handler=char_notify_callback) print(c_uuid) break except: continue except: continue bt.stop_scan() bt.disconnect_client()
  • BLE GATTC write perfomance

    Discussion bluetooh performance write characteristic
    1
    0 Votes
    1 Posts
    506 Views
    No one has replied
  • What is this Value!?

    LoPy pytrack lopy characteristic characteristics ble
    4
    1
    0 Votes
    4 Posts
    923 Views
    S
    @jmarcelino [image: 1524488362634-e78568e9-9adb-4679-b068-205fbf18cf47-image-resized.png]
  • 0 Votes
    2 Posts
    684 Views
    B
    Got the issue sorted out myself. The values are documented in the esp-idf: https://github.com/espressif/esp-idf/blob/master/components/bt/bluedroid/api/include/esp_gatt_defs.h#L267 just set the values corresponding to your needs. Be sure to set both permissions and properties. Example: The below characteristic supports only READ and NOTIFY: service.characteristic(uuid=0x2001, permissions=(1<<0), properties=(1 << 1) | (1 << 4), value=0)
  • 0 Votes
    1 Posts
    948 Views
    No one has replied
  • 0 Votes
    1 Posts
    814 Views
    No one has replied
  • 1 Votes
    5 Posts
    4k Views
    T
    I know this is an old topic I started but it seems like there is even less documentation now on this topic of using the BLE device as a peripheral. It would be nice if the documentation better represented common functionality and how the functionality is intended to be used with this device. I tried to use those links that had reference to using the BLE device as a peripheral but the link was broken.