seismo

Dependencies:   SDFileSystem circular_buffer MPU6050 SoftSerial

source/MPUService.h

Committer:
suads
Date:
2018-11-23
Revision:
7:bc915651d90e
Parent:
0:a4de55cab4e2

File content as of revision 7:bc915651d90e:

#ifndef __BLE_MPU_SERVICE_H__
#define __BLE_MPU_SERVICE_H__

class MPUService {
public:
    const static uint16_t MPU_SERVICE_UUID              = 0xA000;
    const static uint16_t MPU_STATE_CHARACTERISTIC_UUID = 0xA001;

    MPUService(BLEDevice &_ble, double x) :
        ble(_ble), mpuState(MPU_STATE_CHARACTERISTIC_UUID, &x,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
    {
        GattCharacteristic *charTable[] = {&mpuState};
        GattService         mpuService(MPU_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
        ble.addService(mpuService);
    }

    GattAttribute::Handle_t getValueHandle() const
    {
        return mpuState.getValueHandle();
    }
     void updateSensorValue(double newValue) {
        ble.gattServer().write(mpuState.getValueHandle(), (uint8_t *)&newValue, sizeof(double));
    }

private:
    BLEDevice                         &ble;
    ReadWriteGattCharacteristic<double> mpuState;
};

#endif /* #ifndef __BLE_MPU_SERVICE_H__ */