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 5
5
#include " BLEClientIas.h"
6
6
#include " bluefruit.h"
7
7
8
- BLEClientIas::BLEClientIas () : BLEClientService(UUID16_SVC_IMMEDIATE_ALERT) {
8
+ BLEClientIas::BLEClientIas () :
9
+ BLEClientService(UUID16_SVC_IMMEDIATE_ALERT), _alert(UUID16_SVC_IMMEDIATE_ALERT) {
9
10
10
11
}
11
12
12
13
bool BLEClientIas::begin (void ) {
13
14
// invoke superclass begin()
14
15
BLEClientService::begin ();
16
+
17
+ _alert.begin (this );
18
+
15
19
return true ;
16
20
}
17
21
18
22
bool BLEClientIas::discover (uint16_t conn_handle) {
19
23
VERIFY (BLEClientService::discover (conn_handle));
20
-
24
+ _conn_hdl = conn_handle;
21
25
return true ;
22
26
}
23
27
@@ -26,11 +30,10 @@ uint16_t BLEClientIas::getAlertLevel() {
26
30
uint8_t level = 0 ;
27
31
ble_gattc_handle_range_t bck_range = Bluefruit.Discovery .getHandleRange ();
28
32
29
- BLEClientCharacteristic chr (uuid);
30
- chr.begin (this );
33
+ _alert.begin (this );
31
34
32
- if (Bluefruit.Discovery .discoverCharacteristic (_conn_hdl, chr )) {
33
- level = chr .read8 ();
35
+ if (Bluefruit.Discovery .discoverCharacteristic (_conn_hdl, _alert )) {
36
+ level = _alert .read8 ();
34
37
}
35
38
36
39
Bluefruit.Discovery .setHandleRange (bck_range);
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ class BLEClientIas : public BLEClientService {
19
19
20
20
uint16_t getAlertLevel (void );
21
21
22
+ private:
23
+ BLEClientCharacteristic _alert;
24
+
22
25
};
23
26
24
27
Original file line number Diff line number Diff line change 7
7
#include " utility/utilities.h"
8
8
#include " BLEService.h"
9
9
10
- BLEIas::BLEIas (void ) : BLEService(UUID16_SVC_IMMEDIATE_ALERT) {
10
+ BLEIas::BLEIas (void ) :
11
+ BLEService(UUID16_SVC_IMMEDIATE_ALERT), _alert(UUID16_SVC_IMMEDIATE_ALERT) {
11
12
12
13
}
13
14
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) ;
16
17
}
17
18
18
19
err_t BLEIas::begin (void ) {
19
20
20
21
// Invoke the superclass begin()
21
22
VERIFY_STATUS (BLEService::begin ());
22
23
23
- BLECharacteristic chars;
24
+ _alert.setProperties (CHR_PROPS_READ);
25
+ _alert.setPermission (SECMODE_OPEN, SECMODE_NO_ACCESS);
26
+ _alert.setFixedLen (1 );
24
27
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 () );
31
29
32
30
return ERROR_NONE;
33
31
Original file line number Diff line number Diff line change 14
14
class BLEIas : public BLEService {
15
15
16
16
protected:
17
- union {
18
- struct {
19
- uint8_t _alert_level; // UUID 0x2A06
20
- };
21
- };
17
+ BLECharacteristic _alert;
22
18
23
19
public:
24
20
BLEIas (void );
25
21
26
- void setAlertLevel (uint8_t alert_level );
22
+ void write (uint8_t level );
27
23
28
24
virtual err_t begin (void );
29
25
You can’t perform that action at this time.
0 commit comments