1.4.3.13 SYS_WIFI_CtrlMsg Function
C
SYS_WIFI_RESULT SYS_WIFI_CtrlMsg ( SYS_MODULE_OBJ object, uint32_t event, void *buffer, uint32_t length )
Summary
Returns success/ failure for the connect/disconnect/scan operation asked by client.
Description
This function is used to make control message request (connect,disconnect,scan,register callback) to Wi-Fi system service.
Precondition
The SYS_WIFI_Initialize function should have been called before calling this function.
Parameters
Param | Description |
---|---|
object | SYS WIFI object handle, returned from SYS_WIFI_Initialize |
event | A event value, event can be any of SYS_WIFI_CTRLMSG types |
buffer | Control message data input. |
length | size of buffer data |
Returns
return SYS_WIFI_RESULT.
Example
Details of SYS_WIFI_CONNECT: SYS_WIFI_CONFIG wifiSrvcConfig; SYS_MODULE_OBJ WiFiServHandle; // Set mode as STA wifiSrvcConfig.mode = SYS_WIFI_STA; // Disable saving wifi configuration wifiSrvcConfig.saveConfig = false; // Set the auth type to SYS_WIFI_WPA2 wifiSrvcConfig.staConfig.authType = SYS_WIFI_WPA2; // Enable all the channels(0) wifiSrvcConfig.staConfig.channel = 0; // Device doesn't wait for user request wifiSrvcConfig.staConfig.autoConnect = 1; // Set SSID memcpy(wifiSrvcConfig.staConfig.ssid, WIFI_DEV_SSID, sizeof(WIFI_DEV_SSID)); // Set PSK memcpy(wifiSrvcConfig.staConfig.psk, WIFI_DEV_PSK, sizeof(WIFI_DEV_PSK)); // sysObj.syswifi return from SYS_WIFI_Initialize() if (SYS_WIFI_OBJ_INVALID != SYS_WIFI_CtrlMsg (sysObj.syswifi, SYS_WIFI_CONNECT, &wifiSrvcConfig, sizeof(SYS_WIFI_CONFIG))) { } Details of SYS_WIFI_GETDRVHANDLE: // Get Wi-Fi Driver handle using control message request. DRV_HANDLE myWifiDrvHandle; if(SYS_WIFI_SUCCESS == SYS_WIFI_CtrlMsg(sysObj.syswifi, SYS_WIFI_GETDRVHANDLE, &myWifiDrvHandle, sizeof(DRV_HANDLE))) { //Received the handle } Details of SYS_WIFI_REGCALLBACK: // Client can register multiple callback.Number of supported // callback registration is a MHC configuration. SYS_WIFI_CtrlMsg(sysObj.syswifi, SYS_WIFI_REGCALLBACK, WiFiServCallback, sizeof(uint8_t *)); Details of SYS_WIFI_GETWIFICONFIG: // Get Wi-Fi Configuration using control message request. // The information of configuration is updated in the wifiSrvcConfig. SYS_WIFI_CONFIG wifiSrvcConfig; if(SYS_WIFI_SUCCESS == SYS_WIFI_CtrlMsg(sysObj.syswifi, SYS_WIFI_GETWIFICONFIG, &wifiSrvcConfig, sizeof(SYS_WIFI_CONFIG))) { //Received the wifiSrvcConfig data } Details of SYS_WIFI_DISCONNECT: //In STA mode, device disconnect request using control message. SYS_WIFI_CtrlMsg(sysObj.syswifi, SYS_WIFI_DISCONNECT, NULL, 0); // In AP mode, How to disconnect connected STA // When STA connect to AP mode,application received the callback(SYS_WIFI_CONNECT) with connect STA IP and MAC address. // User same MAC address for disconnect request. SYS_WIFI_CtrlMsg(sysObj.syswifi, SYS_WIFI_DISCONNECT, macAddr, 6);
Remarks
None