this is using the mbed os version 5-13-1
Diff: source/WiFiManager.h
- Branch:
- PassingRegression
- Revision:
- 129:590bdc2dcf5b
- Parent:
- 127:a21788227ca6
diff -r a21788227ca6 -r 590bdc2dcf5b source/WiFiManager.h
--- a/source/WiFiManager.h Mon Jul 15 21:37:22 2019 +0000
+++ b/source/WiFiManager.h Fri Jul 19 16:49:26 2019 +0000
@@ -19,11 +19,16 @@
#define TOKEN_RESPONSE_SIZE 5*1024
#define ID_TOKEN_SIZE 1024
#define REFRESH_TOKEN_SIZE 2*1024
+#define KEEPALIVE_MSG_SIZE 1280
+#define SECS_PER_HOUR 3600
+#define MSECS_PER_SEC 1000
+#define SECS_IN_MIN 60
+#define TOKEN_VALID_PERIOD_MS (SECS_PER_HOUR-SECS_IN_MIN)*MSECS_PER_SEC // 1 hour less 1 minute
#define ID_TOKEN_STR_START "\"IdToken\":\""
#define REFRESH_TOKEN_STR_START "\"RefreshToken\":\""
#define ACCESS_TOKEN_STR_END "\",\""
-const char TOKEN_REQ_HDR[] = "POST / HTTP1.1\r\n"
+const char TOKEN_REQ_HDR[] = "POST / HTTP/1.1\r\n"
"Host: cognito-idp.eu-west-2.amazonaws.com\r\n"
"X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth\r\n"
"Content-Type: application/x-amz-json-1.1";
@@ -31,7 +36,7 @@
const char Password[] = "DnaN2dg3B4x!";
const char AuthFlow[] = "USER_PASSWORD_AUTH";
const char ClientId[] = "3el1h42i52p0e1gkb0l86ougdv";
-
+const char AWS_HOST_NAME[] = "cognito-idp.eu-west-2.amazonaws.com";
const uint8_t HELLO_MSG[] = {0x50,0x4f
,0x53,0x54,0x20,0x2f,0x6e,0x75,0x64,0x67
,0x65,0x62,0x6f,0x78,0x2f,0x76,0x31,0x20
@@ -52,7 +57,15 @@
,0xca,0x6e,0x79,0x05,0x4e,0x01,0x68,0x65
,0x6c,0x6c,0x6f,0x00,0x00,0x91,0xb5,0xa4
,0x10};
+const char KEEPALIVE_MSG_HDR[] = "POST /nudgebox/v1 HTTP/1.1\r\n"
+ "Host: dev-box.dnanudge.io\r\n"
+ "Content-Type: application/octet-stream\r\n"
+ "Content-Length: 20"
+ "";
+const uint8_t KEEPALIVE_MSG_BDY[] = {0x00,0x08,0xd4, 0xca,0x6e,0x79,0x05,0x4e,
+ 0x01,0x68,0x65, 0x6c,0x6c,0x6f,0x00,0x00,
+ 0x91,0xb5,0xa4,0x10};
extern void print_memory_info();
#define CLOUD_KEEP_ALIVE_INTERVAL 9000
class WiFiManager {
@@ -91,6 +104,8 @@
char* responseString; // response string formated for Box
uint8_t* responseBytes; // response bytes formated for Box
wifi_cmd_t wifiCmd;
+ wifi_cmd_t fromWiFiCmd;
+ wifi_cmd_t nextWiFiCmd;
bool backgroundTaskCompleted;
//at_data_msg_t *at_data_resp;
int chunkNum;
@@ -121,9 +136,11 @@
http_result_t http_result;
bool use_full_hostname;
int keep_alive_id;
- bool https_request_succeeded;
+ bool https_token_valid;
char * aws_id_token;
char * aws_refresh_token;
+ int token_refresh_count;
+ uint8_t *http_req_log_buf;
#ifdef DNANUDGE_DEBUG
rtos::Semaphore callback_semaphore;
@@ -183,6 +200,11 @@
void keepSocketAlive();
void CreateTokenHttpsRequest(char * httpsReq);
void GetCloudAccessToken();
+ void printHttpRequestLogBuffer();
+ void invalidateAccessToken();
+ void freeAccessTokenMemory();
+ void createTLSconnThreadCall(const char * hostName);
+ void waitForBackgroundTask(int timeout_ms, int inc_ms);