nRF24 / CircuitPython_nRF24L01

CircuitPython driver library for the nRF24L01 transceiver.
http://circuitpython-nrf24l01.rtfd.io/
MIT License
45 stars 11 forks source link

BLE beacons Receiving #32

Closed 2bndy5 closed 2 years ago

2bndy5 commented 3 years ago

Discussed in https://github.com/2bndy5/CircuitPython_nRF24L01/discussions/30

Originally posted by **salembream** July 3, 2021 Hi, I am wondering if NRF24L01 can be used to receive other (standard) BLE beacons? If it is possible, any guidelines to implement it ?

I turned this into a feature request because I want it despite how inaccurate the results may be.

2bndy5 commented 3 years ago

@salembream Ok, I've added this feature in the rf24-network branch - it will be rolled out with the next release. Docs are updated (they may need a proofreading), and the fake_ble_test example now includes a slave() function that receives BLE payloads and decodes the data within for a specified number of seconds. Use slave(20) to receive for 20 seconds. Sample output from updated example:

pi@rpi2:~/github/CircuitPython_nRF24L01/examples $ python3 nrf24l01_fake_ble_test.py
    nRF24L01 fake BLE beacon test
*** Enter 'M' to broadcast the device name, pa_level, & battery charge.
*** Enter 'T' to broadcast the device name & a temperature
*** Enter 'U' to broadcast a custom URL link
*** Enter 'R' to receive BLE payloads
*** Enter 'Q' to quit example.
r 20
recevied payload from MAC address 5a:d6:bd:95:cc:a5
        device transmitting PA Level: 12 dbm
recevied payload from MAC address 7a:ca:bd:95:cc:a5
        raw buffer (unknowmn format): bytearray(b'\x10\x06\x93\x19\x10#\xce\x0c')
recevied payload from MAC address 68:39:b5:b3:1e:34
        raw buffer (unknowmn format): bytearray(b'\x8b\xb3\xdf\x03\xd0')
recevied payload from MAC address 45:bb:ff:e2:5a:d1
recevied payload from MAC address e6:e6:35:b2:88:64
        device name: nRF24L01
        device transmitting PA Level: -12 dbm
        Battery capacity remaining: 85 %
recevied payload from MAC address 1f:28:4c:48:52:8e
recevied payload from MAC address e6:e6:35:b2:88:64
        device name: nRF24L01
        device transmitting PA Level: -12 dbm
        Battery capacity remaining: 85 %
recevied payload from MAC address e6:e6:35:b2:88:64
        device name: nRF24L01
        device transmitting PA Level: -12 dbm
        Battery capacity remaining: 85 %
recevied payload from MAC address e6:e6:35:b2:88:64
        device name: nRF24L01
        device transmitting PA Level: -12 dbm
        Battery capacity remaining: 85 %
recevied payload from MAC address e6:e6:35:b2:88:64
        device name: nRF24L01
        device transmitting PA Level: -12 dbm
        Battery capacity remaining: 85 %

Clearly a lot more BLE data can be decoded, but for now I'm just decoding all Service Data specifications currently supported by the fake_ble module.

2bndy5 commented 3 years ago

debugging this feature at 2 AM seems to have a smaller sample size (ambiant signals) 🤣