Skip to content
Snippets Groups Projects
Commit a12fafce authored by Manon MALIQUE's avatar Manon MALIQUE
Browse files

Displaying of corrections values

parent 65fe153a
No related branches found
No related tags found
No related merge requests found
......@@ -172,7 +172,7 @@ void generic_driver::calibrate(float* pval, float a, float b){
*pval = *pval + b;
log_debug(F("\n[generic_drivers][calibration] Calibration effectuée ! a="));
log_debug(a);
log_debug(F("\n ; b="));
log_debug(F(" ; b="));
log_debug(b);log_flush();
}
\ No newline at end of file
......@@ -121,12 +121,24 @@
// WiFi parameters management
#include "wifiParametersMgt.h"
//Manon
//BLE device
#include <M5StickCPlus.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
/*
* Definitions
*/
//Manon
#define SCAN_TIME 5 // scan period in second
bool BLEScanActivated = false;
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8))
// Debug related definitions
#define SERIAL_BAUDRATE 115200
#ifdef ESP8266
......@@ -777,6 +789,49 @@ void lateSetup( void ) {
log_info(F("\n# --- --- ---")); log_flush();
}
//Manon
// ***** start BLE scan *****
void startScanBLE() {
BLEScan* pBLEScan = BLEDevice::getScan(); // start scanning
pBLEScan->setAdvertisedDeviceCallbacks(new Advertised(), true);
pBLEScan->setActiveScan(true);
pBLEScan->start(SCAN_TIME, scanCompleteCB);
BLEScanActivated = true;
}
// ***** scan Complete Call Back *****
static void scanCompleteCB(BLEScanResults scanResults) { // Callback invoked when scanning has completed
BLEScanActivated = false;
}
// ***** manage BLE scan *****
void manageBLEscan() {
if (!BLEScanActivated)
startScanBLE(); // start scanning
}
// ***** getTemperature *****
float getTemperature(BLEAdvertisedDevice device) {
uint8_t temp_lb = (uint8_t) device.getManufacturerData().c_str()[1]; // temperature lower byte
uint8_t temp_hb = (uint8_t)(device.getManufacturerData().c_str()[2]); // temperature higher byte
int16_t temperature = (int16_t)((uint16_t)(temp_hb)<<8) + (uint16_t)temp_lb;
return ((float)(temperature)/10);
}
// ***** getHumidity *****
uint8_t getHumidity(BLEAdvertisedDevice device) {
const uint8_t *pHum = (const uint8_t *)&device.getManufacturerData().c_str()[3];
return *pHum;
}
void onResult(BLEAdvertisedDevice device) {
log_debug(F("\nReference temperature : "));
log_debug(getTemperature(device));
log_debug(F("\nReference humidity : "));
log_debug(getHumidity(device)); log_flush();
return;
}
// --- SETUP -------------------------------------------------------------------
void setup() {
......@@ -1187,7 +1242,13 @@ if( res!=uint8_t(0x44) ) {
*/
modulesList.startAll( &sensocampus, sharedRoot );
//Manon
//Init BLE
BLEDevice::init("");
manageBLEscan();
log_debug(F("\nSetup of BLE device ..."));log_flush();
delay(1000);
log_debug(F(" done !"));log_flush();
/*
* Very end of setup() :)
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment