NetBurner 3.0
nbWicedApi.h
Go to the documentation of this file.
1 /*NB_REVISION*/
2 
3 /*NB_COPYRIGHT*/
4 
9 #ifndef __NBWIFIAPI_H
10 #define __NBWIFIAPI_H
11 
12 #include <buffers.h>
13 #include <nettypes.h>
14 #include <nbwifi/nbWifiConstants.h>
15 
16 //Scanning and connecting uses the SAME exact AP deifition.
17 struct APDefinition
18 {
19  char SSID[SSID_MAX_LEN + 1 ];
20  char PassPhrase[PASS_MAX_LEN + 1]; //Should be "" empty string for open networks.
21  MACADR BSSID;//All Zeros ignored on connect.
22  bool bAdhoc;//True if its an or to create an Adhoc network.
23  char Security[SEC_HUMAN_MAX_LEN + 1];//On scan empty string for open on connect empty string for dont care OPEN for forcing open.
24  char Cipher[CIPHER_HUMAN_MAX_LEN + 1];//On Scan indicates the Cipher used with the security, ignored on connect.
25  NBWifi::Constants::RadioBand band;
26  uint16_t Channel;
27  int rssi; //Ignored on connect calls....
28 };
29 
30 
31 #define WIFI_Result_Success (1)
32 #define WIFI_Result_BadPass (-1)
33 #define WIFI_Result_NoAPFound (-2)
34 #define WIFI_Result_BSSID_NotFound (-3)
35 #define WIFI_Result_TimedOut (-4)
36 
37 typedef void ( *ReceiveScanResultFunc )( const APDefinition & ap);
38 
39 class WifiInteface
40 {
41 
42  public:
43 
44  //Connection functions
45  //If all three SSID, BSSID and PassPhrase are empty, connects to strongest open network
46  int Connect(); //Use the SSID and PassPhrase stored in the config record.
47  int Connect(const char * SSID, const char * Pass, bool bAdHoc=false);
48  int Connect(APDefinition & ap);
49  int Connect(APDefinition * pAps); //Connect to the AP deifitions on the list in order of preference.
50 
51  void Disconnect();
52 
53  //Scan Functions:
54 
55  //Syncronous Scan...
56  APDefinition * Scan(const char * ssid=nullptr); //nullptr SSID means scan for all
57  APDefinition * ScanWithSettings(
58  const char * ssid=nullptr,
59  uint8_t channelCount = 0,
60  const uint16_t * channelList = nullptr,
61  uint8_t band = 0,
62  uint8_t infrastructureType = 0);
63  //Returns a pointer to a list of APDefinitions
64  //SSID, nullptr on the last one in the list.
65  //This function is not reentrant and the result is only valid until the Next call to Scan
66 
67  //Asyncronous Scan....
68 
69  //If the underlying WIFI driver has an internally timed scan then the
70  //call back funciton will receive an AP with SSID =nullptr as the last indicator...
71  //Otherwise you shoudl probably call StopAsyncScan
72  int StartAsyncScan(ReceiveScanResultFunc * pCallBackFunc, const char * ssid=nullptr);
73  int StartAsyncScanWithSettings(
74  ReceiveScanResultFunc * pCallBackFunc,
75  const char * ssid=nullptr,
76  uint8_t channelCount = 0,
77  const uint16_t * channelList = nullptr,
78  uint8_t band = 0,
79  uint8_t infrastructureType = 0);
80  //In some implmentaions this may be an empty function....
81  int StopAsyncScan();
82 
83 
84  //Status functions:
85  int GetCurSSID(char * buf, int maxlen);
86  MACADR GetCurBSSID();
87  int GetCurrentAP(APDefinition & ap);
88  bool Connected();
89  int GetSignalStrength();
90 
91 };
92 
93 
94 #endif /* ----- #ifndef __NBWIFIAPI_H ----- */
NetBurner Buffers API.