iowfehu;gdbjwHJAOPIHO?L

Fork of X_NUCLEO_IDW01M1 by ST

Revision:
6:e7a3fca2df10
Parent:
1:bd9db471d47d
Child:
8:0f302a13e21b
--- a/Spwf/wifi_driver.c	Wed May 04 12:16:20 2016 +0000
+++ b/Spwf/wifi_driver.c	Mon May 09 10:38:22 2016 +0000
@@ -185,3 +185,74 @@
   return WiFi_MODULE_SUCCESS;
 }
 
+/**
+* @brief  wifi_socket_server_write
+*         Write to a Server socket
+* @param  None
+* @retval WiFi_Status_t : return status of server socket request
+*/
+WiFi_Status_t wifi_socket_server_write(uint16_t DataLength,char * pData) 
+{
+    WiFi_Status_t status = WiFi_MODULE_SUCCESS;
+    /*Can only write if there is a client connected*/
+    if(!wifi_client_connected)
+    {
+    return WiFi_NOT_READY;
+    }
+     __disable_irq();
+    
+    status_flag.do_not_reset_push_WIFI_event = WIFI_TRUE;
+    status_flag.prevent_push_WIFI_event = WIFI_TRUE;
+    __enable_irq();
+    
+    while(status_flag.sock_read_ongoing || WIND64_count!= 0)//wait till any pending data is read
+    {
+        asm("NOP");
+    }
+    
+    wait_for_command_mode();
+    
+    /*to make sure that by default the mode is not switched to command mode from data mode*/
+    status_flag.switch_by_default_to_command_mode = WIFI_FALSE;
+    
+    /*Switch to Data Mode first*/
+    if(!status_flag.data_mode)
+    {
+    WiFi_switch_to_data_mode();//switch by default
+    while(!status_flag.data_mode)
+    {
+      //Wait till data_mode is active
+        asm("NOP");
+    }
+    }  
+    
+    callSpwfSADevice_write(spwf_dev, (const char *) pData, DataLength);
+    
+    /*Write the data on the uart*/
+    /*if(HAL_UART_Transmit(&UartWiFiHandle, (uint8_t *)pData, DataLength,1000)!= HAL_OK)
+    {
+    Error_Handler();
+    return WiFi_HAL_UART_ERROR;
+    }*/
+    //HAL_Delay(100);//Wait for tx before switching back to command mode
+    
+    /*Switch back to Command Mode*/
+    if(!status_flag.command_mode)
+    {
+    WiFi_switch_to_command_mode();//switch by default
+    while(!status_flag.command_mode)
+    {
+      //Wait till command_mode is active
+        asm("NOP");
+    }
+    }
+    
+    status_flag.switch_by_default_to_command_mode = WIFI_TRUE;  /*back to default behaviour*/
+    
+    __disable_irq();
+    status_flag.prevent_push_WIFI_event = WIFI_FALSE;
+    status_flag.do_not_reset_push_WIFI_event = WIFI_FALSE;
+    __enable_irq();
+    
+    return status;
+}
\ No newline at end of file