After about one full hour or sometimes two of continuous cloud writes the following line fails :
WiFi_Status_t wifi_socket_client_write(uint8_t sock_id, uint16_t DataLength, char * pData)
/* AT+S.SOCKW=00,11<cr> */
WiFi_Status_t status = WiFi_MODULE_SUCCESS;
//Check if sock_id is open
if(DataLength>=1021 || DataLength<=0)
status = USART_Receive_AT_Resp( );
I don't mean any disrespect, but most of the wait events testing for io completion should have an escape clause...This is very bad programming practice to hang the socket or the WIFI Reset and many other such layers waiting for commands to arrive or complete an action! I would honestly even go as far as saying most of the code is a disaster waiting to happen...I have gone quite far enough to make sure that the code does not hang during socket recovery or socket hangs and even wifi disconnects. But lines such as the ones below are death-traps waiting to happen!
void Queue_Client_Write_Event(uint8_t sock_id, uint16_t DataLength, char * pData)
WiFi_Counter_Variables.curr_DataLength = DataLength;
WiFi_Counter_Variables.curr_data = pData;
WiFi_Counter_Variables.curr_sockID = sock_id;
wifi_instances.wifi_event.event = WIFI_CLIENT_SOCKET_WRITE_EVENT;
* @brief Wait_For_Sock_Read_To_Complete
* Wait till sock read is over and the OK of read arrives
* @param None
* @retval None
//wait if read is ongoing or read OK is yet to arrive
while(IO_status_flag.sock_read_ongoing == WIFI_TRUE ||
(IO_status_flag.prevent_push_OK_event == WIFI_TRUE && IO_status_flag.client_socket_close_ongoing != WIFI_TRUE)) // to make sure the prevent_push_OK_event is of socket read and not of socket close.
__NOP(); //nothing to do <- Death Trap! This will hang here FOREVER...
How can I make this code production ready for hardware devices to cloud propagation when such things exist all over the place ? We need timeout elements in all such blocking code!
Any idea why these happen and have not been fixed ?