Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS 프로비저닝 기능 구현 #2

Merged
merged 22 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
35c60ba
Feat: Cognito login 기능 구현
GwangrokBaek Aug 19, 2021
31437f3
Feat: Cognito code api 구현
GwangrokBaek Aug 19, 2021
90c53d6
Feat: HTTPS 웹서버 구현
GwangrokBaek Aug 19, 2021
d161166
Feat: HTTPS 웹서버 구현 및 필요없는 웹서버 기능 제거
GwangrokBaek Aug 20, 2021
c0bf284
refactor: 필요없는 기능 제거 및 버퍼 사이즈 축소
GwangrokBaek Aug 22, 2021
d2cffc4
merge: Cognito 기능 브랜치에 HTTPS 기능 브랜치 병합
GwangrokBaek Aug 22, 2021
8a1714d
chore: HTTP 서버 및 HTTPS 서버 begin 함수 분리
GwangrokBaek Aug 22, 2021
3e312c2
Feat: HTTPS 웹서버 중지 기능 구현
GwangrokBaek Aug 22, 2021
9b4eb75
Feat: Cognito AUTHORIZATION 엔드포인트 response 파싱 기능 및 파싱 이후 메인 페이지 이동 구현
GwangrokBaek Aug 22, 2021
00cc306
Feat: 로그인 상태에 따른 WebUI 로그인/로그아웃 버튼 문구 변화
GwangrokBaek Aug 22, 2021
7116deb
Fix: WebUI 색상 버그 수정
GwangrokBaek Aug 23, 2021
4127e17
Fix: 설정 초기화 및 공장 초기화 동작 안되는 문제 수정
GwangrokBaek Aug 24, 2021
c985faf
refactor: HTTPS 웹서버 및 HTTP 서버 코드 분리
GwangrokBaek Aug 24, 2021
b94cc63
chore: 기능 테스트용 주석 해제
GwangrokBaek Aug 24, 2021
8dca93d
Feat: WiFi 설정 API 구현
GwangrokBaek Aug 24, 2021
d559e1b
Merge pull request #1 from GwangrokBaek/feature-https
GwangrokBaek Aug 26, 2021
b5a9aff
feat: ap 모드 로직 구현
GwangrokBaek Jan 17, 2022
9490221
feat: Station 모드 및 프로비저닝 모드 로직 구현
GwangrokBaek Jan 17, 2022
135fdff
feat: STATION 모드 MQTT 명령 추가
GwangrokBaek Jan 21, 2022
f61c4e0
feat: 파일 시스템 enable
GwangrokBaek Jan 21, 2022
bb84c72
idToken 저장 기능 및 메모리 사용량 축소
GwangrokBaek Jan 21, 2022
283aa8f
Merge branch 'feature-https' of https://github.com/zigbang/Tasmota in…
GwangrokBaek Jan 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions platformio_override.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ build_flags = ${core.build_flags}
; Build variant 2MB = 1MB firmware, 1MB filesystem (most Shelly devices)
;board = esp8266_2M1M
; Build variant 4MB = 1MB firmware, 1MB OTA, 2MB filesystem (WEMOS D1 Mini, NodeMCU, Sonoff POW)
;board = esp8266_4M2M
board = esp8266_4M2M

; set CPU frequency to 80MHz (default) or 160MHz
;board_build.f_cpu = 160000000L
Expand All @@ -71,7 +71,7 @@ build_flags = ${core.build_flags}
;board_build.f_flash = 80000000L

; *** Upload Serial reset method for Wemos and NodeMCU
upload_port = /dev/tty.usbserial-1420
upload_port = /dev/tty.usbserial-14110

extra_scripts = ${scripts_defaults.extra_scripts}
; pio-tools/obj-dump.py
Expand Down
4 changes: 4 additions & 0 deletions tasmota/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@
#define D_CMND_HUMOFFSET "HumOffset"
#define D_CMND_GLOBAL_TEMP "GlobalTemp"
#define D_CMND_GLOBAL_HUM "GlobalHum"
#define D_CMND_FACTORY_RESET "FactoryReset"
#define D_CMND_SSID_RESET "SSIDReset"
#define D_CMND_UPDATE_CERT "UpdateCert"
#define D_CMND_READ_INPUT "ReadInput"

