jgh
Fork of BLE_API by
Diff: ble/services/EnvironmentalService.h
- Revision:
- 866:a2a40c69eec0
- Parent:
- 865:0f44d2aaf201
--- a/ble/services/EnvironmentalService.h Mon Nov 02 09:09:07 2015 +0000 +++ b/ble/services/EnvironmentalService.h Mon Nov 02 09:09:08 2015 +0000 @@ -40,26 +40,11 @@ * @param humidity_en Enable this characteristic. * @param pressure_en Enable this characteristic. */ - EnvironmentalService(BLE &_ble, - bool temperature_en = false, - bool humidity_en = false, - bool pressure_en = false) : + EnvironmentalService(BLE& _ble) : ble(_ble), - temperatureCharacteristic(GattCharacteristic::UUID_TEMPERATURE_CHAR, - (uint8_t *) &temperature, - (temperature_en) ? 2 : 0, // minLength - (temperature_en) ? 2 : 0, // maxLength - GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), - humidityCharacteristic(GattCharacteristic::UUID_HUMIDITY_CHAR, - (uint8_t *) &humidity, - (humidity_en) ? 2 : 0, // minLength - (humidity_en) ? 2 : 0, // maxLength - GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), - pressureCharacteristic(GattCharacteristic::UUID_PRESSURE_CHAR, - (uint8_t *) &pressure, - (pressure_en) ? 4 : 0, // minLength - (pressure_en) ? 4 : 0, // maxLength - GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ) + temperatureCharacteristic(GattCharacteristic::UUID_TEMPERATURE_CHAR, &temperature), + humidityCharacteristic(GattCharacteristic::UUID_HUMIDITY_CHAR, &humidity), + pressureCharacteristic(GattCharacteristic::UUID_PRESSURE_CHAR, &pressure) { static bool serviceAdded = false; /* We should only ever need to add the information service once. */ if (serviceAdded) { @@ -70,8 +55,7 @@ &pressureCharacteristic, &temperatureCharacteristic }; - GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, - sizeof(charTable) / sizeof(GattCharacteristic *)); + GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); ble.gattServer().addService(environmentalService); serviceAdded = true; @@ -108,14 +92,15 @@ } private: - BLE & ble; + BLE& ble; - int16_t temperature; - GattCharacteristic temperatureCharacteristic; - uint16_t humidity; - GattCharacteristic humidityCharacteristic; - uint32_t pressure; - GattCharacteristic pressureCharacteristic; + TemperatureType_t temperature; + HumidityType_t humidity; + PressureType_t pressure; + + ReadOnlyGattCharacteristic<TemperatureType_t> temperatureCharacteristic; + ReadOnlyGattCharacteristic<HumidityType_t> humidityCharacteristic; + ReadOnlyGattCharacteristic<PressureType_t> pressureCharacteristic; }; #endif /* #ifndef __BLE_ENVIRONMENTAL_SERVICE_H__*/ \ No newline at end of file