Suad Suljic / Mbed OS Seismo2

Dependencies:   SDFileSystem circular_buffer MPU6050 SoftSerial

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MPUService.h Source File

MPUService.h

00001 #ifndef __BLE_MPU_SERVICE_H__
00002 #define __BLE_MPU_SERVICE_H__
00003 
00004 class MPUService {
00005 public:
00006     const static uint16_t MPU_SERVICE_UUID              = 0xA000;
00007     const static uint16_t MPU_STATE_CHARACTERISTIC_UUID = 0xA001;
00008 
00009     MPUService(BLEDevice &_ble, double x) :
00010         ble(_ble), mpuState(MPU_STATE_CHARACTERISTIC_UUID, &x,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
00011     {
00012         GattCharacteristic *charTable[] = {&mpuState};
00013         GattService         mpuService(MPU_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
00014         ble.addService(mpuService);
00015     }
00016 
00017     GattAttribute::Handle_t getValueHandle() const
00018     {
00019         return mpuState.getValueHandle();
00020     }
00021      void updateSensorValue(double newValue) {
00022         ble.gattServer().write(mpuState.getValueHandle(), (uint8_t *)&newValue, sizeof(double));
00023     }
00024 
00025 private:
00026     BLEDevice                         &ble;
00027     ReadWriteGattCharacteristic<double> mpuState;
00028 };
00029 
00030 #endif /* #ifndef __BLE_MPU_SERVICE_H__ */