Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Some applications may need to create a wireless ad hoc access point that can be accessed by other devices. Wireless ad hoc access points can be created by calling the NetIF_WiFi_CreateAdhoc() API function with the necessary parameters. See NetIF_WiFi_CreateAP  for more information.

A call to NetIF_WiFi_CreateAdhoc() is shown below:

Listing - Listing - Call to NetIF_WiFi_CreateAdhoc()
NET_ERR         err;

ap_ctn = NetIF_WiFi_CreateAdhoc(if_nbr,                              (1)
                                NET_IF_WIFI_DATA_RATE_AUTO,          (2)
                                NET_IF_WIFI_SECURITY_WEP,            (3)
                                NET_IF_WIFI_PWR_LEVEL_HI,            (4)
                                NET_IF_WIFI_CH_1                     (5)
                               "adhoc_ssid",                         (6)
                               "adhoc_password",                     (7)
                               &err);                                (8)
  1. NetIF_WiFi_CreateAdhoc() requires height arguments. The first argument is the interface number, which is acquired upon successfully adding and starting the interface.
  2. The second argument is the data rate used on the wireless network.
  3. The third argument is the wireless security type of the wireless network.
  4. The fourth argument is the radio power level used to communicate on the wireless network.
  5. The fifth argument is the wireless channel for the ad hoc network.
  6. The sixth argument is a pointer to a string that contains the SSID of the wireless access point.
  7. The seventh argument is a pointer to a string that contains the pre-shared key of the wireless access point.
  8. The last argument is a pointer to a NET_ERR that contains the return error code. The return error variable will contain the value NET_IF_WIFI_ERR_NONE if the create process has been completed successfully.

If an error occurs, you should always inspect the return error code and take the appropriate action. There are very few things that could cause a failure to create an ad hoc network properly. Once the error is resolved, the application may again attempt to call NetIF_WiFi_CreateAdhoc().

  • No labels