adafruit / Adafruit_CircuitPython_BLE_Adafruit

Support for the BLE Adafruit Service, which provides access to on-board sensors and components
MIT License
9 stars 6 forks source link

Only AccelerometerService is discovered. #20

Open hkayann opened 2 years ago

hkayann commented 2 years ago

I have nRF Feather Sense 82540.

I am trying to send accelerometer, gyroscope, and magnetometer data over BLE.

I am using the nRF Connect app. Even though, I add all three services only AccelerometerService() is discovered.

The related part of the code is below:

gyro_svc = GyroscopeService()
gyro_svc.measurement_period = 100
gyro_last_update = 0

accel_svc = AccelerometerService()
accel_svc.measurement_period = 100 
accel_last_update = 0

mag_svc = MagnetometerService()
mag_svc.measurement_period = 100 
mag_last_update = 0

ble = BLERadio()
ble.name = "Sense"
# Arduino: 0x8087,  CircuitPython: 0x8088
adv = AdafruitServerAdvertisement()
adv.pid = 0x8088

while True:
    # Advertise when not connected.
    ble.start_advertising(adv)
    while not ble.connected:
        pass
    ble.stop_advertising()

    while ble.connected:
        now_msecs = time.monotonic_ns() // 1000000  # pylint: disable=no-member
        if now_msecs - mag_last_update >= mag_svc.measurement_period:
            mag_svc.magnetic = lis3mdl.magnetic
            mag_last_update = now_msecs
        if now_msecs - accel_last_update >= accel_svc.measurement_period:
            accel_svc.acceleration = lsm6ds33.acceleration # m/s^2 - Tuple
            accel_last_update = now_msecs
        if now_msecs - gyro_last_update >= gyro_svc.measurement_period:
            gyro_svc.gyro = lsm6ds33.gyro
            gyro_last_update = now_msecs

What might be the reason?

dhalbert commented 2 years ago

Try the Bluefruit Playground app instead of nRF Connect: https://learn.adafruit.com/bluefruit-playground-app/circuitpython. If that doesn't work, post your entire program (could be uploaded as a .zip file if it's large).

tannewt commented 2 years ago

nRF connect will only see Adafruit server in the scan. Once you connect you should be able to see them all under the client tab. There is a difference between what is advertised and what is made available over a connection through GATT.