summaryrefslogtreecommitdiff
path: root/sensor/thermostat.ino
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-04-20 14:39:21 +0100
committerdakkar <dakkar@thenautilus.net>2018-04-20 14:39:21 +0100
commit430683b5be52c9838409204385cd7c4be501fa98 (patch)
tree2bd4ec2afba2a29b92f45e3e1b23a810eb1d2b06 /sensor/thermostat.ino
parentfake DHT11 reading (diff)
downloadthermostat-430683b5be52c9838409204385cd7c4be501fa98.tar.gz
thermostat-430683b5be52c9838409204385cd7c4be501fa98.tar.bz2
thermostat-430683b5be52c9838409204385cd7c4be501fa98.zip
on BLE connect error, print error and retry in a bit
Diffstat (limited to 'sensor/thermostat.ino')
-rw-r--r--sensor/thermostat.ino10
1 files changed, 9 insertions, 1 deletions
diff --git a/sensor/thermostat.ino b/sensor/thermostat.ino
index e9db767..8c2abb1 100644
--- a/sensor/thermostat.ino
+++ b/sensor/thermostat.ino
@@ -3,6 +3,7 @@
#include "SSD1306.h"
#include "DHTesp.h"
#include "BLEDevice.h"
+#include "GeneralUtils.h"
static BLEUUID thermo_service_uuid("11111111-2222-3333-4444-000000000000");
static BLEUUID thermo_temp_uuid("11111111-2222-3333-4444-000000000001");
@@ -73,7 +74,14 @@ void read_sensor(float* humidity, float* temperature) {
uint32_t send_data_and_get_time(BLEAddress* pAddress,String* data) {
BLEClient* pClient = BLEDevice::createClient();
show("Sc");
- pClient->connect(*pAddress);
+ esp_err_t err;
+ bool ok = pClient->connect(*pAddress,&err);
+ if (!ok) {
+ String status="";
+ status += GeneralUtils::errorToString(err);
+ show(status);
+ return 10;
+ }
String status = "SC";
status += pClient->getPeerAddress().toString().c_str();
show(status);