Yes.
There are different types of beacons, but the current functionality supports setting an arbitrary advertising payload and scan response, and you can be connectable.
Yes.
Hi net0040.
Hi jimmo,
Code: Select all
_ENV_SENSE_UUID in decode_services(adv_data)
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)
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.
Code: Select all
# org.bluetooth.characteristic.gap.appearance.xml
_ADV_APPEARANCE_GENERIC_THERMOMETER = const(768)
When I used the 1127 firmware, the above question disappeared. But I tested the BLE heart rate band and couldn't connect properly. Apart from the UUID (180D/181A 2A37/2A6E), what is the difference between a thermometer and a heart rate band? Thank younet0040 wrote: ↑Wed Nov 27, 2019 5:14 amHi jimmo,
When I try to connect a ble thermometer using your code, the code runs as false.Cause the sensor cannot be searched properly. When this judge is removed, the code can continue to run. what improvements I need to make, thank you.Code: Select all
_ENV_SENSE_UUID in decode_services(adv_data)
Here's the code and results:
code:result: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)
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.
I think this is just used for scanner devices to show what type of peripheral it is (without having to discover services first). I don't think it's required.net0040 wrote: ↑Wed Nov 27, 2019 5:31 am1.Is this code necessary, please?When I deleted this code, I found that I could still read the data on the ble thermometer.
2.By looking at the data sheet,If I'm used for heart rate band reading, i should set it to const(832) (general heart rate monitoring) or const(833) (heart rate band)
Good that it's working now for temperature.
I'm connecting it with ESP32(arduino) and arduino 101 and Android Phones.They all work normally.(if so, what are you using to connect to it?
Sorry I'm still not quite sure I follow...
This is some posts I wrote before, please don't mind that it's Chinese, there's all the code and download links.If so, can you share code that worked (for both the band and the thing connecting to it),