Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: WeatherStation.cpp
- Revision:
- 14:c5578b5edabe
- Parent:
- 12:856286ad4cdc
- Child:
- 15:aac1b3950a9e
--- a/WeatherStation.cpp Mon Mar 25 14:55:30 2019 +0000
+++ b/WeatherStation.cpp Tue Apr 02 09:51:34 2019 +0000
@@ -6,12 +6,14 @@
// constructor
WeatherStation::WeatherStation(IDevKit& iDevKit, Logger& logger, BLE& ble) :
- GAPPeripheral(ble, iDevKit, m_stationName, GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED, m_eventQueue, logger),
+ GAPPeripheral(ble, iDevKit, m_stationName, GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED, m_eventQueue, logger),
m_iDevKit(iDevKit),
m_logger(logger),
m_lps25hb(m_iDevKit.getSDA(), m_iDevKit.getSCL(), m_logger),
m_hdc1000(m_iDevKit.getSDA(), m_iDevKit.getSCL(), m_iDevKit.getDataRdy(), m_logger),
- m_history() {
+ m_history(),
+ m_batteryService(ble, m_logger),
+ m_environmentalService(ble, m_logger) {
// Set the right timing at the Station's start
time(NULL);
}
@@ -49,7 +51,7 @@
m_eventQueue.call_every(m_measurementInterval, this, &WeatherStation::performMeasurements);
// Starting the BLE peripheral with Advertising State
- GAPPeripheral::advertise();
+ GAPPeripheral::advertise();
}
void WeatherStation::performMeasurements(void) {
@@ -101,4 +103,10 @@
// Sending the Advertising Payload to the GAP Peripheral
// Has just one Payload
setAdvertisementServiceData(dataPayload, 1);
+}
+
+void WeatherStation::onInitComplete(BLE::InitializationCompleteCallbackContext *event) {
+ GAPPeripheral::onInitComplete(event);
+ m_batteryService.addServiceToGattServer();
+ m_batteryService.updateBatteryLevel(m_lps25hb.getPressure());
}
\ No newline at end of file