mirror of
https://github.com/anklimov/lighthub
synced 2025-12-07 20:29:50 +03:00
Merge pull request #12 from livello/patch
lighthub/main.cpp:201:77: error: invalid conversion from 'byte* {aka unsigned char*}' to 'const char*' [-fpermissive]
This commit is contained in:
@@ -178,7 +178,8 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
|||||||
|
|
||||||
Item item(subtopic);
|
Item item(subtopic);
|
||||||
if (item.isValid()) {
|
if (item.isValid()) {
|
||||||
if (item.itemType==CH_GROUP && retaining) return; //Do not restore group channels - they consist not relevant data
|
if (item.itemType == CH_GROUP && retaining)
|
||||||
|
return; //Do not restore group channels - they consist not relevant data
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 0: {
|
case 0: {
|
||||||
short i = 0;
|
short i = 0;
|
||||||
@@ -194,25 +195,25 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
|||||||
case -1: //Not known command
|
case -1: //Not known command
|
||||||
case -2: //JSON input (not implemented yet
|
case -2: //JSON input (not implemented yet
|
||||||
break;
|
break;
|
||||||
case -3: //RGB color in #RRGGBB notation
|
case -3: //RGB color in #RRGGBB notation
|
||||||
{
|
{
|
||||||
CRGB rgb;
|
CRGB rgb;
|
||||||
if (sscanf(payload,"#%2X%2X%2X",&rgb.r,&rgb.g,&rgb.b)==3)
|
if (sscanf((const char*)payload, "#%2X%2X%2X", &rgb.r, &rgb.g, &rgb.b) == 3) {
|
||||||
{ int Par[3];
|
int Par[3];
|
||||||
CHSV hsv=rgb2hsv_approximate(rgb);
|
CHSV hsv = rgb2hsv_approximate(rgb);
|
||||||
Par[0]=map(hsv.h,0,255,0,365);
|
Par[0] = map(hsv.h, 0, 255, 0, 365);
|
||||||
Par[1]=map(hsv.s,0,255,0,100);
|
Par[1] = map(hsv.s, 0, 255, 0, 100);
|
||||||
Par[2]=map(hsv.v,0,255,0,100);
|
Par[2] = map(hsv.v, 0, 255, 0, 100);
|
||||||
item.Ctrl(0, 3, Par, !retaining);
|
item.Ctrl(0, 3, Par, !retaining);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_ON:
|
case CMD_ON:
|
||||||
|
|
||||||
// if (item.getEnableCMD(500) || lanStatus == 4)
|
// if (item.getEnableCMD(500) || lanStatus == 4)
|
||||||
item.Ctrl(cmd, 0, NULL,
|
item.Ctrl(cmd, 0, NULL,
|
||||||
!retaining); //Accept ON command not earlier then 500 ms after set settings (Homekit hack)
|
!retaining); //Accept ON command not earlier then 500 ms after set settings (Homekit hack)
|
||||||
// else Serial.println(F("on Skipped"));
|
// else Serial.println(F("on Skipped"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default: //some known command
|
default: //some known command
|
||||||
@@ -522,6 +523,7 @@ void Changed(int i, DeviceAddress addr, int val) {
|
|||||||
void cmdFunctionHelp(int arg_cnt, char **args)
|
void cmdFunctionHelp(int arg_cnt, char **args)
|
||||||
//(char* tokens)
|
//(char* tokens)
|
||||||
{
|
{
|
||||||
|
printFirmwareVersionAndBuildOptions();
|
||||||
Serial.println(F("Use the commands: 'help' - this text\n"
|
Serial.println(F("Use the commands: 'help' - this text\n"
|
||||||
"'set de:ad:be:ef:fe:00' set and store MAC-address in EEPROM\n"
|
"'set de:ad:be:ef:fe:00' set and store MAC-address in EEPROM\n"
|
||||||
"'save' - save config in NVRAM\n"
|
"'save' - save config in NVRAM\n"
|
||||||
@@ -571,7 +573,7 @@ void applyConfig() {
|
|||||||
if (owArr && !owReady) {
|
if (owArr && !owReady) {
|
||||||
aJsonObject *item = owArr->child;
|
aJsonObject *item = owArr->child;
|
||||||
owReady = owSetup(&Changed);
|
owReady = owSetup(&Changed);
|
||||||
t_count=0;
|
t_count = 0;
|
||||||
while (item) {
|
while (item) {
|
||||||
if ((item->type == aJson_Object)) {
|
if ((item->type == aJson_Object)) {
|
||||||
DeviceAddress addr;
|
DeviceAddress addr;
|
||||||
@@ -906,21 +908,61 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
#endif
|
#endif
|
||||||
Serial.print(F("Config server:"));
|
Serial.print(F("Config server:"));
|
||||||
Serial.println(F(CONFIG_SERVER));
|
Serial.println(F(CONFIG_SERVER));
|
||||||
// Serial.print(F("Firmware MAC Address "));
|
Serial.print(F("Firmware MAC Address "));
|
||||||
// Serial.println(F(QUOTE(CUSTOM_FIRMWARE_MAC))); //Q Macros didn't working with 6 args
|
Serial.println(F(QUOTE(CUSTOM_FIRMWARE_MAC))); //Q Macros didn't working with 6 args
|
||||||
#ifdef DISABLE_FREERAM_PRINT
|
#ifdef DISABLE_FREERAM_PRINT
|
||||||
Serial.println(F("(-)FreeRam printing"));
|
Serial.println(F("(-)FreeRam printing"));
|
||||||
#else
|
#else
|
||||||
Serial.println(F("(+)FreeRam printing"));
|
Serial.println(F("(+)FreeRam printing"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_1W_PIN
|
||||||
|
Serial.print(F("(-)DS2482-100 USE_1W_PIN="));
|
||||||
|
Serial.println(QUOTE(USE_1W_PIN));
|
||||||
|
#else
|
||||||
|
Serial.println(F("(+)DS2482-100"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Wiz5500
|
||||||
|
Serial.println(F("(+)WizNet5500"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DMX_DISABLE
|
||||||
|
Serial.println(F("(-)DMX"));
|
||||||
|
#else
|
||||||
|
Serial.println(F("(+)DMX"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODBUS_DISABLE
|
||||||
|
Serial.println(F("(-)MODBUS"));
|
||||||
|
#else
|
||||||
|
Serial.println(F("(+)MODBUS"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OWIRE_DISABLE
|
||||||
|
Serial.println(F("(-)OWIRE"));
|
||||||
|
#else
|
||||||
|
Serial.println(F("(+)OWIRE"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SD_CARD_INSERTED
|
||||||
|
Serial.println(F("(+)SDCARD"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupMacAddress() {
|
void setupMacAddress() {
|
||||||
byte firmwareMacAddress[6]=CUSTOM_FIRMWARE_MAC;
|
|
||||||
// const char *macStr = QUOTE(CUSTOM_FIRMWARE_MAC);
|
#ifdef DEFAULT_FIRMWARE_MAC
|
||||||
// parseBytes(macStr, ':', firmwareMacAddress, 6, 16);
|
byte firmwareMacAddress[6] = DEFAULT_FIRMWARE_MAC;//comma(,) separated hex-array, hard-coded
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CUSTOM_FIRMWARE_MAC
|
||||||
|
byte firmwareMacAddress[6];
|
||||||
|
const char *macStr = QUOTE(CUSTOM_FIRMWARE_MAC);//colon(:) separated from build options
|
||||||
|
parseBytes(macStr, ':', firmwareMacAddress, 6, 16);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool isMacValid = false;
|
bool isMacValid = false;
|
||||||
for (short i = 0; i < 6; i++) {
|
for (short i = 0; i < 6; i++) {
|
||||||
@@ -965,12 +1007,12 @@ void loop_main() {
|
|||||||
#endif
|
#endif
|
||||||
// if (lastpacket && (lastpacket%10==0)) Serial.println(lastpacket);
|
// if (lastpacket && (lastpacket%10==0)) Serial.println(lastpacket);
|
||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
if (lanStatus!=4) pollingLoop();
|
if (lanStatus != 4) pollingLoop();
|
||||||
#ifdef _owire
|
#ifdef _owire
|
||||||
thermoLoop();
|
thermoLoop();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (inputs) inputLoop();
|
if (inputs) inputLoop();
|
||||||
@@ -1037,9 +1079,9 @@ void pollingLoop(void) {
|
|||||||
if (millis() > nextPollingCheck) {
|
if (millis() > nextPollingCheck) {
|
||||||
while (pollingItem && !done) {
|
while (pollingItem && !done) {
|
||||||
if (pollingItem->type == aJson_Array) {
|
if (pollingItem->type == aJson_Array) {
|
||||||
Item it(pollingItem);
|
Item it(pollingItem);
|
||||||
nextPollingCheck = millis() + it.Poll(); //INTERVAL_CHECK_MODBUS;
|
nextPollingCheck = millis() + it.Poll(); //INTERVAL_CHECK_MODBUS;
|
||||||
done= true;
|
done = true;
|
||||||
}//if
|
}//if
|
||||||
pollingItem = pollingItem->next;
|
pollingItem = pollingItem->next;
|
||||||
if (!pollingItem) {
|
if (!pollingItem) {
|
||||||
@@ -1079,8 +1121,8 @@ void thermoLoop(void) {
|
|||||||
mqttClient.publish("/alarm/snsr", item->name);
|
mqttClient.publish("/alarm/snsr", item->name);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (curtemp>itemTempSetting+THERMO_OVERHEAT_CELSIUS) mqttClient.publish("/alarm/ovrht", item->name);
|
if (curtemp > itemTempSetting + THERMO_OVERHEAT_CELSIUS) mqttClient.publish("/alarm/ovrht", item->name);
|
||||||
|
|
||||||
thermostatCheckPrinted = true;
|
thermostatCheckPrinted = true;
|
||||||
Serial.print(item->name);
|
Serial.print(item->name);
|
||||||
Serial.print(F(" Set:"));
|
Serial.print(F(" Set:"));
|
||||||
@@ -1088,9 +1130,7 @@ void thermoLoop(void) {
|
|||||||
Serial.print(F(" Curtemp:"));
|
Serial.print(F(" Curtemp:"));
|
||||||
Serial.print(curtemp);
|
Serial.print(curtemp);
|
||||||
Serial.print(F(" cmd:"));
|
Serial.print(F(" cmd:"));
|
||||||
Serial.print(itemCommand),
|
Serial.print(itemCommand), pinMode(itemPin, OUTPUT);
|
||||||
|
|
||||||
pinMode(itemPin, OUTPUT);
|
|
||||||
if (itemCommand == CMD_OFF || itemCommand == CMD_HALT ||
|
if (itemCommand == CMD_OFF || itemCommand == CMD_HALT ||
|
||||||
aJson.getArrayItem(itemExtensionArray, IET_ATTEMPTS)->valueint == 0) {
|
aJson.getArrayItem(itemExtensionArray, IET_ATTEMPTS)->valueint == 0) {
|
||||||
digitalWrite(itemPin, LOW);
|
digitalWrite(itemPin, LOW);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CUSTOM_FIRMWARE_MAC
|
#ifndef CUSTOM_FIRMWARE_MAC
|
||||||
#define CUSTOM_FIRMWARE_MAC {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0}
|
#define DEFAULT_FIRMWARE_MAC {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user