Okundu Omeni
/
wifi-https-ble-sm-uart-atcmd-5-13-1
this is using the mbed os version 5-13-1
Diff: source/ATCmdManager.cpp
- Revision:
- 93:06e755a80187
- Parent:
- 92:ec9550034276
- Child:
- 95:290859010c8c
--- a/source/ATCmdManager.cpp Sat Apr 13 14:17:29 2019 +0000 +++ b/source/ATCmdManager.cpp Sun Apr 14 14:38:51 2019 +0000 @@ -173,6 +173,14 @@ _smutex.unlock(); at_resp = AT_RESP_NONE; break; + case AT_COMMAND_FAILED: + // AT_HTTP_RESP response state + printf("\n [ATCMD MAN] WIFI COMMAND FAILED!!\n"); + _smutex.lock(); + _parser.send("\r\nNACK\r\n"); + _smutex.unlock(); + at_resp = AT_RESP_NONE; + break; default: // UNKNOWN response state _smutex.lock(); @@ -736,9 +744,11 @@ { int c; int sptr = 0; + int quoteCnt = 0; for(int i=0;i<maxBytes;i++){ c = _parser.getc(); - if(c==-1){ + if(c== '"')quoteCnt++; + if(c==-1 || quoteCnt==2){ buf[sptr] = NULL; // null terminate if string return i; } @@ -870,8 +880,6 @@ wifi_cmd_message_t *wifiCmd = _aT2WiFimPool->alloc(); if(wifiCmd == NULL){ printf("[ATCMD MAN] queued memory allocation failed\n"); - print_memory_info(); - print_heap_and_isr_stack_info(); return false; } #else @@ -905,6 +913,8 @@ } bool ATCmdManager::queueWiFiDataRequest(wifi_data_msg_t data_req){ + //print_memory_info(); + print_heap_and_isr_stack_info(); wifi_data_msg_t *wifiData = _aT2WiFiDatamPool->alloc(); wifiData->wifi_cmd = data_req.wifi_cmd; wifiData->dataLen = data_req.dataLen; @@ -917,15 +927,29 @@ bool ATCmdManager::dequeueWiFidataResponse(){ if(at_resp != AT_RESP_NONE) return false; // busy + //print_memory_info(); osEvent evt = _wiFi2ATDataQueue->get(0); if(evt.status == osEventMessage){ resp_data = (at_data_msg_t*)evt.value.p; setNextResponse(resp_data->at_resp); //_wiFi2ATDatamPool->free(resp_data); + print_heap_and_isr_stack_info(); } return true; } + +void ATCmdManager::sendAtConfirmation(const char *buf) +{ + int len = strlen(buf); + outputEDMdata((const uint8_t *) buf, len, AT_MSG_ID, CONFIRMATION_MSG_TYPE, NO_CHANNEL); +} +void ATCmdManager::sendAtEvent(const char *buf) +{ + int len = strlen(buf); + outputEDMdata((const uint8_t *) buf, len, AT_MSG_ID, EVENT_MSG_TYPE, NO_CHANNEL); +} + void ATCmdManager::outputEDMdata(const uint8_t *buf, int pLen, edm_msg_id_t identifier, edm_msg_type_t type, channel_id_t channel_id) @@ -940,8 +964,9 @@ // send EDM Identifier + Type _parser.putc(identifier>>8); _parser.putc(identifier%256 | type); - // send EDM Identifier + Type - _parser.putc(channel_id); + // send channel id if valid + if(channel_id != NO_CHANNEL) + _parser.putc(channel_id); // send the data _parser.write((const char *)buf, pLen); // send EDM Message stop byte @@ -967,5 +992,6 @@ _smutex.unlock(); _wiFi2ATDatamPool->free(resp_data); - + //print_memory_info(); + print_heap_and_isr_stack_info(); }