Page 4 of 5

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Mon Nov 25, 2019 2:07 am
by jimmo
mczubel wrote:
Sat Nov 23, 2019 12:20 pm
I'm newly in esp32 ble, with this firmware: can I set esp32 ble like a beacon?
adv packet with conn posibility
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.

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Mon Nov 25, 2019 2:08 am
by jimmo
net0040 wrote:
Wed Nov 20, 2019 3:53 pm
Do I need some bug to be fixed?
thanks
Hi net0040.
Sorry I'm not quite sure I understand what you're asking. Can you explain in a bit more detail what the issue you're seeing is?

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Wed Nov 27, 2019 5:14 am
by net0040
jimmo wrote:
Mon Nov 25, 2019 2:08 am
net0040 wrote:
Wed Nov 20, 2019 3:53 pm
Do I need some bug to be fixed?
thanks
Hi net0040.
Sorry I'm not quite sure I understand what you're asking. Can you explain in a bit more detail what the issue you're seeing is?
Hi jimmo,
When I try to connect a ble thermometer using your code, the code runs as false.

Code: Select all

_ENV_SENSE_UUID in decode_services(adv_data) 
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.
Here's the code and results:
code:

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.

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Wed Nov 27, 2019 5:31 am
by net0040

Code: Select all

# org.bluetooth.characteristic.gap.appearance.xml
_ADV_APPEARANCE_GENERIC_THERMOMETER = const(768)
1.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)

thanks.

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Wed Nov 27, 2019 2:43 pm
by net0040
net0040 wrote:
Wed Nov 27, 2019 5:14 am
jimmo wrote:
Mon Nov 25, 2019 2:08 am
net0040 wrote:
Wed Nov 20, 2019 3:53 pm
Do I need some bug to be fixed?
thanks
Hi net0040.
Sorry I'm not quite sure I understand what you're asking. Can you explain in a bit more detail what the issue you're seeing is?
Hi jimmo,
When I try to connect a ble thermometer using your code, the code runs as false.

Code: Select all

_ENV_SENSE_UUID in decode_services(adv_data) 
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.
Here's the code and results:
code:

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.
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 you

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Sun Dec 01, 2019 12:17 pm
by jimmo
net0040 wrote:
Wed Nov 27, 2019 5:31 am
1.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)
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 2:43 pm
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 you
Good that it's working now for temperature.

Are you trying to connect to a real heart rate sensor (in which case the service and characteristic UUIDs will be different and also the interpretation of the characteristic value), or are you trying to build heart rate sensor such that something else can connect to it (if so, what are you using to connect to it?).

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Mon Dec 02, 2019 2:11 pm
by net0040
(if so, what are you using to connect to it?
I'm connecting it with ESP32(arduino) and arduino 101 and Android Phones.They all work normally.

For micropython,I used to connect with old firmware(2017-08) and was able to connect successfully.

So, heart rate sensors work normally, maybe I'll wait. :D

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Mon Dec 02, 2019 11:00 pm
by jimmo
net0040 wrote:
Mon Dec 02, 2019 2:11 pm
I'm connecting it with ESP32(arduino) and arduino 101 and Android Phones.They all work normally.

For micropython,I used to connect with old firmware(2017-08) and was able to connect successfully.

So, heart rate sensors work normally, maybe I'll wait.
Sorry I'm still not quite sure I follow...

Is it that:

a)
You have a real heart rate band, that you can connect to from:
ESP32 (arduino)
Arduino 101
Android Phones
Old MicroPython (2017-08)

But you can't connect to it from new MicroPython?

Can you share the code that you used that worked (maybe the Arduino code and the old MicroPython code), and the code you're using now?


or b)
Or are you making a heart rate band in ESP32 MicroPython, that you're also trying to connect to from MicroPython? (Or Arduino or Android?).

If so, can you share code that worked (for both the band and the thing connecting to it), and the new code that doesn't work?

Thanks

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Tue Dec 03, 2019 5:20 am
by net0040
I'm hoping to read data of BLE heart rate band from micropython.
I'm on a business trip to another city, and when I return next week, I'll share the code, or email you.

thanks.

Re: About BLE.gap_connect(esp32-based ubluetooth)

Posted: Thu Dec 05, 2019 1:03 pm
by net0040
If so, can you share code that worked (for both the band and the thing connecting to it),
This is some posts I wrote before, please don't mind that it's Chinese, there's all the code and download links.
thank.

1、https://www.arduino.cn/thread-85796-1-1.html Esp32 arduino get heart rate
2、https://www.arduino.cn/thread-45299-1-1.html ARDUINO101 &blynk
3、http://mc.dfrobot.com.cn/thread-27159-1-1.html micropython get heart rate(2017-09)