Merge pull request #769 from qubitter/master
Add support for Immediate Alert Service
This commit is contained in:
6 files changed
+134
No files matched your search
@@ -13,6 +13,7 @@
|
||||
/tools/.idea/
|
||||
/tools/midi_tests/node_modules
|
||||
|
||||
.idea/
|
||||
.DS_Store
|
||||
*.swp
|
||||
/Output
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "services/BLEDfu.h"
|
||||
#include "services/BLEUart.h"
|
||||
#include "services/BLEBas.h"
|
||||
#include "services/BLEIas.h"
|
||||
#include "services/BLEBeacon.h"
|
||||
#include "services/BLEHidGeneric.h"
|
||||
#include "services/BLEHidAdafruit.h"
|
||||
@@ -75,6 +76,7 @@
|
||||
#include "clients/BLEClientCts.h"
|
||||
#include "clients/BLEClientHidAdafruit.h"
|
||||
#include "clients/BLEClientBas.h"
|
||||
#include "clients/BLEClientIas.h"
|
||||
|
||||
#include "utility/AdaCallback.h"
|
||||
#include "utility/bonding.h"
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Created by Charlie Bershatsky on 4/19/23.
|
||||
//
|
||||
|
||||
#include "BLEClientIas.h"
|
||||
#include "bluefruit.h"
|
||||
|
||||
BLEClientIas::BLEClientIas() :
|
||||
BLEClientService(UUID16_SVC_IMMEDIATE_ALERT), _alert(UUID16_SVC_IMMEDIATE_ALERT) {
|
||||
|
||||
}
|
||||
|
||||
bool BLEClientIas::begin(void) {
|
||||
// invoke superclass begin()
|
||||
BLEClientService::begin();
|
||||
|
||||
_alert.begin(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLEClientIas::discover(uint16_t conn_handle) {
|
||||
VERIFY(BLEClientService::discover(conn_handle));
|
||||
_conn_hdl = conn_handle;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t BLEClientIas::getAlertLevel() {
|
||||
|
||||
uint8_t level = 0;
|
||||
ble_gattc_handle_range_t bck_range = Bluefruit.Discovery.getHandleRange();
|
||||
|
||||
_alert.begin(this);
|
||||
|
||||
if (Bluefruit.Discovery.discoverCharacteristic(_conn_hdl, _alert)) {
|
||||
level = _alert.read8();
|
||||
}
|
||||
|
||||
Bluefruit.Discovery.setHandleRange(bck_range);
|
||||
|
||||
return level;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by Charlie Bershatsky on 4/19/23.
|
||||
//
|
||||
|
||||
#ifndef ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
|
||||
#define ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
|
||||
|
||||
#include "bluefruit_common.h"
|
||||
#include "BLEClientCharacteristic.h"
|
||||
#include "BLEClientService.h"
|
||||
|
||||
class BLEClientIas : public BLEClientService {
|
||||
|
||||
public:
|
||||
BLEClientIas(void);
|
||||
|
||||
virtual bool begin(void);
|
||||
virtual bool discover(uint16_t conn_handle);
|
||||
|
||||
uint16_t getAlertLevel (void);
|
||||
|
||||
private:
|
||||
BLEClientCharacteristic _alert;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //ADAFRUIT_NRF52_ARDUINO_BLECLIENTIAS_H
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// 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), _alert(UUID16_SVC_IMMEDIATE_ALERT) {
|
||||
|
||||
}
|
||||
|
||||
void BLEIas::write(uint8_t alert_level) {
|
||||
_alert.write8(alert_level);
|
||||
}
|
||||
|
||||
err_t BLEIas::begin(void) {
|
||||
|
||||
// Invoke the superclass begin()
|
||||
VERIFY_STATUS(BLEService::begin());
|
||||
|
||||
_alert.setProperties(CHR_PROPS_READ);
|
||||
_alert.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS);
|
||||
_alert.setFixedLen(1);
|
||||
|
||||
VERIFY_STATUS( _alert.begin() );
|
||||
|
||||
return ERROR_NONE;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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:
|
||||
BLECharacteristic _alert;
|
||||
|
||||
public:
|
||||
BLEIas(void);
|
||||
|
||||
void write(uint8_t level);
|
||||
|
||||
virtual err_t begin(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //ADAFRUIT_NRF52_ARDUINO_BLEIAS_H
|
||||
Reference in new issue
Block a user