Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor10144391014439 Creating Wireless Ad Hoc Access Point Anchor10146371014637Some applications may need to create an 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 section C-10-3 “NetIFNetIF_WiFi_CreateAdhoc()” on page 535 for CreateAP for more information. Anchor

10206061020606A call to NetIF_WiFi_CreateAdhoc() is shown below:anchor

Code Block

...

language

...

NET_ERR err;   ap_ctn =
HTML Table
summary
classCode_Listing
Table Row (tr)
Table Cell (td)
Anchor
10190891019089
Anchor
10190901019090
Anchor
10190911019091
cpp

...

                              (1)
                                NET_IF_WIFI_DATA_RATE_AUTO,
(2)
          (2)
                                NET_IF_WIFI_SECURITY_WEP,
(3)
            (3)
                                NET_IF_WIFI_PWR_LEVEL_HI,
(4)
            (4)
                                NET_IF_WIFI_CH_1
(5) “adhoc_ssid”, (6) “adhoc_password”, (7) &err); (8)
titleListing - Call to NetIF_WiFi_CreateAdhoc()
linenumberstrue
NET_ERR         err;

ap_ctn = NetIF_WiFi_CreateAdhoc(if_nbr,
(1)
Anchor
10190921019092
Anchor
10190931019093
Anchor
10190941019094
Anchor
10190951019095
Anchor
10190961019096
Anchor
10190971019097
Anchor
10190981019098

...

                     (5)
                               "adhoc_ssid",                         (6)
                               "adhoc_password",                     (7)
                               &err);                                (8)


Panel
bgColor#f0f0f0
  1. NetIF_WiFi_CreateAdhoc()

...

  1. requires eight arguments. The first argument is the interface number, which is acquired upon

...

  1. successfully adding and starting the interface.

...

  1. The second argument is the data rate used on the wireless network.

...

...

  1. The third argument is the wireless security type of the wireless network.

...

...

  1. The fourth argument is the radio power level

...

  1. used to communicate on the wireless network.

...

  1. The fifth argument is the wireless channel for the ad hoc network.

...

...

  1. The sixth argument is a pointer to a string that contains the SSID of the wireless access point.

...

  1. The seventh argument is a pointer to a string that contains the pre-shared key of the wireless access point.

...

  1. The last argument is a pointer to a NET_ERR

...

  1. 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().