You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it should be possible for a connected Bluetooth client like a smartphone to switch on accelerometer data notifications. After enabling notifications, none are ever received however.
Here's a simple test application:
/** * This is a simple template for use with Calliope mini. * * @copyright (c) Calliope gGmbH. * @author Matthias L. Jugel. * * Licensed under the Apache License 2.0 */#include<MicroBit.h>MicroBituBit;
voidonConnected(MicroBitEvent)
{
uBit.display.scroll("C");
}
voidonDisconnected(MicroBitEvent)
{
uBit.display.scroll("D");
}
intmain(void)
{
uBit.init();
uBit.serial.baud(115200);
uBit.serial.send("Calliope BLE accelerometer test v1.0\r\n");
uBit.display.scroll("BLE ACC");
uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, onConnected);
uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, onDisconnected);
uBit.accelerometer.setRange(8);
newMicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
release_fiber();
}
Furthermore, reading the Accelerometer Data characteristic always returns a value of zero. Here's a screenshot of nRF Connect showing this:
I investigated and found a clue.
There are two accelerometer drivers in the source tree. One of them creates events for component ID MICROBIT_ID_ACCELEROMETER (=4) and the other uses component ID (BMX055_ACC_ADDRESS<<1)=48.
The MicroBitAccelerometerService.cpp class registers for events from MICROBIT_ID_ACCELEROMETER but never receives any callbacks for that event.
I changed MicroBitAccelerometerService.cpp to register for events from component ID 4:
printf("About to register for accelerometer events\r\n");
if (EventModel::defaultEventBus) {
intid=BMX055_ACC_ADDRESS<<1;
printf("id=%d\r\n",id);
EventModel::defaultEventBus->listen(id, MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE, this, &MicroBitAccelerometerService::accelerometerUpdate, MESSAGE_BUS_LISTENER_IMMEDIATE);
}
But this made no difference. Callbacks were not received.
As an experiment, I then registered for the same events from MICROBIT_ID_ACCELEROMETER from within my main method, like this:
Now I receive callbacks in the accelerometer service class and the Bluetooth accelerometer service is working.
So, somewhere I think there's a mix up with component IDs used for events. I'm also not sure why you include both accelerometer drivers in the build. Is that deliberate or a mistake?
The text was updated successfully, but these errors were encountered:
With the accelerometer service included in a hex file by including the following line of code:
it should be possible for a connected Bluetooth client like a smartphone to switch on accelerometer data notifications. After enabling notifications, none are ever received however.
Here's a simple test application:
Furthermore, reading the Accelerometer Data characteristic always returns a value of zero. Here's a screenshot of nRF Connect showing this:
I investigated and found a clue.
There are two accelerometer drivers in the source tree. One of them creates events for component ID MICROBIT_ID_ACCELEROMETER (=4) and the other uses component ID (BMX055_ACC_ADDRESS<<1)=48.
The MicroBitAccelerometerService.cpp class registers for events from MICROBIT_ID_ACCELEROMETER but never receives any callbacks for that event.
I changed MicroBitAccelerometerService.cpp to register for events from component ID 4:
But this made no difference. Callbacks were not received.
As an experiment, I then registered for the same events from MICROBIT_ID_ACCELEROMETER from within my main method, like this:
Now I receive callbacks in the accelerometer service class and the Bluetooth accelerometer service is working.
So, somewhere I think there's a mix up with component IDs used for events. I'm also not sure why you include both accelerometer drivers in the build. Is that deliberate or a mistake?
The text was updated successfully, but these errors were encountered: