![]() |
WINC1500 IoT Software APIs
19.5.2
WINC Software API Reference Manual
|
Functions | |
NMI_API sint8 | m2m_wifi_p2p (uint8 u8Channel) |
Detailed Description
Asynchronous Wi-Fi direct (P2P) enabling mode function. The WINC supports P2P in device listening mode ONLY (intent is ZERO). The WINC P2P implementation does not support P2P GO (Group Owner) mode. Active P2P devices (e.g. phones) could find the WINC in the search list. When a device is connected to WINC, a Wi-Fi notification event M2M_WIFI_RESP_CON_STATE_CHANGED is triggered. After a short while, the DHCP IP Address is obtained and an event M2M_WIFI_REQ_DHCP_CONF is triggered. Refer to the code examples for a more illustrative example.
Function Documentation
◆ m2m_wifi_p2p()
- Parameters
-
[in] u8Channel P2P Listen RF channel. According to the P2P standard It must hold only one of the following values 1, 6 or 11.
- Precondition
- A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at initialization. Registering the callback is done through passing it to the m2m_wifi_init.
- The events M2M_WIFI_RESP_CON_STATE_CHANGED and M2M_WIFI_REQ_DHCP_CONF must be handled in the callback.
- The m2m_wifi_handle_events MUST be called to receive the responses in the callback.
- Warning
- This function is not allowed in AP or STA modes.
- See also
- tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_CON_STATE_CHANGED M2M_WIFI_REQ_DHCP_CONF tstrM2mWifiStateChanged
- Returns
- The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Example
The code snippet shown an example of how the p2p mode operates.
#include "m2m_wifi.h"
#include "m2m_types.h"
{
switch(u8WiFiEvent)
{
{
tstrM2mWifiStateChanged *pstrWifiState = (tstrM2mWifiStateChanged*)pvMsg;
M2M_INFO("Wifi State :: %s :: ErrCode %d\n", pstrWifiState->u8CurrState? "CONNECTED":"DISCONNECTED",pstrWifiState->u8ErrCode);
// Do something
}
break;
case M2M_WIFI_REQ_DHCP_CONF:
{
printf("P2P IP Address \"%u.%u.%u.%u\"\n",pu8IPAddress[0],pu8IPAddress[1],pu8IPAddress[2],pu8IPAddress[3]);
}
break;
default:
break;
}
}
int main()
{
tstrWifiInitParam param;
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(¶m))
{
// Trigger P2P
while(1)
{
}
}
}
Generated on Thu Jan 26 2017 22:15:21 for WINC1500 IoT Software APIs by
