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.
WeatherStation.h@14:c5578b5edabe, 2019-04-02 (annotated)
- Committer:
- loicguibert
- Date:
- Tue Apr 02 09:51:34 2019 +0000
- Revision:
- 14:c5578b5edabe
- Parent:
- 12:856286ad4cdc
Added battery service;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| loicguibert | 4:bfe306335065 | 1 | #pragma once |
| loicguibert | 4:bfe306335065 | 2 | |
| loicguibert | 4:bfe306335065 | 3 | #include "Logger.h" |
| loicguibert | 11:dbc310addbf6 | 4 | #include "IDevKit.h" |
| loicguibert | 4:bfe306335065 | 5 | #include "LPS25HBDevice.h" |
| loicguibert | 4:bfe306335065 | 6 | #include "HDC1000Device.h" |
| loicguibert | 11:dbc310addbf6 | 7 | #include "MeasurementHistory.h" |
| loicguibert | 11:dbc310addbf6 | 8 | #include "ble/BLE.h" |
| loicguibert | 11:dbc310addbf6 | 9 | #include "GAPPeripheral.h" |
| loicguibert | 14:c5578b5edabe | 10 | #include "BatteryService.h" |
| loicguibert | 14:c5578b5edabe | 11 | #include "EnvironmentalService.h" |
| loicguibert | 12:856286ad4cdc | 12 | #include <ctime> |
| loicguibert | 4:bfe306335065 | 13 | |
| loicguibert | 11:dbc310addbf6 | 14 | |
| loicguibert | 11:dbc310addbf6 | 15 | class WeatherStation : public GAPPeripheral { |
| loicguibert | 4:bfe306335065 | 16 | public: |
| loicguibert | 4:bfe306335065 | 17 | // constructor |
| loicguibert | 11:dbc310addbf6 | 18 | WeatherStation(IDevKit& iDevKit, Logger& logger, BLE& ble); |
| loicguibert | 4:bfe306335065 | 19 | |
| loicguibert | 4:bfe306335065 | 20 | // called for starting the weather station |
| loicguibert | 4:bfe306335065 | 21 | // it will start getting measurements and advertise with data measurements |
| loicguibert | 4:bfe306335065 | 22 | void start(); |
| loicguibert | 4:bfe306335065 | 23 | |
| loicguibert | 4:bfe306335065 | 24 | // called by timer |
| loicguibert | 4:bfe306335065 | 25 | void performMeasurements(void); |
| loicguibert | 12:856286ad4cdc | 26 | |
| loicguibert | 12:856286ad4cdc | 27 | // Called at the end of performMeasurements(void): encode and send values to the GAP Peripheral |
| loicguibert | 12:856286ad4cdc | 28 | void setupAdvertisementPayload(double pressure, double temp, double humidity); |
| loicguibert | 14:c5578b5edabe | 29 | |
| loicguibert | 14:c5578b5edabe | 30 | virtual void onInitComplete(BLE::InitializationCompleteCallbackContext *event); |
| loicguibert | 4:bfe306335065 | 31 | |
| loicguibert | 4:bfe306335065 | 32 | private: |
| loicguibert | 4:bfe306335065 | 33 | // data members |
| loicguibert | 4:bfe306335065 | 34 | |
| loicguibert | 4:bfe306335065 | 35 | // event queue for handling all events (including timers) |
| loicguibert | 4:bfe306335065 | 36 | events::EventQueue m_eventQueue; |
| loicguibert | 4:bfe306335065 | 37 | |
| loicguibert | 4:bfe306335065 | 38 | // measurement interval |
| loicguibert | 4:bfe306335065 | 39 | static const int m_measurementInterval; |
| loicguibert | 4:bfe306335065 | 40 | |
| loicguibert | 4:bfe306335065 | 41 | // blink interval |
| loicguibert | 4:bfe306335065 | 42 | static const int m_blinkInterval; |
| loicguibert | 4:bfe306335065 | 43 | |
| loicguibert | 12:856286ad4cdc | 44 | //Station name |
| loicguibert | 12:856286ad4cdc | 45 | static const string m_stationName; |
| loicguibert | 12:856286ad4cdc | 46 | |
| loicguibert | 4:bfe306335065 | 47 | // reference to dev kit |
| loicguibert | 11:dbc310addbf6 | 48 | IDevKit& m_iDevKit; |
| loicguibert | 4:bfe306335065 | 49 | |
| loicguibert | 4:bfe306335065 | 50 | // reference to logger |
| loicguibert | 4:bfe306335065 | 51 | Logger& m_logger; |
| loicguibert | 4:bfe306335065 | 52 | |
| loicguibert | 5:0d9e292a9d06 | 53 | // reference to devices |
| loicguibert | 4:bfe306335065 | 54 | LPS25HBDevice m_lps25hb; |
| loicguibert | 4:bfe306335065 | 55 | |
| loicguibert | 4:bfe306335065 | 56 | HDC1000Device m_hdc1000; |
| loicguibert | 11:dbc310addbf6 | 57 | |
| loicguibert | 12:856286ad4cdc | 58 | // reference to values' history storage |
| loicguibert | 11:dbc310addbf6 | 59 | MeasurementHistory m_history; |
| loicguibert | 12:856286ad4cdc | 60 | |
| loicguibert | 12:856286ad4cdc | 61 | // reference to advertising payload |
| loicguibert | 12:856286ad4cdc | 62 | ServiceDataPayload dataPayload[1]; |
| loicguibert | 14:c5578b5edabe | 63 | |
| loicguibert | 14:c5578b5edabe | 64 | // services |
| loicguibert | 14:c5578b5edabe | 65 | BatteryService m_batteryService; |
| loicguibert | 14:c5578b5edabe | 66 | |
| loicguibert | 14:c5578b5edabe | 67 | EnvironmentalService m_environmentalService; |
| loicguibert | 11:dbc310addbf6 | 68 | |
| loicguibert | 4:bfe306335065 | 69 | }; |