From dc724a2c9649234c4c202b6b821f71f9d76b99dd Mon Sep 17 00:00:00 2001 From: "A.M. Rowsell" Date: Sat, 6 Apr 2019 09:52:45 -0400 Subject: [PATCH] Merged updates from dev branch into master Signed-off-by: A.M. Rowsell --- main.c | 11 ++++++----- strtoarr.py | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 719ef25..5a17640 100644 --- a/main.c +++ b/main.c @@ -121,8 +121,8 @@ LOCAL void ICACHE_FLASH_ATTR dataLog(void *arg) { void ICACHE_FLASH_ATTR user_init() { LOCAL mqtt_session_t globalSession; LOCAL mqtt_session_t *pGlobalSession = &globalSession; - char ssid[32] = "yourwifissid"; char passkey[64] = "yourwifipass"; + char ssid[32] = "yourwifissid"; struct station_config stationConf; gpio_init(); // init gpio so we can use the LED & onewire bus @@ -137,14 +137,15 @@ void ICACHE_FLASH_ATTR user_init() { // prepare the TCP/MQTT connection stuff // Adafruit IO is at 52.5.238.97 // use strtoarr.py to generate these - static const char ioUser[11] = { 0x4d, 0x72, 0x41, 0x75, 0x72, 0x65, 0x6c, 0x69, 0x75, 0x73, 0x52 }; // MrAureliusR static const uint8_t ioUser_len = 11; - static const char ioKey[32] = { }; // use strtoarr.py to generate these + static const char ioUser[ioUser_len] = { 0x4d, 0x72, 0x41, 0x75, 0x72, 0x65, 0x6c, 0x69, 0x75, 0x73, 0x52 }; // MrAureliusR static const uint8_t ioKey_len = 32; - static const char ioTopic[27] = { 0x4d, 0x72, 0x41, 0x75, 0x72, 0x65, 0x6c, 0x69, 0x75, 0x73, 0x52, 0x2f, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x74, 0x6f, 0x70, 0x69, 0x63 }; // MrAureliusR/feeds/testtopic + static const char ioKey[ioKey_len] = { }; static const uint8_t ioTopic_len = 27; - static const char clientID[5] = { 0x46, 0x52, 0x5a, 0x4e, 0x30 }; // FRZN0 + static const char ioTopic[ioTopic_len] = { 0x4d, 0x72, 0x41, 0x75, 0x72, 0x65, 0x6c, 0x69, 0x75, 0x73, 0x52, 0x2f, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x74, 0x6f, 0x70, 0x69, 0x63 }; // MrAureliusR/feeds/testtopic static const uint8_t clientID_len = 5; + static const char clientID[clientID_len] = { 0x46, 0x52, 0x5a, 0x4e, 0x30 }; // FRZN0 + pGlobalSession->port = 1883; // mqtt port static const char adafruitIO_ip[4] = {52, 5, 238, 97}; diff --git a/strtoarr.py b/strtoarr.py index 5f3198d..3a5cf45 100755 --- a/strtoarr.py +++ b/strtoarr.py @@ -21,7 +21,8 @@ import os inString = str(sys.argv[1]); -print("static const char {0}[{1}] = {{ ".format(sys.argv[2], len(inString)), end='') +print("static const uint8_t {0}_len = {1};".format(sys.argv[2], len(inString))) +print("static const char {0}[{0}_len] = {{ ".format(sys.argv[2], len(inString)), end='') for letter in inString[:-1]: p = ord(letter) print("{0:#x}, ".format(p), end='') @@ -29,4 +30,4 @@ for letter in inString[:-1]: p = ord(inString[-1]) print("{0:#x} ".format(int(p)), end='') print("}; // " + inString) -print("static const uint8_t {0}_len = {1};".format(sys.argv[2], len(inString))) +