#ifdef ESP32
#define D_CMND_TOUCH_CAL "TouchCal"
Expand Down
4 changes: 3 additions & 1 deletion tasmota/language/ko_KO.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
#define D_SELECT_YOUR_WIFI_NETWORK "아래에서 WiFi를 선택하세요"
#define D_SHOW_MORE_WIFI_NETWORKS "다른 WiFi 탐색"
#define D_SHOW_MORE_OPTIONS "더보기"
#define D_CHECK_CREDENTIALS "Please, check your credentials"
#define D_CHECK_CREDENTIALS "올바른 WiFi 네트워크인지 확인해주세요"
#define D_SUCCESSFUL_WIFI_CONNECTION "Successful WiFi Connection"
#define D_NOW_YOU_CAN_CLOSE_THIS_WINDOW "Now you can close this window"
#define D_REDIRECTING_TO_NEW_IP "새로운 네트워크로 이동 중입니다. 잠시만 기다려주세요"
Expand Down Expand Up @@ -393,6 +393,8 @@
#define D_ENABLE_WEBLOG_FOR_RESPONSE "응답이 있다면 Weblog 2를 사용"
#define D_NEED_USER_AND_PASSWORD "user=<아이디>&password=<비밀번호> 필요"

#define D_CHECK_CERTIFICATION "인증서 정보가 없습니다. 직방 앱을 사용해 기기를 등록해주세요."

// xdrv_01_mqtt.ino
#define D_FINGERPRINT "TLS 지문 확인..."
#define D_TLS_CONNECT_FAILED_TO "TLS 연결 실패"
Expand Down
3 changes: 1 addition & 2 deletions tasmota/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ typedef union {
} DisplayOptions;

const uint32_t settings_text_size = 699; // Settings->text_pool[size] = Settings->display_model (2D2) - Settings->text_pool (017)
const uint8_t MAX_TUYA_FUNCTIONS = 16;
const uint8_t MAX_TUYA_FUNCTIONS = 1;

