mirror of https://github.com/arendst/Tasmota.git
Fix I2CScan invalid JSON
Fix I2CScan invalid JSON error message (#3925)
This commit is contained in:
parent
3d6b9859bd
commit
2252be521a
|
@ -1,6 +1,7 @@
|
|||
/* 6.2.1.9 20180928
|
||||
* Add Apparent Power and Reactive Power to Energy Monitoring devices (#251)
|
||||
* Add RF Receiver control to module MagicHome to be used on Arilux LC10 (#3792)
|
||||
* Fix I2CScan invalid JSON error message (#3925)
|
||||
*
|
||||
* 6.2.1.8 20180926
|
||||
* Change status JSON message providing more switch and retain information
|
||||
|
|
|
@ -855,35 +855,19 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
0, 0, 0, 0, 0
|
||||
},
|
||||
/*
|
||||
{ "MagicHome", // Magic Home (aka Flux-light) (ESP8266)
|
||||
// https://www.aliexpress.com/item/Magic-Home-Mini-RGB-RGBW-Wifi-Controller-For-Led-Strip-Panel-light-Timing-Function-16million-colors/32686853650.html
|
||||
0,
|
||||
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
|
||||
GPIO_LED1_INV, // GPIO02 Blue onboard LED
|
||||
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
|
||||
GPIO_USER, // GPIO04 IR receiver (optional)
|
||||
GPIO_PWM2, // GPIO05 RGB LED Green
|
||||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_PWM3, // GPIO12 RGB LED Blue
|
||||
GPIO_USER, // GPIO13 RGBW LED White (optional - set to PWM4 for Cold White or Warm White)
|
||||
GPIO_PWM1, // GPIO14 RGB LED Red
|
||||
0, 0, 0
|
||||
},
|
||||
*/
|
||||
{ "MagicHome", // Magic Home (aka Flux-light) (ESP8266) and Arilux LC10 (ESP8285)
|
||||
// https://www.aliexpress.com/item/Magic-Home-Mini-RGB-RGBW-Wifi-Controller-For-Led-Strip-Panel-light-Timing-Function-16million-colors/32686853650.html
|
||||
0,
|
||||
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
|
||||
GPIO_LED1_INV, // GPIO02 Blue onboard LED
|
||||
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
|
||||
GPIO_ARIRFRCV, // GPIO04 IR or RF receiver (optional)
|
||||
GPIO_ARIRFRCV, // GPIO04 IR or RF receiver (optional) (Arilux LC10)
|
||||
GPIO_PWM2, // GPIO05 RGB LED Green
|
||||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_PWM3, // GPIO12 RGB LED Blue
|
||||
GPIO_USER, // GPIO13 RGBW LED White (optional - set to PWM4 for Cold White or Warm White as used on Arilux LC10)
|
||||
GPIO_PWM1, // GPIO14 RGB LED Red
|
||||
GPIO_LED2_INV, // GPIO15 RF receiver control
|
||||
GPIO_LED2_INV, // GPIO15 RF receiver control (Arilux LC10)
|
||||
0, 0
|
||||
},
|
||||
{ "Luani HVIO", // ESP8266_HVIO
|
||||
|
@ -1089,6 +1073,20 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
/*
|
||||
Optionals
|
||||
|
||||
{ "MagicHome", // Magic Home (aka Flux-light) (ESP8266)
|
||||
// https://www.aliexpress.com/item/Magic-Home-Mini-RGB-RGBW-Wifi-Controller-For-Led-Strip-Panel-light-Timing-Function-16million-colors/32686853650.html
|
||||
0,
|
||||
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
|
||||
GPIO_LED1_INV, // GPIO02 Blue onboard LED
|
||||
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
|
||||
GPIO_USER, // GPIO04 IR receiver (optional)
|
||||
GPIO_PWM2, // GPIO05 RGB LED Green
|
||||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_PWM3, // GPIO12 RGB LED Blue
|
||||
GPIO_USER, // GPIO13 RGBW LED White (optional - set to PWM4 for Cold White or Warm White)
|
||||
GPIO_PWM1, // GPIO14 RGB LED Red
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Arilux LC10", // Arilux LC10 (ESP8285), RGBW + RF
|
||||
// https://github.com/arendst/Sonoff-Tasmota/wiki/MagicHome-with-ESP8285
|
||||
// https://www.aliexpress.com/item/DC5-24V-Wireless-WIFI-LED-RGB-Controller-RGBW-Controller-IR-RF-Remote-Control-IOS-Android-for/32827253255.html
|
||||
|
|
|
@ -1775,27 +1775,35 @@ int8_t I2cWriteBuffer(uint8_t addr, uint8_t reg, uint8_t *reg_data, uint16_t len
|
|||
|
||||
void I2cScan(char *devs, unsigned int devs_len)
|
||||
{
|
||||
byte error;
|
||||
byte address;
|
||||
// Return error codes defined in twi.h and core_esp8266_si2c.c
|
||||
// I2C_OK 0
|
||||
// I2C_SCL_HELD_LOW 1 = SCL held low by another device, no procedure available to recover
|
||||
// I2C_SCL_HELD_LOW_AFTER_READ 2 = I2C bus error. SCL held low beyond slave clock stretch time
|
||||
// I2C_SDA_HELD_LOW 3 = I2C bus error. SDA line held low by slave/another_master after n bits
|
||||
// I2C_SDA_HELD_LOW_AFTER_INIT 4 = line busy. SDA again held low by another device. 2nd master?
|
||||
|
||||
byte error = 0;
|
||||
byte address = 0;
|
||||
byte any = 0;
|
||||
char tstr[10];
|
||||
|
||||
snprintf_P(devs, devs_len, PSTR("{\"" D_CMND_I2CSCAN "\":\"" D_JSON_I2CSCAN_DEVICES_FOUND_AT));
|
||||
for (address = 1; address <= 127; address++) {
|
||||
Wire.beginTransmission(address);
|
||||
error = Wire.endTransmission();
|
||||
if (0 == error) {
|
||||
snprintf_P(tstr, sizeof(tstr), PSTR(" 0x%2x"), address);
|
||||
strncat(devs, tstr, devs_len);
|
||||
any = 1;
|
||||
snprintf_P(devs, devs_len, PSTR("%s 0x%02x"), devs, address);
|
||||
}
|
||||
else if (4 == error) {
|
||||
snprintf_P(devs, devs_len, PSTR("{\"" D_CMND_I2CSCAN "\":\"" D_JSON_I2CSCAN_UNKNOWN_ERROR_AT " 0x%2x\"}"), address);
|
||||
else if (error != 2) { // Seems to happen anyway using this scan
|
||||
any = 2;
|
||||
snprintf_P(devs, devs_len, PSTR("{\"" D_CMND_I2CSCAN "\":\"Error %d at 0x%02x"), error, address);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (any) {
|
||||
strncat(devs, "\"}", devs_len);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
snprintf_P(devs, devs_len, PSTR("{\"" D_CMND_I2CSCAN "\":\"" D_JSON_I2CSCAN_NO_DEVICES_FOUND "\"}"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue