New branch for my new AIO key.
Will have to remember to sanitize before committing to master. Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
This commit is contained in:
parent
70cf55efdf
commit
1cd8191682
4 changed files with 24 additions and 21 deletions
33
main.c
33
main.c
|
@ -65,31 +65,26 @@ void ICACHE_FLASH_ATTR user_init() {
|
|||
|
||||
// prepare the TCP/MQTT connection stuff
|
||||
// Adafruit IO is at 52.5.238.97
|
||||
|
||||
static const char testUser[11] = { 0x4d, 0x72, 0x41, 0x75, 0x72, 0x65, 0x6c, 0x69, 0x75, 0x73, 0x52 };
|
||||
static const uint8_t testUser_len = 11;
|
||||
static const char testPass[32] = { 0x63, 0x61, 0x62, 0x31, 0x39, 0x36, 0x36, 0x34, 0x31, 0x66, 0x33, 0x63, 0x34, 0x34, 0x36, 0x32, 0x61, 0x35, 0x30, 0x39, 0x64, 0x62, 0x64, 0x31, 0x34, 0x61, 0x30, 0x61, 0x66, 0x36, 0x64, 0x32 };
|
||||
static const uint8_t testPass_len = 32;
|
||||
//static const char testPass[4] = { 0x74, 0x65, 0x73, 0x74 };
|
||||
//static const uint8_t testPass_len = 4;
|
||||
static const char testTopic[37] = { 0x4d, 0x72, 0x41, 0x75, 0x72, 0x65, 0x6c, 0x69, 0x75, 0x73, 0x52, 0x2f, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2f, 0x62, 0x65, 0x64, 0x72, 0x6f, 0x6f, 0x6d, 0x2e, 0x62, 0x65, 0x64, 0x72, 0x6f, 0x6f, 0x6d, 0x74, 0x65, 0x6d, 0x70 };
|
||||
static const uint8_t testTopic_len = 37;
|
||||
//static const char testTopic[4] = { 0x74, 0x65, 0x73, 0x74 };
|
||||
//static const uint8_t testTopic_len = 4;
|
||||
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] = { 0x32, 0x63, 0x39, 0x36, 0x65, 0x30, 0x35, 0x61, 0x66, 0x34, 0x35, 0x30, 0x34, 0x31, 0x66, 0x31, 0x38, 0x36, 0x65, 0x62, 0x39, 0x30, 0x33, 0x32, 0x33, 0x31, 0x31, 0x31, 0x61, 0x32, 0x61, 0x38 }; // 2c96e05af45041f186eb90323111a2a8
|
||||
static const uint8_t ioKey_len = 32;
|
||||
static const char ioTopic[37] = { 0x4d, 0x72, 0x41, 0x75, 0x72, 0x65, 0x6c, 0x69, 0x75, 0x73, 0x52, 0x2f, 0x66, 0x65, 0x65, 0x64, 0x73, 0x2f, 0x62, 0x65, 0x64, 0x72, 0x6f, 0x6f, 0x6d, 0x2e, 0x62, 0x65, 0x64, 0x72, 0x6f, 0x6f, 0x6d, 0x74, 0x65, 0x6d, 0x70 };
|
||||
static const uint8_t ioTopic_len = 37;
|
||||
static const char clientID[5] = { 0x46, 0x5a, 0x5a, 0x4e, 0x30 };
|
||||
static const uint8_t clientID_len = 5;
|
||||
pGlobalSession->port = 1883; // mqtt port
|
||||
static const char esp_tcp_server_ip[4] = {52, 5, 238, 97};
|
||||
os_memcpy(pGlobalSession->ip, esp_tcp_server_ip, 4);
|
||||
pGlobalSession->username_len = testUser_len;
|
||||
static const char adafruitIO_ip[4] = {52, 5, 238, 97};
|
||||
os_memcpy(pGlobalSession->ip, adafruitIO_ip, 4);
|
||||
pGlobalSession->username_len = ioUser_len;
|
||||
pGlobalSession->username = os_zalloc(sizeof(uint8_t) * pGlobalSession->username_len);
|
||||
os_memcpy(pGlobalSession->username, testUser, pGlobalSession->username_len);
|
||||
pGlobalSession->password_len = testPass_len;
|
||||
os_memcpy(pGlobalSession->username, ioUser, pGlobalSession->username_len);
|
||||
pGlobalSession->password_len = ioKey_len;
|
||||
pGlobalSession->password = os_zalloc(sizeof(uint8_t) * pGlobalSession->password_len);
|
||||
os_memcpy(pGlobalSession->password, testPass, pGlobalSession->password_len);
|
||||
pGlobalSession->topic_name_len = testTopic_len;
|
||||
os_memcpy(pGlobalSession->password, ioKey, pGlobalSession->password_len);
|
||||
pGlobalSession->topic_name_len = ioTopic_len;
|
||||
pGlobalSession->topic_name = os_zalloc(sizeof(uint8_t) * pGlobalSession->topic_name_len);
|
||||
os_memcpy(pGlobalSession->topic_name, testTopic, pGlobalSession->topic_name_len);
|
||||
os_memcpy(pGlobalSession->topic_name, ioTopic, pGlobalSession->topic_name_len);
|
||||
pGlobalSession->client_id_len = clientID_len;
|
||||
pGlobalSession->client_id = os_zalloc(sizeof(uint8_t) * pGlobalSession->client_id_len);
|
||||
os_memcpy(pGlobalSession->client_id, clientID, pGlobalSession->client_id_len);
|
||||
|
|
6
mqtt.c
6
mqtt.c
|
@ -72,9 +72,15 @@ LOCAL void ICACHE_FLASH_ATTR data_recv_callback(void *arg, char *pdata, unsigned
|
|||
os_printf("Connection refused -- illegal CONNACK return code.\n");
|
||||
break;
|
||||
}
|
||||
if(session->connack_cb != NULL) {
|
||||
session->connack_cb(pData);
|
||||
}
|
||||
break;
|
||||
case MQTT_MSG_TYPE_PUBLISH:
|
||||
os_printf("Application message from server: %s\n", &pdata[3]); // probably incorrect
|
||||
if(session->publish_cb != NULL) {
|
||||
session->publish_cb(pData);
|
||||
}
|
||||
break;
|
||||
case MQTT_MSG_TYPE_SUBACK:
|
||||
os_printf("Subscription acknowledged\n");
|
||||
|
|
2
mqtt.h
2
mqtt.h
|
@ -83,6 +83,8 @@ typedef struct {
|
|||
char validConnection; /**< Boolean value which indicates whether or not the TCP connection is established, set in tcpConnect() */
|
||||
struct espconn *activeConnection; /**< A pointer to the espconn structure containing details of the TCP connection */
|
||||
// Add pointers to user callback functions
|
||||
void (*publish_cb)(void *arg); /**< Pointer to user callback function for publish */
|
||||
void (*connack_cb)(void *arg); /**< Pointer to user callback function for connack */
|
||||
} mqtt_session_t;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#!/usr/bin/python3
|
||||
##
|
||||
# @file
|
||||
# @brief File to create string arrays
|
||||
|
@ -28,5 +28,5 @@ for letter in inString[:-1]:
|
|||
|
||||
p = ord(inString[-1])
|
||||
print("{0:#x} ".format(int(p)), end='')
|
||||
print("};")
|
||||
print("}; // " + inString)
|
||||
print("static const uint8_t {0}_len = {1};".format(sys.argv[2], len(inString)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue