added IAS service

This commit is contained in:
Charlie B committed 2023-04-19 16:17:07 -04:00
1 parent 211566bc25
commit 5d96925d9a
4 files changed
+86

No files matched your search

@@ -0,0 +1,5 @@
//
// Created by Charlie Bershatsky on 4/19/23.
//
#include "BLEClientIas.h"
@@ -0,0 +1,14 @@
//
// Created by Charlie Bershatsky on 4/19/23.
//
#ifndef ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
#define ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
class BLEClientIas {
};
#endif //ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
@@ -0,0 +1,34 @@
//
// Created by Charlie Bershatsky on 4/19/23.
//
#include "BLEIas.h"
#include "bluefruit.h"
#include "utility/utilities.h"
#include "BLEService.h"
BLEIas::BLEIas(void) : BLEService(UUID16_SVC_IMMEDIATE_ALERT) {
}
void BLEIas::setAlertLevel(const uint8_t alert_level) {
_alert_level = alert_level;
}
err_t BLEIas::begin(void) {
// Invoke the superclass begin()
VERIFY_STATUS(BLEService::begin());
BLECharacteristic chars;
chars.setUuid(UUID16_CHR_ALERT_LEVEL);
chars.setTempMemory();
chars.setProperties(CHR_PROPS_READ);
chars.setFixedLen(sizeof(_alert_level));
VERIFY_STATUS(chars.begin());
chars.write(_alert_level, sizeof(_alert_level));
return ERROR_NONE;
}
@@ -0,0 +1,33 @@
//
// Created by Charlie Bershatsky on 4/19/23.
//
#ifndef ADAFRUIT_NRF52_ARDUINO_BLEIAS_H
#define ADAFRUIT_NRF52_ARDUINO_BLEIAS_H
#include "bluefruit_common.h"
#include "BLEService.h"
#include "BLECharacteristic.h"
class BLEIas : public BLEService {
protected:
union {
struct {
const uint8_t _alert_level; // UUID 0x2A06
};
};
public:
BLEIas(void);
void setAlertLevel(uint8_t alert_level);
virtual err_t begin(void);
};
#endif //ADAFRUIT_NRF52_ARDUINO_BLEIAS_H