Fix to watchdog timeout
This commit is contained in:
parent
1057cfb19a
commit
6dc77df498
|
@ -152,7 +152,7 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
|||
float distance = calculateDistance(rssi, oBeacon.getSignalPower());
|
||||
Serial.print("RSSI: ");
|
||||
Serial.print(rssi);
|
||||
Serial.print("\txPower: ");
|
||||
Serial.print("\ttxPower: ");
|
||||
Serial.print(oBeacon.getSignalPower());
|
||||
Serial.print("\tDistance: ");
|
||||
Serial.println(distance);
|
||||
|
@ -207,8 +207,12 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
|||
String publishTopic = String(channel) + "/" + room;
|
||||
|
||||
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("Message: "); Serial.println(JSONmessageBuffer);
|
||||
|
||||
} else {
|
||||
Serial.print("Error sending message: "); Serial.println(publishTopic);
|
||||
Serial.print("Message: "); Serial.println(JSONmessageBuffer);
|
||||
|
@ -218,15 +222,19 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
|||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
WiFi.setHostname(hostname);
|
||||
|
||||
Serial.print("Connecting to WiFi..");
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.println("Connecting to WiFi..");
|
||||
Serial.print(".");
|
||||
}
|
||||
|
||||
Serial.println("Connected to the WiFi network");
|
||||
Serial.println();
|
||||
Serial.print("Connected to the WiFi network as ");
|
||||
Serial.println(hostname);
|
||||
|
||||
client.setServer(mqttServer, mqttPort);
|
||||
reconnect();
|
||||
|
@ -238,6 +246,7 @@ void setup() {
|
|||
Serial.println("Error sending message");
|
||||
}
|
||||
|
||||
|
||||
BLEDevice::init("");
|
||||
pBLEScan = BLEDevice::getScan(); //create new scan
|
||||
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
|
||||
|
@ -251,14 +260,14 @@ void loop() {
|
|||
reconnect();
|
||||
}
|
||||
client.loop();
|
||||
|
||||
|
||||
if (millis() - last > (waitTime * 1000)) {
|
||||
Serial.println("Scanning...");
|
||||
BLEScanResults foundDevices = pBLEScan->start(scanTime);
|
||||
Serial.printf("\nScan done! Devices found: %d\n",foundDevices.getCount());
|
||||
last = millis();
|
||||
}
|
||||
delay(5);
|
||||
|
||||
}
|
||||
|
||||
char *uint64_to_string(uint64_t input)
|
||||
|
|
23
README.md
23
README.md
|
@ -1,9 +1,28 @@
|
|||
# ESP32-mqtt-room
|
||||
An ESP32 based presence detection node for use with the Home Assistant mqtt_room component for localized device presence detection.
|
||||
|
||||
This depends heavily on the hard work done by [pcbreflux](https://github.com/pcbreflux) and [nkolban](https://github.com/nkolban) both on GitHub and on their YouTube Channels.
|
||||
This depends heavily on the hard work done by [pcbreflux](https://github.com/pcbreflux) and [nkolban](https://github.com/nkolban) both on GitHub and on their YouTube Channels. Specifically, it is a modified version of pcbreflux's [ESP32_BLE_beaconscan](https://github.com/pcbreflux/espressif/tree/master/esp32/arduino/sketchbook/ESP32_BLE_beaconscan).
|
||||
|
||||
## 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.
|
||||
|
||||
Specifically, it is a modified version of pcbreflux's [ESP32_BLE_beaconscan](https://github.com/pcbreflux/espressif/tree/master/esp32/arduino/sketchbook/ESP32_BLE_beaconscan)
|
||||
|
||||
## 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.
|
||||
|
||||
#### Development Tasks
|
||||
- [x] Implement basic BLE packet discovery
|
||||
- [x] Implement iBeacon data packet parsing
|
||||
- [ ] Setup instructions in README.md
|
||||
- [ ] Match configuration options to Room Assistant
|
||||
- [ ] Implement Mi Flora data parsing and reporting
|
||||
- [ ] Whitelist functionality
|
||||
- [ ] Blacklist functionality
|
||||
- [ ] Maximum distance limit
|
||||
- [ ] Scan interval Settings
|
||||
- [ ] Configuration via Web UI
|
||||
- [ ] Wifi Manager for managing access point credentials
|
||||
- [ ] Implement Over-The-Air (OTA) updates
|
||||
- [ ] Build and upload via [PlatformIO](platformio.org)
|
||||
|
|
Loading…
Reference in New Issue