diff options
author | kolban <kolban1@kolban.com> | 2017-09-10 13:36:10 -0500 |
---|---|---|
committer | kolban <kolban1@kolban.com> | 2017-09-10 13:36:10 -0500 |
commit | 5e5b5b78f0aeca611edb52ff4e885334b6fe46a9 (patch) | |
tree | 8d207806891e66ee6ea292d82eb7f120e2138418 /ESP32_BLE_Arduino/src/BLERemoteService.h | |
download | thermostat-5e5b5b78f0aeca611edb52ff4e885334b6fe46a9.tar.gz thermostat-5e5b5b78f0aeca611edb52ff4e885334b6fe46a9.tar.bz2 thermostat-5e5b5b78f0aeca611edb52ff4e885334b6fe46a9.zip |
0.1.0 release
Diffstat (limited to 'ESP32_BLE_Arduino/src/BLERemoteService.h')
-rw-r--r-- | ESP32_BLE_Arduino/src/BLERemoteService.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ESP32_BLE_Arduino/src/BLERemoteService.h b/ESP32_BLE_Arduino/src/BLERemoteService.h new file mode 100644 index 0000000..4393fbc --- /dev/null +++ b/ESP32_BLE_Arduino/src/BLERemoteService.h @@ -0,0 +1,63 @@ +/* + * BLERemoteService.h + * + * Created on: Jul 8, 2017 + * Author: kolban + */ + +#ifndef COMPONENTS_CPP_UTILS_BLEREMOTESERVICE_H_ +#define COMPONENTS_CPP_UTILS_BLEREMOTESERVICE_H_ +#include "sdkconfig.h" +#if defined(CONFIG_BT_ENABLED) + +#include <map> + +#include "BLEClient.h" +#include "BLERemoteCharacteristic.h" +#include "BLEUUID.h" +#include "FreeRTOS.h" + +class BLEClient; +class BLERemoteCharacteristic; + + +/** + * @brief A model of a remote %BLE service. + */ +class BLERemoteService { +public: + BLERemoteService(esp_gatt_srvc_id_t srvcId, BLEClient* pClient); + virtual ~BLERemoteService(); + + // Public methods + BLERemoteCharacteristic* getCharacteristic(const char* uuid); + BLERemoteCharacteristic* getCharacteristic(BLEUUID uuid); + void getCharacteristics(void); + BLEClient* getClient(void); + BLEUUID getUUID(void); + std::string toString(void); + +private: + // Friends + friend class BLEClient; + friend class BLERemoteCharacteristic; + + // Private methods + esp_gatt_srvc_id_t* getSrvcId(void); + void gattClientEventHandler( + esp_gattc_cb_event_t event, + esp_gatt_if_t gattc_if, + esp_ble_gattc_cb_param_t* evtParam); + void removeCharacteristics(); + + // Properties + std::map<std::string, BLERemoteCharacteristic *> m_characteristicMap; + bool m_haveCharacteristics; // Have we previously obtained the characteristics. + BLEClient* m_pClient; + FreeRTOS::Semaphore m_semaphoreGetCharEvt = FreeRTOS::Semaphore("GetCharEvt"); + esp_gatt_srvc_id_t m_srvcId; + BLEUUID m_uuid; +}; // BLERemoteService + +#endif /* CONFIG_BT_ENABLED */ +#endif /* COMPONENTS_CPP_UTILS_BLEREMOTESERVICE_H_ */ |