Skip to content

Commit a55de5f

Browse files
committed
adding client bas
1 parent df8a17c commit a55de5f

File tree

6 files changed

+132
-9
lines changed

6 files changed

+132
-9
lines changed

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#include "clients/BLEClientDis.h"
8282
#include "clients/BLEClientCts.h"
8383
#include "clients/BLEClientHidAdafruit.h"
84+
#include "clients/BLEClientBas.h"
8485

8586
#include "utility/AdaCallback.h"
8687
#include "utility/bonding.h"

libraries/Bluefruit52Lib/src/clients/BLEAncs.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ BLEAncs::BLEAncs(void)
7878
_notification(BLEANCS_UUID_CHR_NOTIFICATION), _data(BLEANCS_UUID_CHR_DATA),
7979
_adamsg()
8080
{
81-
_notif_cb = NULL;
81+
_notif_cb = NULL;
8282
}
8383

8484
bool BLEAncs::begin(void)
@@ -116,11 +116,6 @@ bool BLEAncs::discover(uint16_t conn_handle)
116116
return true;
117117
}
118118

119-
void BLEAncs::disconnect(void)
120-
{
121-
BLEClientService::disconnect();
122-
}
123-
124119
void BLEAncs::setNotificationCallback(notification_callback_t fp)
125120
{
126121
_notif_cb = fp;

libraries/Bluefruit52Lib/src/clients/BLEAncs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ class BLEAncs : public BLEClientService
162162
bool actPositive (uint32_t uid);
163163
bool actNegative (uint32_t uid);
164164

165-
protected:
166-
virtual void disconnect(void);
167-
168165
private:
169166
BLEClientCharacteristic _control;
170167
BLEClientCharacteristic _notification;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**************************************************************************/
2+
/*!
3+
@file BLEClientBas.cpp
4+
@author hathach (tinyusb.org)
5+
6+
@section LICENSE
7+
8+
Software License Agreement (BSD License)
9+
10+
Copyright (c) 2019, Adafruit Industries (adafruit.com)
11+
All rights reserved.
12+
13+
Redistribution and use in source and binary forms, with or without
14+
modification, are permitted provided that the following conditions are met:
15+
1. Redistributions of source code must retain the above copyright
16+
notice, this list of conditions and the following disclaimer.
17+
2. Redistributions in binary form must reproduce the above copyright
18+
notice, this list of conditions and the following disclaimer in the
19+
documentation and/or other materials provided with the distribution.
20+
3. Neither the name of the copyright holders nor the
21+
names of its contributors may be used to endorse or promote products
22+
derived from this software without specific prior written permission.
23+
24+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*/
35+
/**************************************************************************/
36+
37+
#include "bluefruit.h"
38+
39+
BLEClientBas::BLEClientBas(void)
40+
: BLEClientService(UUID16_SVC_BATTERY), _battery(UUID16_CHR_BATTERY_LEVEL)
41+
{
42+
43+
}
44+
45+
bool BLEClientBas::begin(void)
46+
{
47+
// Invoke base class begin()
48+
BLEClientService::begin();
49+
50+
_battery.begin(this);
51+
52+
return true;
53+
}
54+
55+
bool BLEClientBas::discover(uint16_t conn_handle)
56+
{
57+
// Call BLECentralService discover
58+
VERIFY( BLEClientService::discover(conn_handle) );
59+
_conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars
60+
61+
// Discover TXD, RXD characteristics
62+
VERIFY( 1 == Bluefruit.Discovery.discoverCharacteristic(conn_handle, _battery) );
63+
64+
_conn_hdl = conn_handle;
65+
return true;
66+
}
67+
68+
uint8_t BLEClientBas::read(void)
69+
{
70+
return _battery.read8();
71+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**************************************************************************/
2+
/*!
3+
@file BLEClientBas.h
4+
@author hathach (tinyusb.org)
5+
6+
@section LICENSE
7+
8+
Software License Agreement (BSD License)
9+
10+
Copyright (c) 2019, Adafruit Industries (adafruit.com)
11+
All rights reserved.
12+
13+
Redistribution and use in source and binary forms, with or without
14+
modification, are permitted provided that the following conditions are met:
15+
1. Redistributions of source code must retain the above copyright
16+
notice, this list of conditions and the following disclaimer.
17+
2. Redistributions in binary form must reproduce the above copyright
18+
notice, this list of conditions and the following disclaimer in the
19+
documentation and/or other materials provided with the distribution.
20+
3. Neither the name of the copyright holders nor the
21+
names of its contributors may be used to endorse or promote products
22+
derived from this software without specific prior written permission.
23+
24+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*/
35+
/**************************************************************************/
36+
37+
#ifndef BLECLIENTBAS_H_
38+
#define BLECLIENTBAS_H_
39+
40+
#include "bluefruit_common.h"
41+
#include "BLEClientCharacteristic.h"
42+
#include "BLEClientService.h"
43+
44+
class BLEClientBas : public BLEClientService
45+
{
46+
public:
47+
BLEClientBas(void);
48+
49+
virtual bool begin(void);
50+
virtual bool discover(uint16_t conn_handle);
51+
52+
uint8_t read(void);
53+
54+
private:
55+
BLEClientCharacteristic _battery;
56+
}
57+
58+
#endif /* BLECLIENTBAS_H_ */

libraries/Bluefruit52Lib/src/clients/BLEClientDis.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
*/
3535
/**************************************************************************/
36+
3637
#ifndef BLECLIENTDIS_H_
3738
#define BLECLIENTDIS_H_
3839

0 commit comments

Comments
 (0)