add ble
This commit is contained in:
parent
0b141290b4
commit
8484546773
@ -9,9 +9,18 @@ const char* TENG_SUUID = "00010000-9a74-4b30-9361-4a16ec09930f"; // Se
|
||||
const char* TENG_STATUS_CUUID = "00010001-9a74-4b30-9361-4a16ec09930f"; // Characteristic UUID
|
||||
const char* TENG_COMMAND_CUUID = "00010002-9a74-4b30-9361-4a16ec09930f"; // Characteristic UUID
|
||||
const char* TENG_READING_CUUID = "00010003-9a74-4b30-9361-4a16ec09930f"; // Characteristic UUID
|
||||
const char* TENG_BASELINE_CUUID = "00010004-9a74-4b30-9361-4a16ec09930f"; // Characteristic UUID
|
||||
BLEService tengService(TENG_SUUID);
|
||||
BLEByteCharacteristic tengStatus(TENG_STATUS_CUUID, BLERead | BLENotify);
|
||||
BLEByteCharacteristic tengCommand(TENG_COMMAND_CUUID, BLEWrite);
|
||||
BLEUnsignedShortCharacteristic tengReading(TENG_READING_CUUID, BLERead);
|
||||
BLEUnsignedShortCharacteristic tengReading(TENG_READING_CUUID, BLERead | BLENotify);
|
||||
BLEUnsignedShortCharacteristic tengBaseline(TENG_BASELINE_CUUID, BLERead);
|
||||
|
||||
enum Command : byte { NOOP = 0, MEASURE_BASELINE }
|
||||
enum Command : byte { NOOP = 0, MEASURE_BASELINE };
|
||||
|
||||
void initServices() {
|
||||
tengService.addCharacteristic(tengStatus);
|
||||
tengService.addCharacteristic(tengCommand);
|
||||
tengService.addCharacteristic(tengReading);
|
||||
tengService.addCharacteristic(tengBaseline);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "services.hpp"
|
||||
|
||||
// needs to be in separate file because sketch preprocessor reorders stuff
|
||||
enum DeviceStatus : uint8_t { ERROR = 0, BUSY, WAIT_CONNECT, MEASURING_BASELINE, READING };
|
||||
enum DeviceStatus : byte { ERROR = 0, BUSY, WAIT_CONNECT, MEASURING_BASELINE, READING };
|
||||
|
||||
void setStatusLED(DeviceStatus s, bool value) {
|
||||
switch (s) {
|
||||
|
@ -20,8 +20,8 @@ void blinkLED(unsigned n=5, unsigned delay_=200) {
|
||||
|
||||
|
||||
|
||||
unsigned MAX_DEVIATION = 0;
|
||||
unsigned BASELINE = 0;
|
||||
uint16_t MAX_DEVIATION = 0;
|
||||
uint16_t BASELINE = 0;
|
||||
void measureBaseline(unsigned nMeas, unsigned interval=50) {
|
||||
uint64_t value = 0;
|
||||
unsigned minVal = 1023;
|
||||
@ -62,10 +62,7 @@ void setup() {
|
||||
byte data[10] = "\xFF\xFFMQU@TUM"; // 0xFFFF manufacturer id for testing
|
||||
BLE.setManufacturerData(data, 10);
|
||||
|
||||
tengService.addCharacteristic(tengStatus);
|
||||
tengService.addCharacteristic(tengCommand);
|
||||
tengService.addCharacteristic(tengReading);
|
||||
|
||||
initServices();
|
||||
BLE.addService(tengService);
|
||||
BLE.setAdvertisedService(tengService);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user