Skip to content

Commit

Permalink
fix value sending
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulaScharf committed Nov 19, 2024
1 parent 84707d5 commit d9dd01c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
10 changes: 5 additions & 5 deletions sensebox-bike-atrai-v2-esp32s3/src/ble/BLEModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool BLEModule::writeBLE(const char * characteristicId, uint8_t value, uint8_t v
{
BLECharacteristic *pCharacteristic = pService->getCharacteristic(characteristicId);
uint8_t buf[2] = {value, value2};
pCharacteristic->setValue(buf,1);
pCharacteristic->setValue(buf,2);
pCharacteristic->notify();
return true;
}
Expand All @@ -85,7 +85,7 @@ bool BLEModule::writeBLE(const char * characteristicId, uint8_t value, uint8_t v
{
BLECharacteristic *pCharacteristic = pService->getCharacteristic(characteristicId);
uint8_t buf[3] = {value, value2, value3};
pCharacteristic->setValue(buf,1);
pCharacteristic->setValue(buf,3);
pCharacteristic->notify();
return true;
}
Expand All @@ -94,16 +94,16 @@ bool BLEModule::writeBLE(const char * characteristicId, uint8_t value, uint8_t v
{
BLECharacteristic *pCharacteristic = pService->getCharacteristic(characteristicId);
uint8_t buf[4] = {value, value2, value3, value4};
pCharacteristic->setValue(buf,1);
pCharacteristic->setValue(buf,4);
pCharacteristic->notify();
return true;
}

bool BLEModule::writeBLE(const char * characteristicId, uint8_t value, uint8_t value2, uint8_t value3, uint8_t value4, uint8_t value5)
{
BLECharacteristic *pCharacteristic = pService->getCharacteristic(characteristicId);
uint8_t buf[5] = {value, value2, value3, value4};
pCharacteristic->setValue(buf,1);
uint8_t buf[5] = {value, value2, value3, value4, value5};
pCharacteristic->setValue(buf,5);
pCharacteristic->notify();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "AccelerationSensor.h"
#include "edge-impulse-sdk/classifier/ei_run_classifier.h"

AccelerationSensor::AccelerationSensor() : BaseSensor("accelerationSensorTask", 2048, 0) {}
AccelerationSensor::AccelerationSensor() : BaseSensor("accelerationSensorTask", 8192, 0) {}

String surfaceClassificationUUID = "b944af10-f495-4560-968f-2f0d18cab521";
// String accUUID = "B944AF10F4954560968F2F0D18CAB522";
Expand Down Expand Up @@ -34,7 +34,7 @@ void AccelerationSensor::initSensor()
anomalyCharacteristic = BLEModule::createCharacteristic(anomalyUUID.c_str());
}

float buffer[6] = {};
float buffer[EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE] = {};
size_t ix = 0;
float probAsphalt = 0.0;
float probCompact = 0.0;
Expand All @@ -52,12 +52,12 @@ bool AccelerationSensor::readSensorData()

mpu.getEvent(&a, &g, &temp);

buffer[0] = 1.0;
buffer[1] = 1.0;
buffer[2] = 1.0;
buffer[3] = 1.0;
buffer[4] = 1.0;
buffer[5] = 1.0;
buffer[ix++] = 1.0;
buffer[ix++] = 1.0;
buffer[ix++] = 1.0;
buffer[ix++] = 1.0;
buffer[ix++] = 1.0;
buffer[ix++] = 1.0;

// Serial.println(millis() - prevAccTime);
prevAccTime = millis();
Expand Down Expand Up @@ -97,7 +97,6 @@ bool AccelerationSensor::readSensorData()

if (sendBLE)
{

notifyBLE(probAsphalt, probCompact, probPaving, probSett, probStanding, anomaly);
}

Expand All @@ -116,6 +115,6 @@ bool AccelerationSensor::readSensorData()

void AccelerationSensor::notifyBLE(float probAsphalt, float probCompact, float probPaving, float probSett, float probStanding, float anomaly)
{
BLEModule::writeBLE(surfaceClassificationUUID.c_str(), probAsphalt, probCompact, probPaving, probSett, probStanding);
BLEModule::writeBLE(surfaceClassificationUUID.c_str(), probAsphalt*100, probCompact*100, probPaving*100, probSett*100, probStanding*100);
BLEModule::writeBLE(anomalyUUID.c_str(), anomaly);
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ bool DustSensor::readSensorData()

void DustSensor::notifyBLE(float pm1, float pm2_5, float pm4, float pm10)
{
BLEModule::writeBLE(dustUUID.c_str(), pm1, pm2_5, pm4, pm10);
BLEModule::writeBLE(dustUUID.c_str(), pm1*100, pm2_5*100, pm4*100, pm10*100);
}

0 comments on commit d9dd01c

Please sign in to comment.