Extending the X_NUCLEO_IDW01M1 to allow configuration of the board as an access point
Dependents: X_NUCLEO_IDW01M1_AP_Test
Fork of X_NUCLEO_IDW01M1 by
Diff: Spwf/wifi_module.c
- Revision:
- 5:c83ffd44f40a
- Parent:
- 1:bd9db471d47d
- Child:
- 7:0fdd186a7d90
--- a/Spwf/wifi_module.c Tue Apr 19 07:42:22 2016 +0000 +++ b/Spwf/wifi_module.c Wed May 04 12:16:20 2016 +0000 @@ -484,41 +484,49 @@ break; case WIFI_CLIENT_SOCKET_OPEN_EVENT: - Reset_AT_CMD_Buffer(); - - /* AT+S.SOCKON = myserver,1234,t <cr> */ - sprintf((char*)WiFi_AT_Cmd_Buff,AT_SOCKET_OPEN,curr_hostname,(int)curr_port_number,curr_protocol); - status = USART_Transmit_AT_Cmd(strlen((char*)WiFi_AT_Cmd_Buff)); - if(status != WiFi_MODULE_SUCCESS) + + if(!open_sockets[event_pop_s->socket_id])//make sure socket is closed { - #if DEBUG_PRINT - printf("\r\n ERROR During Socket Open \r\n"); - #endif - status_flag.AT_Response_Received = WIFI_TRUE; - AT_RESPONSE = WiFi_AT_CMD_RESP_ERROR; + Reset_AT_CMD_Buffer(); + + /* AT+S.SOCKON = myserver,1234,t <cr> */ + sprintf((char*)WiFi_AT_Cmd_Buff,AT_SOCKET_OPEN,curr_hostname,(int)curr_port_number,curr_protocol); + status = USART_Transmit_AT_Cmd(strlen((char*)WiFi_AT_Cmd_Buff)); + if(status != WiFi_MODULE_SUCCESS) + { + #if DEBUG_PRINT + printf("\r\n ERROR During Socket Open \r\n"); + #endif + status_flag.AT_Response_Received = WIFI_TRUE; + AT_RESPONSE = WiFi_AT_CMD_RESP_ERROR; + } } break; case WIFI_CLIENT_SOCKET_CLOSE_EVENT: - Reset_AT_CMD_Buffer(); - - /* AT+S.SOCKC=00<cr> */ - sprintf((char*)WiFi_AT_Cmd_Buff,AT_SOCKET_CLOSE,event_pop_s->socket_id); - status = USART_Transmit_AT_Cmd(strlen((char*)WiFi_AT_Cmd_Buff)); - if(status == WiFi_MODULE_SUCCESS) + + if(open_sockets[event_pop_s->socket_id])//make sure socket is open { - AT_RESPONSE = WiFi_MODULE_SUCCESS; - status_flag.prevent_push_OK_event = WIFI_TRUE; //prevent the OK received after socket close command to be Q'ed - status_flag.stop_event_dequeue = WIFI_TRUE; - remote_socket_closed_id = event_pop_s->socket_id; - status_flag.client_socket_close_ongoing = WIFI_TRUE; //used for making changes in the value of open_sockets[sock_id] if no error is returned -// status_flag.SockON_Server_Closed_Callback = WIFI_TRUE; - } - else - { - #if DEBUG_PRINT - printf("\r\n ERROR During Socket Close \r\n"); - #endif + Reset_AT_CMD_Buffer(); + + /* AT+S.SOCKC=00<cr> */ + sprintf((char*)WiFi_AT_Cmd_Buff,AT_SOCKET_CLOSE,event_pop_s->socket_id); + status = USART_Transmit_AT_Cmd(strlen((char*)WiFi_AT_Cmd_Buff)); + if(status == WiFi_MODULE_SUCCESS) + { + AT_RESPONSE = WiFi_MODULE_SUCCESS; + status_flag.prevent_push_OK_event = WIFI_TRUE; //prevent the OK received after socket close command to be Q'ed + status_flag.stop_event_dequeue = WIFI_TRUE; + remote_socket_closed_id = event_pop_s->socket_id; + status_flag.client_socket_close_ongoing = WIFI_TRUE; //used for making changes in the value of open_sockets[sock_id] if no error is returned + // status_flag.SockON_Server_Closed_Callback = WIFI_TRUE; + } + else + { + #if DEBUG_PRINT + printf("\r\n ERROR During Socket Close \r\n"); + #endif + } } break;