1 parent
f0546fab8c
commit
f515f9c03a
4 files changed
+32
-2
No files matched your search
+1
-1
@@ -587,7 +587,7 @@ void loop()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef ZgatewayBT
|
#ifdef ZgatewayBT
|
||||||
#ifndef ESP32
|
#ifndef multiCore
|
||||||
if(BTtoMQTT())
|
if(BTtoMQTT())
|
||||||
trc(F("BTtoMQTT OK"));
|
trc(F("BTtoMQTT OK"));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -175,6 +175,9 @@ const byte subnet[] = { 255, 255, 255, 0 }; //ip adress
|
|||||||
//variables to avoid duplicates
|
//variables to avoid duplicates
|
||||||
#define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates
|
#define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates
|
||||||
|
|
||||||
|
//uncomment to use multicore function of ESP32 for BLE
|
||||||
|
//#define multiCore
|
||||||
|
|
||||||
#define TimeBetweenReadingSYS 30000 // time between system readings (like memory)
|
#define TimeBetweenReadingSYS 30000 // time between system readings (like memory)
|
||||||
/*-------------------ACTIVATE TRACES----------------------*/
|
/*-------------------ACTIVATE TRACES----------------------*/
|
||||||
#define TRACE 1 // 0= trace off 1 = trace on
|
#define TRACE 1 // 0= trace off 1 = trace on
|
||||||
|
|||||||
+25
-1
@@ -40,6 +40,9 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
|
|||||||
#include <BLEScan.h>
|
#include <BLEScan.h>
|
||||||
#include <BLEAdvertisedDevice.h>
|
#include <BLEAdvertisedDevice.h>
|
||||||
|
|
||||||
|
//Time used to wait for an interval before resending BLE infos
|
||||||
|
unsigned long timeBLE= 0;
|
||||||
|
|
||||||
//core on which the BLE detection task will run
|
//core on which the BLE detection task will run
|
||||||
static int taskCore = 0;
|
static int taskCore = 0;
|
||||||
|
|
||||||
@@ -108,6 +111,7 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
|
|||||||
};
|
};
|
||||||
|
|
||||||
void setupBT(){
|
void setupBT(){
|
||||||
|
#ifdef multiCore
|
||||||
// we setup a task with priority one to avoid conflict with other gateways
|
// we setup a task with priority one to avoid conflict with other gateways
|
||||||
xTaskCreatePinnedToCore(
|
xTaskCreatePinnedToCore(
|
||||||
coreTask, /* Function to implement the task */
|
coreTask, /* Function to implement the task */
|
||||||
@@ -117,9 +121,13 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
|
|||||||
1, /* Priority of the task */
|
1, /* Priority of the task */
|
||||||
NULL, /* Task handle. */
|
NULL, /* Task handle. */
|
||||||
taskCore); /* Core where the task should run */
|
taskCore); /* Core where the task should run */
|
||||||
trc(F("ZgatewayBT ESP32 setup done "));
|
trc(F("ZgatewayBT multicore ESP32 setup done "));
|
||||||
|
#elif
|
||||||
|
trc(F("ZgatewayBT singlecore ESP32 setup done "));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef multiCore
|
||||||
void coreTask( void * pvParameters ){
|
void coreTask( void * pvParameters ){
|
||||||
|
|
||||||
String taskMessage = "BT Task running on core ";
|
String taskMessage = "BT Task running on core ";
|
||||||
@@ -136,6 +144,22 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
|
|||||||
BLEScanResults foundDevices = pBLEScan->start(Scan_duration);
|
BLEScanResults foundDevices = pBLEScan->start(Scan_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif
|
||||||
|
boolean BTtoMQTT(){
|
||||||
|
unsigned long now = millis();
|
||||||
|
if (now > (timeBLE + TimeBtw_Read)) {//retriving value of temperature and humidity of the box from DHT every xUL
|
||||||
|
timeBLE = now;
|
||||||
|
BLEDevice::init("");
|
||||||
|
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
|
||||||
|
MyAdvertisedDeviceCallbacks myCallbacks;
|
||||||
|
pBLEScan->setAdvertisedDeviceCallbacks(&myCallbacks);
|
||||||
|
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
|
||||||
|
BLEScanResults foundDevices = pBLEScan->start(Scan_duration);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#else // arduino or ESP8266 working with HM10/11
|
#else // arduino or ESP8266 working with HM10/11
|
||||||
|
|
||||||
|
|||||||
@@ -168,6 +168,9 @@ const byte subnet[] = { 255, 255, 255, 0 }; //ip adress
|
|||||||
//variables to avoid duplicates
|
//variables to avoid duplicates
|
||||||
#define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates
|
#define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates
|
||||||
|
|
||||||
|
//uncomment to use multicore function of ESP32 for BLE
|
||||||
|
#define multiCore
|
||||||
|
|
||||||
#define TimeBetweenReadingSYS 30000 // time between system readings (like memory)
|
#define TimeBetweenReadingSYS 30000 // time between system readings (like memory)
|
||||||
/*-------------------ACTIVATE TRACES----------------------*/
|
/*-------------------ACTIVATE TRACES----------------------*/
|
||||||
#define TRACE 1 // 0= trace off 1 = trace on
|
#define TRACE 1 // 0= trace off 1 = trace on
|
||||||
Reference in new issue
Block a user