I used two examples of you, one is ble thermometer(another esp32), the other is reading thermometer data as central role.
During the test, two problems were encountered:
1、
Code: Select all
def _irq(self, event, data):
if event == _IRQ_SCAN_RESULT:
addr_type, addr, connectable, rssi, adv_data = data
print(addr_type, bytes(addr),decode_services(adv_data),_ENV_SENSE_UUID, _ENV_SENSE_UUID in decode_services(adv_data) ,connectable)
if connectable and _ENV_SENSE_UUID in decode_services(adv_data):
#if connectable:
# Found a potential device, remember it and stop scanning.
self._addr_type = addr_type
self._addr = bytes(addr) # Note: The addr buffer is owned by modbluetooth, need to copy it.
self._name = decode_name(adv_data) or '?'
self._ble.gap_scan(None)
result:
Code: Select all
>>> %Run -c $EDITOR_CONTENT
0 b'<q\xbfF\x05Z' [UUID16(0x181a)] UUID16(0x181a) False True
0 b'<q\xbfF\x05Z' [UUID16(0x181a)] UUID16(0x181a) False True
0 b'<q\xbfF\x05Z' [UUID16(0x181a)] UUID16(0x181a) False True
0 b'<q\xbfF\x05Z' [UUID16(0x181a)] UUID16(0x181a) False True
No sensor found.
_ENV_SENSE_UUID= [UUID16(0x181a)]
decode_services(adv_data) UUID16(0x181a)
but:
Code: Select all
_ENV_SENSE_UUID in decode_services(adv_data)
is false
2、When I commented out some code, the sensor was searched. After I run the code of ble thermometer (another esp32), I have conducted joint debugging with my mobile phone, The ble thermometer is works.
result:
Code: Select all
>>> %Run -c $EDITOR_CONTENT
0 b'<q\xbfF\x05Z' [UUID16(0x181a)] UUID16(0x181a) False True
Found sensor: 0 b'<q\xbfF\x05Z' mpy-temp
0 0 b'<q\xbfF\x05Z'
0 1 5 UUID16(0x0000)
0 6 10 UUID16(0x0000)
0 11 65535 UUID16(0x001a)
Do I need some bug to be fixed?
thanks