Correct return always false when using HM10 and return number instead of char array for sensors values
This commit is contained in:
1 parent
4dafcd3779
commit
5bc0d4d532
1 file changed
+9
-17
+9
-17
@@ -265,7 +265,7 @@ vector<BLEdevice> devices;
|
|||||||
#endif
|
#endif
|
||||||
strupp(d[0].extract);
|
strupp(d[0].extract);
|
||||||
if(isBlack(d[0].extract)) return false; //if black listed mac we go out
|
if(isBlack(d[0].extract)) return false; //if black listed mac we go out
|
||||||
if(oneWhite() && !isWhite(d[0].extract)); return false; //if we have at least one white mac and this mac is not white we go out
|
if(oneWhite() && !isWhite(d[0].extract)) return false; //if we have at least one white mac and this mac is not white we go out
|
||||||
String topic = subjectBTtoMQTT + String(d[0].extract);
|
String topic = subjectBTtoMQTT + String(d[0].extract);
|
||||||
int rssi = (int)strtol(d[2].extract, NULL, 16) - 256;
|
int rssi = (int)strtol(d[2].extract, NULL, 16) - 256;
|
||||||
BLEdata.set("rssi", (int)rssi);
|
BLEdata.set("rssi", (int)rssi);
|
||||||
@@ -421,31 +421,25 @@ boolean process_data(int offset, char * rest_data, char * mac_adress){
|
|||||||
// following the value of digit 47 we determine the type of data we get from the sensor
|
// following the value of digit 47 we determine the type of data we get from the sensor
|
||||||
switch (rest_data[47 + offset]) {
|
switch (rest_data[47 + offset]) {
|
||||||
case '9' :
|
case '9' :
|
||||||
dtostrf(value,0,0,val);
|
BLEdata.set("fer", (double)value);
|
||||||
BLEdata.set("fer", val);
|
|
||||||
break;
|
break;
|
||||||
case '4' :
|
case '4' :
|
||||||
if (value > 65000) value = value - 65535;
|
if (value > 65000) value = value - 65535;
|
||||||
dtostrf(value/10,3,1,val); // temp has to be divided by 10
|
BLEdata.set("tem", (double)value/10);
|
||||||
BLEdata.set("tem", val);
|
|
||||||
break;
|
break;
|
||||||
case '6' :
|
case '6' :
|
||||||
if (value > 65000) value = value - 65535;
|
if (value > 65000) value = value - 65535;
|
||||||
dtostrf(value/10,3,1,val); // hum has to be divided by 10
|
BLEdata.set("hum", (double)value/10);
|
||||||
BLEdata.set("hum", val);
|
|
||||||
break;
|
break;
|
||||||
case '7' :
|
case '7' :
|
||||||
dtostrf(value,0,0,val);
|
BLEdata.set("lux", (double)value);
|
||||||
BLEdata.set("lux", val);
|
|
||||||
break;
|
break;
|
||||||
case '8' :
|
case '8' :
|
||||||
dtostrf(value,0,0,val);
|
BLEdata.set("moi", (double)value);
|
||||||
BLEdata.set("moi", val);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a' : // batteryLevel
|
case 'a' : // batteryLevel
|
||||||
dtostrf(value,0,0,val);
|
BLEdata.set("batt", (double)value);
|
||||||
BLEdata.set("batt", val);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd' : // temp+hum
|
case 'd' : // temp+hum
|
||||||
@@ -455,15 +449,13 @@ boolean process_data(int offset, char * rest_data, char * mac_adress){
|
|||||||
tempAr[4] = '\0';
|
tempAr[4] = '\0';
|
||||||
value = strtol(tempAr, NULL, 16);
|
value = strtol(tempAr, NULL, 16);
|
||||||
if (value > 65000) value = value - 65535;
|
if (value > 65000) value = value - 65535;
|
||||||
dtostrf(value/10,3,1,val); // hum has to be divided by 10
|
BLEdata.set("hum", (double)value/10);
|
||||||
BLEdata.set("hum", val);
|
|
||||||
// temperature
|
// temperature
|
||||||
memcpy(tempAr, &data[4], 4);
|
memcpy(tempAr, &data[4], 4);
|
||||||
tempAr[4] = '\0';
|
tempAr[4] = '\0';
|
||||||
value = strtol(tempAr, NULL, 16);
|
value = strtol(tempAr, NULL, 16);
|
||||||
if (value > 65000) value = value - 65535;
|
if (value > 65000) value = value - 65535;
|
||||||
dtostrf(value/10,3,1,val2); // hum has to be divided by 10
|
BLEdata.set("tem", (double)value/10);
|
||||||
BLEdata.set("tem", val2);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
trc("can't read values");
|
trc("can't read values");
|
||||||
|
|||||||
Reference in new issue
Block a user