Updated formatting
This commit is contained in:
parent
6dc77df498
commit
12147c6df2
|
@ -17,7 +17,7 @@
|
|||
|
||||
BLEScan* pBLEScan;
|
||||
int scanTime = 5; //In seconds
|
||||
int waitTime = 15; //In seconds
|
||||
int waitTime = scanInterval; //In seconds
|
||||
|
||||
uint16_t beconUUID = 0xFEAA;
|
||||
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00)>>8) + (((x)&0xFF)<<8))
|
||||
|
@ -25,6 +25,16 @@ uint16_t beconUUID = 0xFEAA;
|
|||
WiFiClient espClient;
|
||||
PubSubClient client(espClient);
|
||||
|
||||
TaskHandle_t CoreZeroTask;
|
||||
|
||||
void handleWatchdog( void * parameter ) {
|
||||
for (;;) {
|
||||
vTaskDelay(10); // watchdog timer
|
||||
}
|
||||
}
|
||||
|
||||
char *uint64_to_string(uint64_t input);
|
||||
|
||||
String getProximityUUIDString(BLEBeacon beacon) {
|
||||
std::string serviceData = beacon.getProximityUUID().toString().c_str();
|
||||
int serviceDataLength = serviceData.length();
|
||||
|
@ -201,6 +211,11 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
|||
}
|
||||
}
|
||||
|
||||
Serial.println("wdt");
|
||||
vTaskDelay(500); // watchdog timer
|
||||
|
||||
unsigned long started = millis();
|
||||
|
||||
char JSONmessageBuffer[500];
|
||||
JSONencoder.printTo(JSONmessageBuffer, sizeof(JSONmessageBuffer));
|
||||
|
||||
|
@ -208,9 +223,10 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
|||
|
||||
if (client.publish((char *)publishTopic.c_str(), JSONmessageBuffer) == true) {
|
||||
|
||||
vTaskDelay(10); // watchdog timer
|
||||
|
||||
// Serial.print("Success sending message to topic: "); Serial.println(publishTopic);
|
||||
Serial.print("Success sending message to topic: "); Serial.println(publishTopic);
|
||||
unsigned long duration = millis() - started;
|
||||
Serial.print("duration ");
|
||||
Serial.println(duration);
|
||||
// Serial.print("Message: "); Serial.println(JSONmessageBuffer);
|
||||
|
||||
} else {
|
||||
|
@ -220,9 +236,21 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
|||
}
|
||||
};
|
||||
|
||||
void createTaskOnCoreZero() {
|
||||
xTaskCreatePinnedToCore(
|
||||
handleWatchdog, /* Task function. */
|
||||
"CoreZeroTask", /* name of task. */
|
||||
1000, /* Stack size of task */
|
||||
NULL, /* parameter of the task */
|
||||
1, /* priority of the task */
|
||||
&Task1, /* Task handle to keep track of created task */
|
||||
0); /* Core */
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
createTaskOnCoreZero();
|
||||
WiFi.begin(ssid, password);
|
||||
WiFi.setHostname(hostname);
|
||||
|
||||
|
@ -268,10 +296,11 @@ void loop() {
|
|||
last = millis();
|
||||
}
|
||||
|
||||
vTaskDelay(10); // watchdog timer
|
||||
|
||||
}
|
||||
|
||||
char *uint64_to_string(uint64_t input)
|
||||
{
|
||||
char *uint64_to_string(uint64_t input) {
|
||||
static char result[21] = "";
|
||||
// Clear result from any leftover digits from previous function call.
|
||||
memset(&result[0], 0, sizeof(result));
|
||||
|
@ -280,8 +309,7 @@ char *uint64_to_string(uint64_t input)
|
|||
char c;
|
||||
uint8_t base = 10;
|
||||
|
||||
while (input)
|
||||
{
|
||||
while (input) {
|
||||
int num = input % base;
|
||||
input /= base;
|
||||
c = '0' + num;
|
||||
|
|
12
README.md
12
README.md
|
@ -6,13 +6,17 @@ This depends heavily on the hard work done by [pcbreflux](https://github.com/pcb
|
|||
## Getting Started
|
||||
1. You can get started by cloning this repository to your local machine using git. Alternatively, you can [download the zip](https://github.com/jptrsn/ESP32-mqtt-room/archive/master.zip).
|
||||
2. Make a copy of the `Settings.h` file, and rename it `Settings_local.h`. Fill in the required information in your local settings file (the local file is ignored by GitHub, so you won't upload your sensitive information).
|
||||
3. Set the board variant to ESP32 in the Arduino IDE.
|
||||
|
||||
### Configuration
|
||||
3. Settings are defined in `Settings_local.h` which is not included in the repo by default. Make a copy of `Settings.h` and rename it `Settings_local.h` in the same folder. Fill in your required settings.
|
||||
|
||||
## Configuration
|
||||
Settings are defined in `Settings_local.h` which is not included in the repo by default. You can make a copy of `Settings.h` and rename it `Settings_local.h` in the same folder.
|
||||
### Build and Upload
|
||||
4. Open the `ESP32-mqtt-room.ino` file in the Arduino IDE, and set the board variant to ESP32. You'll need to use the large partition scheme to get it to fit your board.
|
||||
5. Compile and upload. Ensure that you've got all required libraries installed (and do not use the beta version of any of them).
|
||||
|
||||
#### Development Tasks
|
||||
_**TBC**_
|
||||
|
||||
#### Future Development Tasks
|
||||
- [x] Implement basic BLE packet discovery
|
||||
- [x] Implement iBeacon data packet parsing
|
||||
- [ ] Setup instructions in README.md
|
||||
|
|
|
@ -24,3 +24,6 @@
|
|||
|
||||
//Define the base topic for room detection. Usually "room_presence"
|
||||
#define channel "room_presence"
|
||||
|
||||
//Define the interval in seconds between scans
|
||||
#define scanInterval 15
|
||||
|
|
Loading…
Reference in New Issue