Przy oryginalnych ustawieniach soft ten działa poprawnie, ale nie podobało mi się w supla-cloud ustawienie kanałów w taki sposób:
0-przekaźniki roller-shuter,
1-input sensor,
2-temperatura,
Tak jest w oryginale
Kod: Zaznacz cały
void supla_esp_board_gpio_init(void) {
supla_input_cfg[0].type = INPUT_TYPE_BUTTON;
supla_input_cfg[0].gpio_id = B_CFG_PORT;
supla_input_cfg[0].flags = INPUT_FLAG_PULLUP | INPUT_FLAG_CFG_BTN;
supla_input_cfg[1].type = INPUT_TYPE_SENSOR;
supla_input_cfg[1].gpio_id = B_SENSOR_PORT1;
supla_input_cfg[1].channel = 1;
supla_input_cfg[2].type = INPUT_TYPE_BUTTON_HILO;
supla_input_cfg[2].gpio_id = B_BTN1_PORT;
supla_input_cfg[2].relay_gpio_id = B_RELAY1_PORT;
supla_input_cfg[3].type = INPUT_TYPE_BUTTON_HILO;
supla_input_cfg[3].gpio_id = B_BTN2_PORT;
supla_input_cfg[3].relay_gpio_id = B_RELAY2_PORT;
// ---------------------------------------
// ---------------------------------------
supla_relay_cfg[0].gpio_id = B_RELAY1_PORT;
supla_relay_cfg[0].flags = RELAY_FLAG_RESET | RELAY_FLAG_TURNOFF_BINDED;
supla_relay_cfg[0].channel = 0;
supla_relay_cfg[0].bind = 1;
supla_relay_cfg[1].gpio_id = B_RELAY2_PORT;
supla_relay_cfg[1].flags = RELAY_FLAG_RESET | RELAY_FLAG_TURNOFF_BINDED;
supla_relay_cfg[1].bind = 0;
}
void supla_esp_board_set_channels(TDS_SuplaRegisterDevice_B *srd) {
srd->channel_count = 3;
srd->channels[0].Number = 0;
srd->channels[0].Type = SUPLA_CHANNELTYPE_RELAY;
srd->channels[0].FuncList = SUPLA_BIT_RELAYFUNC_CONTROLLINGTHEROLLERSHUTTER;
srd->channels[0].Default = SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER;
srd->channels[0].value[0] = supla_esp_gpio_relay_on(B_RELAY1_PORT) ? 1 : ( supla_esp_gpio_relay_on(B_RELAY2_PORT) ? 2 : 0 ) ;
srd->channels[1].Number = 1;
srd->channels[1].Type = SUPLA_CHANNELTYPE_SENSORNO;
srd->channels[2].Number = 2;
srd->channels[2].Type = SUPLA_CHANNELTYPE_THERMOMETERDS18B20;
srd->channels[2].FuncList = 0;
srd->channels[2].Default = 0;
supla_get_temperature(srd->channels[2].value);
}
void supla_esp_board_send_channel_values_with_delay(void *srpc) {
supla_esp_channel_value_changed(1, gpio__input_get(B_SENSOR_PORT1));
}
0-przekaźniki,
1-temperatura,
2-input sensor
Moje zmiany
Kod: Zaznacz cały
void supla_esp_board_gpio_init(void) {
supla_input_cfg[0].type = INPUT_TYPE_BUTTON;
supla_input_cfg[0].gpio_id = B_CFG_PORT;
supla_input_cfg[0].flags = INPUT_FLAG_PULLUP | INPUT_FLAG_CFG_BTN;
supla_input_cfg[1].type = INPUT_TYPE_SENSOR;
supla_input_cfg[1].gpio_id = B_SENSOR_PORT1;
supla_input_cfg[1].channel = 2; //tu zaszła zmiana
supla_input_cfg[2].type = INPUT_TYPE_BUTTON_HILO;
supla_input_cfg[2].gpio_id = B_BTN1_PORT;
supla_input_cfg[2].relay_gpio_id = B_RELAY1_PORT;
supla_input_cfg[3].type = INPUT_TYPE_BUTTON_HILO;
supla_input_cfg[3].gpio_id = B_BTN2_PORT;
supla_input_cfg[3].relay_gpio_id = B_RELAY2_PORT;
// ---------------------------------------
// ---------------------------------------
supla_relay_cfg[0].gpio_id = B_RELAY1_PORT;
supla_relay_cfg[0].flags = RELAY_FLAG_RESET | RELAY_FLAG_TURNOFF_BINDED;
supla_relay_cfg[0].channel = 0;
supla_relay_cfg[0].bind = 1;
supla_relay_cfg[1].gpio_id = B_RELAY2_PORT;
supla_relay_cfg[1].flags = RELAY_FLAG_RESET | RELAY_FLAG_TURNOFF_BINDED;
supla_relay_cfg[1].bind = 0;
}
void supla_esp_board_set_channels(TDS_SuplaRegisterDevice_B *srd) {
srd->channel_count = 3;
srd->channels[0].Number = 0;
srd->channels[0].Type = SUPLA_CHANNELTYPE_RELAY;
srd->channels[0].FuncList = SUPLA_BIT_RELAYFUNC_CONTROLLINGTHEROLLERSHUTTER;
srd->channels[0].Default = SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER;
srd->channels[0].value[0] = supla_esp_gpio_relay_on(B_RELAY1_PORT) ? 1 : ( supla_esp_gpio_relay_on(B_RELAY2_PORT) ? 2 : 0 ) ;
//tu zaszły zmiany poniżej \/
srd->channels[1].Number = 1;
srd->channels[1].Type = SUPLA_CHANNELTYPE_THERMOMETERDS18B20;
srd->channels[1].FuncList = 0;
srd->channels[1].Default = 0;
srd->channels[2].Number = 2;
srd->channels[2].Type = SUPLA_CHANNELTYPE_SENSORNO;
//tu zaszła zmiana /\
supla_get_temperature(srd->channels[1].value); //tu zaszła zmiana
}
void supla_esp_board_send_channel_values_with_delay(void *srpc) {
supla_esp_channel_value_changed(1, gpio__input_get(B_SENSOR_PORT1));
}