question

petaramesh avatar image
petaramesh asked

BLE advertising stops when VictronConnect connected to device

Hello,
I've built a cutom (Raspberry Pi Pico) based device that centalizes information from all of my Victron equiment and automatizes things, and it receives my Victron equipment info via Bluetooth BLE.
I however have noticed that when my phone connects to one of the devices with VictronConnect, the corresponding device seems to stop emitting BLE advertisings and my custom system doesn't receive any info until VictronConnect disconnects from the device.

Is this the expected behaviour ? Would there be a way to keep receiving information regardless of whether VictronConnect is connected to the device ?1710409426805.jpeg1710409399914.jpeg

Bluetooth Low Energy - BLE
1710409399914.jpeg (174.0 KiB)
1710409426805.jpeg (146.2 KiB)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

4 Answers
Thiemo van Engelen (Victron Energy staff) avatar image
Thiemo van Engelen (Victron Energy staff) answered ·

Hi @petaramesh

The solar charger is advertising when VictronConnect is connected, but with (literally) a bit different data then when it is not connected. What is the code that you use to receive the data? Does it perhaps look at some fixed bytes that the advertisement needs to start with?

Kind regards,

Thiemo van Engelen


1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

petaramesh avatar image petaramesh commented ·

Hello Thiemo,

My code basically relies on the information you published at : https://community.victronenergy.com/storage/attachments/48745-extra-manufacturer-data-2022-12-14.pdf

And that' basically some quick and dirty python code that I wrote and you can find the BT BLE partt here : https://github.com/keshavdv/victron-ble/issues/44#issuecomment-1932031694

Kind regards.

0 Likes 0 ·
Thiemo van Engelen (Victron Energy staff) avatar image
Thiemo van Engelen (Victron Energy staff) answered ·

Hi @petaramesh

There is another difference that I forgot and that is that the actual BLE advertisement type is different. Your code has the following check:

adv_type == 0

According to the API description at https://docs.micropython.org/en/latest/library/bluetooth.html, adv_type becomes 0x02 when VictronConnect is connected to the device. ADV_IND, which is normally used and means connectable and scannable, but once a device is connected, the advertisement is changed to ADV_SCAN_IND as it is no longer connectable. See also https://novelbits.io/bluetooth-low-energy-advertisements-part-1/.

So when you change the check to either check for 0 or 2, you will probably also receive the packets when VictronConnect is connected.

Kind regards,

Thiemo van Engelen

(edited) Probably found the correct API and filled in the correct values to check for.

3 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

petaramesh avatar image petaramesh commented ·
Hello,

From memory I had excluded 0x02 adv packets for, when I first tried to dump what I received from the Victrons (I first developped only with a Smart Battery Sense that I could easily bring home), I did see some 0x02 packets, but they didn't seem to be formatted the same as the 0x00 packets and they didn't seem to contain any usable information...

So I'll try it but will check my code to avoid to break things by trying to process invalid or unparsable data...

Thanks again for the hint.

0 Likes 0 ·
Show more comments
Thiemo van Engelen (Victron Energy staff) avatar image
Thiemo van Engelen (Victron Energy staff) answered ·

Hi @petaramesh

Something else by the way: you might want to change the scan window to 400 msec, as the advertisement interval of our devices is something like 350 msec when VictronConnect is connected so increasing the scan window to >350 msec increases the change of actually seeing the advertisement.

Kind regards,

Thiemo van Engelen

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

petaramesh avatar image petaramesh commented ·
Thank you very much for the insight Thiemo, I will definitely try this !
0 Likes 0 ·
petaramesh avatar image
petaramesh answered ·

Hi @Thiemo van Engelen (Victron Energy staff)
I could finally find some time to try implement your suggestions in my code, and it works like a charm, thank you !
Now I can receive and process Victron devices advertisements whether or not the device is connected to the VictronConnect app on my phone.
Here's the new code I use for BT processing : https://github.com/keshavdv/victron-ble/issues/44#issuecomment-2041409051

If I find time, I may sometime create a Githuh repo of my own to put my complete project code in it.

Thanks again for your help !

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Additional resources still need to be added for this topic