typedef struct {
uint16_t cfg_holder; // 000 v6 header
Expand Down Expand Up @@ -689,7 +689,6 @@ typedef struct {
uint16_t syslog_port; // ECA
uint8_t syslog_level; // ECC
uint8_t webserver; // ECD
uint8_t weblog_level; // ECE
uint8_t mqtt_fingerprint[2][20]; // ECF

uint8_t ex_adc_param_type; // EF7 Free since 9.0.0.1
Expand Down
2 changes: 0 additions & 2 deletions tasmota/settings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,6 @@ void SettingsDefaultSet2(void) {
flag3.gui_hostname_ip |= GUI_SHOW_HOSTNAME;
flag3.mdns_enabled |= MDNS_ENABLED;
Settings->webserver = WEB_SERVER;
Settings->weblog_level = WEB_LOG_LEVEL;
SettingsUpdateText(SET_WEBPWD, PSTR(WEB_PASSWORD));
SettingsUpdateText(SET_CORS, PSTR(CORS_DOMAIN));

// Button
Expand Down
3 changes: 1 addition & 2 deletions tasmota/support.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2360,8 +2360,7 @@ void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_pa

if (!TasmotaGlobal.log_buffer) { return; } // Leave now if there is no buffer available

uint32_t highest_loglevel = Settings->weblog_level;
if (Settings->mqttlog_level > highest_loglevel) { highest_loglevel = Settings->mqttlog_level; }
uint32_t highest_loglevel = Settings->mqttlog_level;
if (TasmotaGlobal.syslog_level > highest_loglevel) { highest_loglevel = TasmotaGlobal.syslog_level; }
if (TasmotaGlobal.templog_level > highest_loglevel) { highest_loglevel = TasmotaGlobal.templog_level; }
if (TasmotaGlobal.uptime < 3) { highest_loglevel = LOG_LEVEL_DEBUG_MORE; } // Log all before setup correct log level
Expand Down
62 changes: 60 additions & 2 deletions tasmota/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
#endif // USE_DEVICE_GROUPS_SEND
D_CMND_DEVGROUP_SHARE "|" D_CMND_DEVGROUPSTATUS "|" D_CMND_DEVGROUP_TIE "|"
#endif // USE_DEVICE_GROUPS
D_CMND_FACTORY_RESET "|" D_CMND_SSID_RESET "|" D_CMND_UPDATE_CERT "|" D_CMND_READ_INPUT "|"
D_CMND_SENSOR "|" D_CMND_DRIVER
#ifdef ESP32
"|Info|" D_CMND_TOUCH_CAL "|" D_CMND_TOUCH_THRES "|" D_CMND_TOUCH_NUM "|" D_CMND_CPU_FREQUENCY
Expand Down Expand Up @@ -67,6 +68,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
#endif // USE_DEVICE_GROUPS_SEND
&CmndDevGroupShare, &CmndDevGroupStatus, &CmndDevGroupTie,
#endif // USE_DEVICE_GROUPS
&CmndFactoryReset, &CmndSSIDReset, &CmndUpdateCert, &CmndReadInput,
&CmndSensor, &CmndDriver
#ifdef ESP32
, &CmndInfo, &CmndTouchCal, &CmndTouchThres, &CmndTouchNum, &CmndCpuFrequency
Expand Down Expand Up @@ -525,10 +527,10 @@ void CmndStatus(void)
}

if ((0 == payload) || (3 == payload)) {
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS3_LOGGING "\":{\"" D_CMND_SERIALLOG "\":%d,\"" D_CMND_WEBLOG "\":%d,\"" D_CMND_MQTTLOG "\":%d,\"" D_CMND_SYSLOG "\":%d,\""
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS3_LOGGING "\":{\"" D_CMND_SERIALLOG "\":%d,\"" D_CMND_MQTTLOG "\":%d,\"" D_CMND_SYSLOG "\":%d,\""
D_CMND_LOGHOST "\":\"%s\",\"" D_CMND_LOGPORT "\":%d,\"" D_CMND_SSID "\":[\"%s\",\"%s\"],\"" D_CMND_TELEPERIOD "\":%d,\""
D_JSON_RESOLUTION "\":\"%08X\",\"" D_CMND_SETOPTION "\":[\"%08X\",\"%s\",\"%08X\",\"%08X\",\"%08X\"]}}"),
Settings->seriallog_level, Settings->weblog_level, Settings->mqttlog_level, Settings->syslog_level,
Settings->seriallog_level, Settings->mqttlog_level, Settings->syslog_level,
SettingsText(SET_SYSLOG_HOST), Settings->syslog_port, EscapeJSONString(SettingsText(SET_STASSID1)).c_str(), EscapeJSONString(SettingsText(SET_STASSID2)).c_str(), Settings->tele_period,
Settings->flag2.data, Settings->flag.data, ToHex_P((unsigned char*)Settings->param, PARAM8_SIZE, stemp2, sizeof(stemp2)),
Settings->flag3.data, Settings->flag4.data, Settings->flag5.data);
Expand Down Expand Up @@ -2263,6 +2265,62 @@ void CmndDevGroupTie(void)
}
#endif // USE_DEVICE_GROUPS

void CmndFactoryReset(void)
{
TasmotaGlobal.restart_flag = 212;
Response_P(PSTR("{\"Factory reset\":\"Success\"}"));
}

void CmndSSIDReset(void)
{
SettingsUpdateText(SET_STASSID1, "");
SettingsUpdateText(SET_STAPWD1, "");
SettingsUpdateText(SET_STASSID2, "");
SettingsUpdateText(SET_STAPWD2, "");
TasmotaGlobal.restart_flag = 2;
Response_P(PSTR("{\"SSID reset\":\"Success\"}"));
}

