Skip to content

Commit 5d96925

Browse files
committed
added IAS service
1 parent 211566b commit 5d96925

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
// Created by Charlie Bershatsky on 4/19/23.
3+
//
4+
5+
#include "BLEClientIas.h"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Created by Charlie Bershatsky on 4/19/23.
3+
//
4+
5+
#ifndef ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
6+
#define ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
7+
8+
9+
class BLEClientIas {
10+
11+
};
12+
13+
14+
#endif //ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Created by Charlie Bershatsky on 4/19/23.
3+
//
4+
5+
#include "BLEIas.h"
6+
#include "bluefruit.h"
7+
#include "utility/utilities.h"
8+
#include "BLEService.h"
9+
10+
BLEIas::BLEIas(void) : BLEService(UUID16_SVC_IMMEDIATE_ALERT) {
11+
12+
}
13+
14+
void BLEIas::setAlertLevel(const uint8_t alert_level) {
15+
_alert_level = alert_level;
16+
}
17+
18+
err_t BLEIas::begin(void) {
19+
20+
// Invoke the superclass begin()
21+
VERIFY_STATUS(BLEService::begin());
22+
23+
BLECharacteristic chars;
24+
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.write(_alert_level, sizeof(_alert_level));
31+
32+
return ERROR_NONE;
33+
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// Created by Charlie Bershatsky on 4/19/23.
3+
//
4+
5+
#ifndef ADAFRUIT_NRF52_ARDUINO_BLEIAS_H
6+
#define ADAFRUIT_NRF52_ARDUINO_BLEIAS_H
7+
8+
#include "bluefruit_common.h"
9+
10+
#include "BLEService.h"
11+
#include "BLECharacteristic.h"
12+
13+
14+
class BLEIas : public BLEService {
15+
16+
protected:
17+
union {
18+
struct {
19+
const uint8_t _alert_level; // UUID 0x2A06
20+
};
21+
};
22+
23+
public:
24+
BLEIas(void);
25+
26+
void setAlertLevel(uint8_t alert_level);
27+
28+
virtual err_t begin(void);
29+
30+
};
31+
32+
33+
#endif //ADAFRUIT_NRF52_ARDUINO_BLEIAS_H

0 commit comments

Comments
 (0)