File tree Expand file tree Collapse file tree 4 files changed +22
-22
lines changed
libraries/Bluefruit52Lib/src Expand file tree Collapse file tree 4 files changed +22
-22
lines changed Original file line number Diff line number Diff line change 55#include " BLEClientIas.h"
66#include " bluefruit.h"
77
8- BLEClientIas::BLEClientIas () : BLEClientService(UUID16_SVC_IMMEDIATE_ALERT) {
8+ BLEClientIas::BLEClientIas () :
9+ BLEClientService(UUID16_SVC_IMMEDIATE_ALERT), _alert(UUID16_SVC_IMMEDIATE_ALERT) {
910
1011}
1112
1213bool BLEClientIas::begin (void ) {
1314 // invoke superclass begin()
1415 BLEClientService::begin ();
16+
17+ _alert.begin (this );
18+
1519 return true ;
1620}
1721
1822bool BLEClientIas::discover (uint16_t conn_handle) {
1923 VERIFY (BLEClientService::discover (conn_handle));
20-
24+ _conn_hdl = conn_handle;
2125 return true ;
2226}
2327
@@ -26,11 +30,10 @@ uint16_t BLEClientIas::getAlertLevel() {
2630 uint8_t level = 0 ;
2731 ble_gattc_handle_range_t bck_range = Bluefruit.Discovery .getHandleRange ();
2832
29- BLEClientCharacteristic chr (uuid);
30- chr.begin (this );
33+ _alert.begin (this );
3134
32- if (Bluefruit.Discovery .discoverCharacteristic (_conn_hdl, chr )) {
33- level = chr .read8 ();
35+ if (Bluefruit.Discovery .discoverCharacteristic (_conn_hdl, _alert )) {
36+ level = _alert .read8 ();
3437 }
3538
3639 Bluefruit.Discovery .setHandleRange (bck_range);
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ class BLEClientIas : public BLEClientService {
1919
2020 uint16_t getAlertLevel (void );
2121
22+ private:
23+ BLEClientCharacteristic _alert;
24+
2225};
2326
2427
Original file line number Diff line number Diff line change 77#include " utility/utilities.h"
88#include " BLEService.h"
99
10- BLEIas::BLEIas (void ) : BLEService(UUID16_SVC_IMMEDIATE_ALERT) {
10+ BLEIas::BLEIas (void ) :
11+ BLEService(UUID16_SVC_IMMEDIATE_ALERT), _alert(UUID16_SVC_IMMEDIATE_ALERT) {
1112
1213}
1314
14- void BLEIas::setAlertLevel (uint8_t alert_level) {
15- _alert_level = alert_level;
15+ void BLEIas::write (uint8_t alert_level) {
16+ _alert. write8 ( alert_level) ;
1617}
1718
1819err_t BLEIas::begin (void ) {
1920
2021 // Invoke the superclass begin()
2122 VERIFY_STATUS (BLEService::begin ());
2223
23- BLECharacteristic chars;
24+ _alert.setProperties (CHR_PROPS_READ);
25+ _alert.setPermission (SECMODE_OPEN, SECMODE_NO_ACCESS);
26+ _alert.setFixedLen (1 );
2427
25- chars.setUuid (UUID16_CHR_ALERT_LEVEL);
26- chars.setTempMemory ();
27- chars.setProperties (CHR_PROPS_READ);
28- chars.setFixedLen (sizeof (_alert_level));
29- VERIFY_STATUS (chars.begin ());
30- chars.write8 (_alert_level);
28+ VERIFY_STATUS ( _alert.begin () );
3129
3230 return ERROR_NONE;
3331
Original file line number Diff line number Diff line change 1414class BLEIas : public BLEService {
1515
1616protected:
17- union {
18- struct {
19- uint8_t _alert_level; // UUID 0x2A06
20- };
21- };
17+ BLECharacteristic _alert;
2218
2319public:
2420 BLEIas (void );
2521
26- void setAlertLevel (uint8_t alert_level );
22+ void write (uint8_t level );
2723
2824 virtual err_t begin (void );
2925
You can’t perform that action at this time.
0 commit comments