diff --git a/libraries/Bluefruit52Lib/src/BLEGatt.cpp b/libraries/Bluefruit52Lib/src/BLEGatt.cpp index 27a67aba..cd100dcd 100644 --- a/libraries/Bluefruit52Lib/src/BLEGatt.cpp +++ b/libraries/Bluefruit52Lib/src/BLEGatt.cpp @@ -116,7 +116,7 @@ void BLEGatt::_eventHandler(ble_evt_t* evt) for(int i=0; i<_client.chr_count; i++) { - if ( evt_conn_hdl == _client.chr_list[i]->_conn_hdl ) + if ( evt_conn_hdl == _client.chr_list[i]->connHandle() ) { _client.chr_list[i]->disconnect(); } diff --git a/libraries/Bluefruit52Lib/src/bluefruit.h b/libraries/Bluefruit52Lib/src/bluefruit.h index 91c8981a..1b9f363a 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.h +++ b/libraries/Bluefruit52Lib/src/bluefruit.h @@ -75,6 +75,7 @@ #include "clients/BLEAncs.h" #include "clients/BLEClientUart.h" #include "clients/BLEClientDis.h" +#include "clients/BLEClientCts.h" #define BLE_MAX_DATA_PER_MTU (GATT_MTU_SIZE_DEFAULT - 3) diff --git a/libraries/Bluefruit52Lib/src/clients/BLEClientCts.cpp b/libraries/Bluefruit52Lib/src/clients/BLEClientCts.cpp new file mode 100644 index 00000000..c66200e2 --- /dev/null +++ b/libraries/Bluefruit52Lib/src/clients/BLEClientCts.cpp @@ -0,0 +1,68 @@ +/**************************************************************************/ +/*! + @file BLEClientCts.cpp + @author hathach + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2017, Adafruit Industries (adafruit.com) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ + +#include "bluefruit.h" + +BLEClientCts::BLEClientCts(void) + : BLEClientService(UUID16_SVC_CURRENT_TIME), _cur_time(UUID16_CHR_CURRENT_TIME), _local_info(UUID16_CHR_LOCAL_TIME_INFORMATION) +{ + +} + +bool BLEClientCts::begin(void) +{ + // Invoke base class begin() + BLEClientService::begin(); + + _cur_time.begin(this); + _local_info.begin(this); + + return true; +} + +bool BLEClientCts::discover(uint16_t conn_handle) +{ + // Call Base class discover + VERIFY( BLEClientService::discover(conn_handle) ); + _conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars + + // Discover Current Time chars ( mandatory ) + + + // Discover Local Time Information chars ( optional ) + + return true; +} diff --git a/libraries/Bluefruit52Lib/src/clients/BLEClientCts.h b/libraries/Bluefruit52Lib/src/clients/BLEClientCts.h new file mode 100644 index 00000000..5a7479dc --- /dev/null +++ b/libraries/Bluefruit52Lib/src/clients/BLEClientCts.h @@ -0,0 +1,56 @@ +/**************************************************************************/ +/*! + @file BLEClientCts.h + @author hathach + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2017, Adafruit Industries (adafruit.com) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ +#ifndef BLECLIENTCTS_H_ +#define BLECLIENTCTS_H_ + +#include "bluefruit_common.h" +#include "BLEClientCharacteristic.h" +#include "BLEClientService.h" + +class BLEClientCts : public BLEClientService +{ + public: + BLEClientCts(void); + + virtual bool begin(void); + virtual bool discover(uint16_t conn_handle); + + private: + BLEClientCharacteristic _cur_time; + BLEClientCharacteristic _local_info; +}; + +#endif /* BLECLIENTCTS_H_ */