You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7 KiB

#include "MicroBit.h"
// UUIDs for our service and characteristics
extern const uint8_t MicroBitMagnetometerServiceUUID[];
extern const uint8_t MicroBitMagnetometerServiceDataUUID[];
extern const uint8_t MicroBitMagnetometerServiceBearingUUID[];
extern const uint8_t MicroBitMagnetometerServicePeriodUUID[];
* Class definition for a MicroBit BLE Magnetometer Service.
* Provides access to live magnetometer data via BLE, and provides basic configuration options.
class MicroBitMagnetometerService
* Constructor.
* Create a representation of the MagnetometerService
* @param _ble The instance of a BLE device that we're running on.
MicroBitMagnetometerService(BLEDevice &_ble);
* Callback. Invoked when any of our attributes are written via BLE.
void onDataWritten(const GattWriteCallbackParams *params);
* Magnetometer update callback
void magnetometerUpdate(MicroBitEvent e);
// Bluetooth stack we're running on.
BLEDevice &ble;
// memory for our 8 bit control characteristics.
uint16_t magnetometerDataCharacteristicBuffer[3];
uint16_t magnetometerBearingCharacteristicBuffer;
uint16_t magnetometerPeriodCharacteristicBuffer;
// Handles to access each characteristic when they are held by Soft Device.
GattAttribute::Handle_t magnetometerDataCharacteristicHandle;
GattAttribute::Handle_t magnetometerBearingCharacteristicHandle;
GattAttribute::Handle_t magnetometerPeriodCharacteristicHandle;