void CmndUpdateCert(void)
{
if (XdrvMailbox.data_len > 0) {
JsonParser parser((char*) XdrvMailbox.data);
JsonParserObject stateObject = parser.getRootObject();

String cert = stateObject["cert"].getStr();
String key = stateObject["key"].getStr();

if (!cert.length() || !key.length()) {
Response_P(PSTR("{\"Cert update\":\"Failed\"}"));
return;
}

TasmotaGlobal.cert_info_flag = 0;
char* certCharType = (char*)cert.c_str();
char* keyCharType = (char*)key.c_str();

memcpy(AmazonClientCert, certCharType, strlen(certCharType));
memcpy(AmazonPrivateKey, keyCharType, strlen(keyCharType));
printf("cert: %s\n", certCharType);
printf("key: %s\n", keyCharType);

cert.~String();
key.~String();

ConvertTlsFile(0);
ConvertTlsFile(1);
TasmotaGlobal.cert_info_flag = 1;
Response_P(PSTR("{\"Cert update\":\"Success\"}"));
} else {
Response_P(PSTR("{\"Cert update\":\"Failed\"}"));
}
}

void CmndReadInput(void)
{
// TODO: Read GPIO value
}

void CmndSensor(void)
{
XsnsCall(FUNC_COMMAND_SENSOR);
Expand Down
29 changes: 9 additions & 20 deletions tasmota/support_tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ void Every250mSeconds(void)

switch (TasmotaGlobal.state_250mS) {
case 0: // Every x.0 second
if (TasmotaGlobal.ota_state_flag && CommandsReady()) {
if (TasmotaGlobal.ota_state_flag && CommandsReady()) { // TODO: Flash에 저장된 OTA 설정 값을 읽는 것으로 변경, OTA 모드, 프로비저닝 모드에서 동작하지 않도록 체크 로직 필요
TasmotaGlobal.ota_state_flag--;
if (2 == TasmotaGlobal.ota_state_flag) {
RtcSettings.ota_loader = 0; // Try requested image first
Expand Down Expand Up @@ -1312,22 +1312,9 @@ void Every250mSeconds(void)
StartMdns();

#ifdef USE_WEBSERVER
if (Settings->webserver) {

#ifdef ESP8266
if (!WifiIsInManagerMode()) { StartWebserver(Settings->webserver, WiFi.localIP()); }
#endif // ESP8266
#ifdef ESP32
#ifdef USE_ETHERNET
StartWebserver(Settings->webserver, (EthernetLocalIP()) ? EthernetLocalIP() : WiFi.localIP());
#else
StartWebserver(Settings->webserver, WiFi.localIP());
#endif
#endif // ESP32

MdnsAddServiceHttp();
} else {
if (!Settings->webserver) {
StopWebserver();
StopWebserverSecure();
}
#ifdef USE_EMULATION
if (Settings->flag2.emulation) { UdpConnect(); }
Expand All @@ -1345,7 +1332,12 @@ void Every250mSeconds(void)
}
#endif // USE_KNX

MqttCheck();
if (TasmotaGlobal.idToken_info_flag) {
// 프로비저닝 모드
ProvisioningCheck();
} else {
MqttCheck();
}
} else {
#ifdef USE_EMULATION
UdpDisconnect();
Expand Down Expand Up @@ -1378,9 +1370,6 @@ void ArduinoOTAInit(void)
{
ArduinoOTA.setPort(8266);
ArduinoOTA.setHostname(NetworkHostname());
if (strlen(SettingsText(SET_WEBPWD))) {
ArduinoOTA.setPassword(SettingsText(SET_WEBPWD));
}

ArduinoOTA.onStart([]()
{
Expand Down
29 changes: 15 additions & 14 deletions tasmota/tasmota.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ const uint8_t MAX_PWMS = 5; // Max number of PWM channels
const uint8_t MAX_COUNTERS = 4; // Max number of counter sensors
const uint8_t MAX_TIMERS = 16; // Max number of Timers
const uint8_t MAX_PULSETIMERS = 8; // Max number of supported pulse timers
const uint8_t MAX_DOMOTICZ_IDX = 4; // Max number of Domoticz device, key and switch indices
const uint8_t MAX_DOMOTICZ_SNS_IDX = 12; // Max number of Domoticz sensors indices
const uint8_t MAX_KNX_GA = 10; // Max number of KNX Group Addresses to read that can be set
const uint8_t MAX_KNX_CB = 10; // Max number of KNX Group Addresses to write that can be set
const uint8_t MAX_DOMOTICZ_IDX = 1; // Max number of Domoticz device, key and switch indices
const uint8_t MAX_DOMOTICZ_SNS_IDX = 1; // Max number of Domoticz sensors indices
const uint8_t MAX_KNX_GA = 1; // Max number of KNX Group Addresses to read that can be set
const uint8_t MAX_KNX_CB = 1; // Max number of KNX Group Addresses to write that can be set
const uint8_t MAX_XNRG_DRIVERS = 32; // Max number of allowed energy drivers
const uint8_t MAX_XDSP_DRIVERS = 32; // Max number of allowed display drivers
const uint8_t MAX_XDRV_DRIVERS = 96; // Max number of allowed driver drivers
Expand All @@ -78,7 +78,7 @@ const uint8_t MAX_SHUTTER_RELAYS = 8; // Max number of shutter relays
const uint8_t MAX_SHUTTER_KEYS = 4; // Max number of shutter keys or buttons
const uint8_t MAX_PCF8574 = 4; // Max number of PCF8574 devices
const uint8_t MAX_RULE_SETS = 3; // Max number of rule sets of size 512 characters
const uint16_t MAX_RULE_SIZE = 512; // Max number of characters in rules
const uint16_t MAX_RULE_SIZE = 1; // Max number of characters in rules
const uint16_t VL53L0X_MAX_SENSORS = 8; // Max number of VL53L0X sensors

#ifdef ESP32
Expand Down Expand Up @@ -123,6 +123,8 @@ const char WIFI_HOSTNAME[] = "ZIGBANG"; // Expands to <MQTT_TOPIC>-<last 4 d
const uint8_t CONFIG_FILE_SIGN = 0xA5; // Configuration file signature
const uint8_t CONFIG_FILE_XOR = 0x5A; // Configuration file xor (0 = No Xor)

const uint8_t INPUT_BUFFER_SIZE = 100; // Max number of characters in serial command buffer

const uint32_t HLW_PREF_PULSE = 12530; // was 4975us = 201Hz = 1000W
const uint32_t HLW_UREF_PULSE = 1950; // was 1666us = 600Hz = 220V
const uint32_t HLW_IREF_PULSE = 3500; // was 1666us = 600Hz = 4.545A
Expand Down Expand Up @@ -163,17 +165,16 @@ const uint8_t OTA_ATTEMPTS = 10; // Number of times to try fetching t
const uint8_t OTA_ATTEMPTS = 5; // Number of times to try fetching the new firmware
#endif // ESP8266

const uint16_t INPUT_BUFFER_SIZE = 520; // Max number of characters in serial command buffer
const uint16_t FLOATSZ = 16; // Max number of characters in float result from dtostrfd (max 32)
const uint16_t CMDSZ = 24; // Max number of characters in command
const uint16_t TOPSZ = 151; // Max number of characters in topic string
const uint16_t TOPSZ = 60; // Max number of characters in topic string

#ifdef ESP8266
#ifdef PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
const uint16_t LOG_BUFFER_SIZE = 4096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
const uint16_t LOG_BUFFER_SIZE = 2048; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
//const uint16_t LOG_BUFFER_SIZE = 6144; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
#else
const uint16_t LOG_BUFFER_SIZE = 4096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
const uint16_t LOG_BUFFER_SIZE = 512; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
#endif // PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
#else // Not ESP8266
const uint16_t LOG_BUFFER_SIZE = 6144; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
Expand All @@ -187,7 +188,7 @@ const uint16_t MAX_LOGSZ = 700; // Max number of characters in log l

const uint8_t SENSOR_MAX_MISS = 5; // Max number of missed sensor reads before deciding it's offline

const uint8_t MAX_BACKLOG = 30; // Max number of commands in backlog
const uint8_t MAX_BACKLOG = 10; // Max number of commands in backlog
const uint32_t MIN_BACKLOG_DELAY = 200; // Minimal backlog delay in mSeconds

const uint32_t SOFT_BAUDRATE = 9600; // Default software serial baudrate
Expand Down Expand Up @@ -329,13 +330,13 @@ enum XsnsFunctions {FUNC_SETTINGS_OVERRIDE, FUNC_PIN_STATE, FUNC_MODULE_INIT, FU
FUNC_SET_POWER, FUNC_SET_DEVICE_POWER, FUNC_SHOW_SENSOR, FUNC_ANY_KEY,
FUNC_ENERGY_EVERY_SECOND, FUNC_ENERGY_RESET,
FUNC_RULES_PROCESS, FUNC_TELEPERIOD_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM, FUNC_BUTTON_PRESSED,
FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_CONSOLE_BUTTON, FUNC_WEB_ADD_MANAGEMENT_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON,
FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_MANAGEMENT_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON,
FUNC_WEB_ADD_HANDLER, FUNC_SET_CHANNELS, FUNC_SET_SCHEME, FUNC_HOTPLUG_SCAN,
FUNC_DEVICE_GROUP_ITEM };

enum AddressConfigSteps { ADDR_IDLE, ADDR_RECEIVE, ADDR_SEND };

enum SettingsTextIndex { SET_OTAURL,
enum SettingsTextIndex { SET_ID_TOKEN, SET_OTAURL,
SET_MQTTPREFIX1, SET_MQTTPREFIX2, SET_MQTTPREFIX3, // MAX_MQTT_PREFIXES
SET_STASSID1, SET_STASSID2, // MAX_SSIDS
SET_STAPWD1, SET_STAPWD2, // MAX_SSIDS
Expand Down Expand Up @@ -399,10 +400,10 @@ enum DevGroupItemFlag { DGR_ITEM_FLAG_NO_SHARE = 1 };
enum DevGroupShareItem { DGR_SHARE_POWER = 1, DGR_SHARE_LIGHT_BRI = 2, DGR_SHARE_LIGHT_FADE = 4, DGR_SHARE_LIGHT_SCHEME = 8,
DGR_SHARE_LIGHT_COLOR = 16, DGR_SHARE_DIMMER_SETTINGS = 32, DGR_SHARE_EVENT = 64 };

enum CommandSource { SRC_IGNORE, SRC_MQTT, SRC_RESTART, SRC_BUTTON, SRC_SWITCH, SRC_BACKLOG, SRC_SERIAL, SRC_WEBGUI, SRC_WEBCOMMAND, SRC_WEBCONSOLE, SRC_PULSETIMER,
enum CommandSource { SRC_IGNORE, SRC_MQTT, SRC_RESTART, SRC_BUTTON, SRC_SWITCH, SRC_BACKLOG, SRC_SERIAL, SRC_WEBGUI, SRC_WEBCOMMAND, SRC_PULSETIMER,
SRC_TIMER, SRC_RULE, SRC_MAXPOWER, SRC_MAXENERGY, SRC_OVERTEMP, SRC_LIGHT, SRC_KNX, SRC_DISPLAY, SRC_WEMO, SRC_HUE, SRC_RETRY, SRC_REMOTE, SRC_SHUTTER,
SRC_THERMOSTAT, SRC_CHAT, SRC_TCL, SRC_BERRY, SRC_FILE, SRC_MAX };
const char kCommandSource[] PROGMEM = "I|MQTT|Restart|Button|Switch|Backlog|Serial|WebGui|WebCommand|WebConsole|PulseTimer|"
const char kCommandSource[] PROGMEM = "I|MQTT|Restart|Button|Switch|Backlog|Serial|WebGui|WebCommand|PulseTimer|"
"Timer|Rule|MaxPower|MaxEnergy|Overtemp|Light|Knx|Display|Wemo|Hue|Retry|Remote|Shutter|"
"Thermostat|Chat|TCL|Berry|File";

Expand Down
11 changes: 11 additions & 0 deletions tasmota/tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ struct {
uint8_t last_source; // Last command source
uint8_t shutters_present; // Number of actual define shutters
uint8_t discovery_counter; // Delayed discovery counter
uint8_t idToken_info_flag; // Zigbang id token from app
uint8_t cert_info_flag; // AWS IoT certification

#ifndef SUPPORT_IF_STATEMENT
uint8_t backlog_index; // Command backlog index
Expand Down Expand Up @@ -303,6 +305,10 @@ void setup(void) {
strcpy(TasmotaGlobal.mqtt_topic, tmp);
sprintf(tmp, "ZiotThing_%s_%s_group", DEVICE_TYPE, SettingsText(SET_FRIENDLYNAME1));
SettingsUpdateText(SET_MQTT_GRP_TOPIC, tmp);
if (strlen(SettingsText(SET_ID_TOKEN))) {
TasmotaGlobal.idToken_info_flag = true;
}
printf("MQTT_TOPIC: %s\n", SettingsText(SET_MQTT_TOPIC));

SettingsDelta();

Expand Down Expand Up @@ -393,6 +399,9 @@ void setup(void) {
SettingsUpdateText(SET_HOSTNAME, TasmotaGlobal.hostname);
}

mac_address.~String();
mac_part.~String();

RtcInit();
GpioInit();
ButtonInit();
Expand Down Expand Up @@ -420,6 +429,8 @@ void setup(void) {
ArduinoOTAInit();
#endif // USE_ARDUINO_OTA

HTTPSClientInit();

XdrvCall(FUNC_INIT);
XsnsCall(FUNC_INIT);
#ifdef USE_SCRIPT
Expand Down
25 changes: 25 additions & 0 deletions tasmota/tasmota_cert.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,29 @@
char AmazonClientCert[857];
char AmazonPrivateKey[45];

static const char serverCert[] PROGMEM = R"EOF(
-----BEGIN CERTIFICATE-----
MIIBCzCBtgIJAL0cewa9T9XLMA0GCSqGSIb3DQEBCwUAMA0xCzAJBgNVBAYTAktS
MB4XDTIyMDExMzAyNDEyN1oXDTMzMDQwMTAyNDEyN1owDTELMAkGA1UEBhMCS1Iw
XDANBgkqhkiG9w0BAQEFAANLADBIAkEAuC6rUj2m0phpCkZVV9U//v4H8/3vaHck
dG9f0yMpZyoXsZBaIePPfBjLW5kg16Fj+eQP0IKhWJ3LzNTVAXl1nwIDAQABMA0G
CSqGSIb3DQEBCwUAA0EAnTlMjfsHiNwFlxIjgp+r0CpqE6+o+WlnjuUCYi3ZnmNe
eclX5v75TKvJQ4nrDqQfTwqaO+iNs/DJDqsVpWZZEQ==
-----END CERTIFICATE-----
)EOF";

static const char serverKey[] PROGMEM = R"EOF(
-----BEGIN PRIVATE KEY-----
MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAuC6rUj2m0phpCkZV
V9U//v4H8/3vaHckdG9f0yMpZyoXsZBaIePPfBjLW5kg16Fj+eQP0IKhWJ3LzNTV
AXl1nwIDAQABAkBV492c8oczOkPxuK7f0OCRJyHKVKcqjjT/31hOe9048AuYFdio
8599iR+EMYu1499Z2VLtkPyePTsraKwuSufhAiEA3wIezIGyjGL9enn/RSJoIKuk
RfBXLl60MsbDeJ6a84cCIQDTbhy6NxDon4JwA4Q/dX/ZVGADtzn9MYzGeAFQqvsj
KQIgMqIonAZWo8lWBBju/KNzQPe3tKl9Ieoev+ihOSHJzMECIEmuavZ+MDdRN0y/
/Pt8gDSF0fwZg2z4Mp4LvjGVlHWZAiA5Qd0a1Jt9to6tlOpilS0uW4HdoW8CK6pA
Ng9m8M/5+Q==
-----END PRIVATE KEY-----
)EOF";


#endif // defined(USE_TLS) && defined(USE_MQTT_TLS_CA_CERT)
Loading