Mam zagwozdkę, w kodzie mam:
Code: Select all
const char PARAM1[] = "MQTT server";
const char PARAM2[] = "MQTT user";
const char PARAM3[] = "MQTT password";
const char PARAM4[] = "device ID";
const char PARAM5[] = "channel ID";
const char PARAM6[] = "night_h_start";
const char PARAM7[] = "night_h_end";
const char PARAM8[] = "message";
potem:
Code: Select all
char mqtt_server[50] ={};
char mqtt_user[50] ={};
char mqtt_pass[50] ={};
int dv_id;
int chann_id;
int night_h_start;
int night_h_stop;
char message[25]={};
potem w SETUP:
Code: Select all
SuplaDevice.addClock(new Supla::Clock);
auto clock1 = SuplaDevice.getClock();
new Supla::Html::CustomTextParameter(PARAM1, "MQTT server", 50);
new Supla::Html::CustomTextParameter(PARAM2, "MQTT user", 50);
new Supla::Html::CustomTextParameter(PARAM3, "MQTT password", 50);
new Supla::Html::CustomParameter(PARAM4, "device ID");
new Supla::Html::CustomParameter(PARAM5, "channel ID");
new Supla::Html::CustomParameter(PARAM6, "night_h_start");
new Supla::Html::CustomParameter(PARAM7, "night_h_end");
new Supla::Html::CustomTextParameter(PARAM8, "push message", 25);
Supla::Notification::RegisterNotification(-1);
SuplaDevice.setSuplaCACert(suplaCACert);
SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert);
paramSave();
SuplaDevice.begin();
funkcja paramSave:
Code: Select all
void paramSave(){
if (Supla::Storage::ConfigInstance()->getString(PARAM1, mqtt_server, 50)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %s", PARAM1, mqtt_server);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM1);
}
if (Supla::Storage::ConfigInstance()->getString(PARAM2, mqtt_user, 50)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %d", PARAM2, mqtt_user);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM2);
}
if (Supla::Storage::ConfigInstance()->getString(PARAM3, mqtt_pass, 50)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %d", PARAM3, mqtt_pass);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM3);
}
if (Supla::Storage::ConfigInstance()->getInt32(PARAM4, &dv_id)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %d", PARAM4, dv_id);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM4);
}
if (Supla::Storage::ConfigInstance()->getInt32(PARAM5, &chann_id)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %d", PARAM5, chann_id);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM5);
}
if (Supla::Storage::ConfigInstance()->getInt32(PARAM6, &night_h_start)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %d", PARAM6, night_h_start);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM6);
}
if (Supla::Storage::ConfigInstance()->getInt32(PARAM7, &night_h_stop)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %d", PARAM7, night_h_stop);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM7);
}
if (Supla::Storage::ConfigInstance()->getString(PARAM8, message, 200)) {
SUPLA_LOG_DEBUG(" **** Param[%s]: %d", PARAM8, message);
} else {
SUPLA_LOG_DEBUG(" **** Param[%s] is not set", PARAM8);
}
}
dla mqtt_user i mqtt_pass wpisuję(w web interface) ciąg znaków alfanumerycznych, tych podanych przy uruchamianiu mqtt supli. Zresztą podobnie jak w mqtt_server. Jednak mqtt_server zapisuje się prawidłowo, a dla mqtt_user, mqtt_pass i message zapisuje się ciąg numeryczny(wpisałem poniżej przykładowy/losowy ciąg znaków). Dal device id i channel id zapisuje dobrze. Jest jakiś problem z okienkami tekstowymi, PARAM2,3 i 8, a PARAM1 jest ok.
Proszę logi:
Code: Select all
14:04:57.673 -> Using Supla protocol version 23
14:04:57.720 -> Current status: [5] SuplaDevice initialized
14:04:57.767 -> Enter normal mode
14:04:57.767 -> *** Supla - Initialization done
14:04:57.815 -> **** Param[MQTT server]: mqttxx.supla.org
14:04:57.862 -> **** Param[MQTT user]: 3752840273
14:04:57.909 -> **** Param[MQTT password]: 9387362549
14:04:57.955 -> **** Param[device ID]: 1111
14:04:58.002 -> **** Param[channel ID]: 1111
14:04:58.002 -> **** Param[night_h_start]: 1
14:04:58.050 -> **** Param[night_h_end]: 7
14:04:58.094 -> **** Param[message]: 5859493303
Również kiedy w loop uruchomię jeden raz na początku wypisanie zawartości zmiennych:
Code: Select all
void loop() {
if(!wf){
Serial.print("dv:.............");
Serial.println(dv_id);
Serial.print("channel:.............");
Serial.println(chann_id);
Serial.print("serwer:.............");
Serial.println(mqtt_server);
Serial.print("user:.............");
Serial.println(mqtt_user);
Serial.print("password:.............");
Serial.println(mqtt_pass);
wf=1;
}
to otrzymuję:
Code: Select all
14:04:58.142 -> dv:.............0
14:04:58.142 -> channel:.............0
14:04:58.142 -> serwer:.............
14:04:58.189 -> user:.............
14:04:58.189 -> password:.............
Why?