3
3
4
4
/* -------------------------------------------------------------------------- */
5
5
CWifi::CWifi () : _timeout(50000 ){
6
+ mak[0 ] = 0 ;
7
+ mak[1 ] = 0 ;
8
+ mak[2 ] = 0 ;
9
+ mak[3 ] = 0 ;
10
+ mak[4 ] = 0 ;
11
+ mak[5 ] = 0 ;
6
12
}
7
13
/* -------------------------------------------------------------------------- */
8
14
@@ -186,11 +192,6 @@ void CWifi::end(void) {
186
192
187
193
}
188
194
189
- /* -------------------------------------------------------------------------- */
190
- uint8_t * CWifi::macAddress (uint8_t * mac) {
191
- /* -------------------------------------------------------------------------- */
192
- return 0 ;
193
- }
194
195
195
196
static bool macStr2macArray (uint8_t *mac_out, const char *mac_in) {
196
197
if (mac_in[2 ] != ' :' ||
@@ -210,6 +211,37 @@ static bool macStr2macArray(uint8_t *mac_out, const char *mac_in) {
210
211
}
211
212
212
213
214
+ /* -------------------------------------------------------------------------- */
215
+ uint8_t * CWifi::macAddress (uint8_t * mac) {
216
+ /* -------------------------------------------------------------------------- */
217
+ string res = " " ;
218
+ modem.begin ();
219
+ if (modem.write (string (PROMPT (_MODE)),res, " %s" , CMD_READ (_MODE))) {
220
+ if (atoi (res.c_str ()) == 1 ) {
221
+ if (modem.write (string (PROMPT (_MACSTA)),res, " %s" , CMD_READ (_MACSTA))) {
222
+ macStr2macArray (mac, res.c_str ());
223
+ return mac;
224
+ }
225
+ }
226
+ else if (atoi (res.c_str ()) == 2 ) {
227
+ if (modem.write (string (PROMPT (_MACSOFTAP)),res, " %s" , CMD_READ (_MACSOFTAP))) {
228
+ macStr2macArray (mac, res.c_str ());
229
+ return mac;
230
+ }
231
+ }
232
+ }
233
+
234
+ for (int i = 0 ; i < 6 ; i++)
235
+ {
236
+ mac[i] = mak[i];
237
+ }
238
+
239
+ return mac;
240
+ }
241
+
242
+
243
+
244
+
213
245
/* -------------------------------------------------------------------------- */
214
246
int8_t CWifi::scanNetworks () {
215
247
/* -------------------------------------------------------------------------- */
@@ -355,9 +387,6 @@ static uint8_t Encr2wl_enc(string e) {
355
387
}
356
388
}
357
389
358
-
359
-
360
-
361
390
/* -------------------------------------------------------------------------- */
362
391
uint8_t CWifi::encryptionType (uint8_t networkItem) {
363
392
if (networkItem < access_points.size ()) {
@@ -367,10 +396,6 @@ uint8_t CWifi::encryptionType(uint8_t networkItem) {
367
396
}
368
397
/* -------------------------------------------------------------------------- */
369
398
370
-
371
-
372
-
373
-
374
399
/* -------------------------------------------------------------------------- */
375
400
uint8_t * CWifi::BSSID (uint8_t networkItem, uint8_t * bssid) {
376
401
if (networkItem < access_points.size ()) {
0 commit comments