Select one of the symbols to view example projects that use it.
 
Outline
#define __ESP_WIFI_H__
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_wifi_types.h"
#include "esp_event.h"
#include "esp_wifi_crypto_types.h"
#include "esp_wifi_default.h"
#define ESP_ERR_WIFI_NOT_INIT
#define ESP_ERR_WIFI_NOT_STARTED
#define ESP_ERR_WIFI_NOT_STOPPED
#define ESP_ERR_WIFI_IF
#define ESP_ERR_WIFI_MODE
#define ESP_ERR_WIFI_STATE
#define ESP_ERR_WIFI_CONN
#define ESP_ERR_WIFI_NVS
#define ESP_ERR_WIFI_MAC
#define ESP_ERR_WIFI_SSID
#define ESP_ERR_WIFI_PASSWORD
#define ESP_ERR_WIFI_TIMEOUT
#define ESP_ERR_WIFI_WAKE_FAIL
#define ESP_ERR_WIFI_WOULD_BLOCK
#define ESP_ERR_WIFI_NOT_CONNECT
#define ESP_ERR_WIFI_POST
#define ESP_ERR_WIFI_INIT_STATE
#define ESP_ERR_WIFI_STOP_STATE
#define ESP_ERR_WIFI_NOT_ASSOC
#define ESP_ERR_WIFI_TX_DISALLOW
#define ESP_ERR_WIFI_TWT_FULL
#define ESP_ERR_WIFI_TWT_SETUP_TIMEOUT
#define ESP_ERR_WIFI_TWT_SETUP_TXFAIL
#define ESP_ERR_WIFI_TWT_SETUP_REJECT
#define ESP_ERR_WIFI_DISCARD
#define ESP_ERR_WIFI_ROC_IN_PROGRESS
wifi_osi_funcs_t
wifi_init_config_t
#define WIFI_STATIC_TX_BUFFER_NUM
#define WIFI_STATIC_TX_BUFFER_NUM
#define WIFI_CACHE_TX_BUFFER_NUM
#define WIFI_CACHE_TX_BUFFER_NUM
#define WIFI_DYNAMIC_TX_BUFFER_NUM
#define WIFI_DYNAMIC_TX_BUFFER_NUM
#define WIFI_RX_MGMT_BUF_NUM_DEF
#define WIFI_RX_MGMT_BUF_NUM_DEF
#define WIFI_CSI_ENABLED
#define WIFI_CSI_ENABLED
#define WIFI_AMPDU_RX_ENABLED
#define WIFI_AMPDU_RX_ENABLED
#define WIFI_AMPDU_TX_ENABLED
#define WIFI_AMPDU_TX_ENABLED
#define WIFI_AMSDU_TX_ENABLED
#define WIFI_AMSDU_TX_ENABLED
#define WIFI_NVS_ENABLED
#define WIFI_NVS_ENABLED
#define WIFI_NANO_FORMAT_ENABLED
#define WIFI_NANO_FORMAT_ENABLED
g_wifi_default_wpa_crypto_funcs;
g_wifi_osi_funcs;
#define WIFI_INIT_CONFIG_MAGIC
#define WIFI_DEFAULT_RX_BA_WIN
#define WIFI_DEFAULT_RX_BA_WIN
#define WIFI_TASK_CORE_ID
#define WIFI_TASK_CORE_ID
#define WIFI_SOFTAP_BEACON_MAX_LEN
#define WIFI_SOFTAP_BEACON_MAX_LEN
#define WIFI_MGMT_SBUF_NUM
#define WIFI_MGMT_SBUF_NUM
#define WIFI_STA_DISCONNECTED_PM_ENABLED
#define WIFI_STA_DISCONNECTED_PM_ENABLED
#define WIFI_ENABLE_WPA3_SAE
#define WIFI_ENABLE_WPA3_SAE
#define WIFI_ENABLE_CACHE_TX_BUFFER
#define WIFI_ENABLE_CACHE_TX_BUFFER
#define WIFI_FTM_INITIATOR
#define WIFI_FTM_INITIATOR
#define WIFI_FTM_RESPONDER
#define WIFI_FTM_RESPONDER
#define WIFI_ENABLE_GCMP
#define WIFI_ENABLE_GCMP
#define WIFI_ENABLE_GMAC
#define WIFI_ENABLE_GMAC
#define WIFI_ENABLE_11R
#define WIFI_ENABLE_11R
#define WIFI_ENABLE_ENTERPRISE
#define WIFI_ENABLE_ENTERPRISE
#define WIFI_DUMP_HESIGB_ENABLED
#define WIFI_DUMP_HESIGB_ENABLED
#define WIFI_TX_HETB_QUEUE_NUM
#define WIFI_TX_HETB_QUEUE_NUM
#define CONFIG_FEATURE_WPA3_SAE_BIT
#define CONFIG_FEATURE_CACHE_TX_BUF_BIT
#define CONFIG_FEATURE_FTM_INITIATOR_BIT
#define CONFIG_FEATURE_FTM_RESPONDER_BIT
#define CONFIG_FEATURE_GCMP_BIT
#define CONFIG_FEATURE_GMAC_BIT
#define CONFIG_FEATURE_11R_BIT
#define CONFIG_FEATURE_WIFI_ENT_BIT
esp_wifi_init(const wifi_init_config_t *);
esp_wifi_deinit();
esp_wifi_set_mode(wifi_mode_t);
esp_wifi_get_mode(wifi_mode_t *);
esp_wifi_start();
esp_wifi_stop();
esp_wifi_restore();
esp_wifi_connect();
esp_wifi_disconnect();
esp_wifi_clear_fast_connect();
esp_wifi_deauth_sta(uint16_t);
esp_wifi_scan_start(const wifi_scan_config_t *, bool);
esp_wifi_set_scan_parameters(const wifi_scan_default_params_t *);
esp_wifi_get_scan_parameters(wifi_scan_default_params_t *);
esp_wifi_scan_stop();
esp_wifi_scan_get_ap_num(uint16_t *);
esp_wifi_scan_get_ap_records(uint16_t *, wifi_ap_record_t *);
esp_wifi_scan_get_ap_record(wifi_ap_record_t *);
esp_wifi_clear_ap_list();
esp_wifi_sta_get_ap_info(wifi_ap_record_t *);
esp_wifi_set_ps(wifi_ps_type_t);
esp_wifi_get_ps(wifi_ps_type_t *);
esp_wifi_set_protocol(wifi_interface_t, uint8_t);
esp_wifi_get_protocol(wifi_interface_t, uint8_t *);
esp_wifi_set_bandwidth(wifi_interface_t, wifi_bandwidth_t);
esp_wifi_get_bandwidth(wifi_interface_t, wifi_bandwidth_t *);
esp_wifi_set_channel(uint8_t, wifi_second_chan_t);
esp_wifi_get_channel(uint8_t *, wifi_second_chan_t *);
esp_wifi_set_country(const wifi_country_t *);
esp_wifi_get_country(wifi_country_t *);
esp_wifi_set_mac(wifi_interface_t, const uint8_t *);
esp_wifi_get_mac(wifi_interface_t, uint8_t *);
wifi_promiscuous_cb_t
esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t);
esp_wifi_set_promiscuous(bool);
esp_wifi_get_promiscuous(bool *);
esp_wifi_set_promiscuous_filter(const wifi_promiscuous_filter_t *);
esp_wifi_get_promiscuous_filter(wifi_promiscuous_filter_t *);
esp_wifi_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *);
esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *);
esp_wifi_set_config(wifi_interface_t, wifi_config_t *);
esp_wifi_get_config(wifi_interface_t, wifi_config_t *);
wifi_sta_list_t
esp_wifi_ap_get_sta_list(wifi_sta_list_t *);
esp_wifi_ap_get_sta_aid(const uint8_t *, uint16_t *);
esp_wifi_set_storage(wifi_storage_t);
esp_vendor_ie_cb_t
esp_wifi_set_vendor_ie(bool, wifi_vendor_ie_type_t, wifi_vendor_ie_id_t, const void *);
esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t, void *);
esp_wifi_set_max_tx_power(int8_t);
esp_wifi_get_max_tx_power(int8_t *);
esp_wifi_set_event_mask(uint32_t);
esp_wifi_get_event_mask(uint32_t *);
esp_wifi_80211_tx(wifi_interface_t, const void *, int, bool);
wifi_csi_cb_t
esp_wifi_set_csi_rx_cb(wifi_csi_cb_t, void *);
esp_wifi_set_csi_config(const wifi_csi_config_t *);
esp_wifi_get_csi_config(wifi_csi_config_t *);
esp_wifi_set_csi(bool);
esp_wifi_set_ant_gpio(const wifi_ant_gpio_config_t *);
esp_wifi_get_ant_gpio(wifi_ant_gpio_config_t *);
esp_wifi_set_ant(const wifi_ant_config_t *);
esp_wifi_get_ant(wifi_ant_config_t *);
esp_wifi_get_tsf_time(wifi_interface_t);
esp_wifi_set_inactive_time(wifi_interface_t, uint16_t);
esp_wifi_get_inactive_time(wifi_interface_t, uint16_t *);
esp_wifi_statis_dump(uint32_t);
esp_wifi_set_rssi_threshold(int32_t);
esp_wifi_ftm_initiate_session(wifi_ftm_initiator_cfg_t *);
esp_wifi_ftm_end_session();
esp_wifi_ftm_resp_set_offset(int16_t);
esp_wifi_ftm_get_report(wifi_ftm_report_entry_t *, uint8_t);
esp_wifi_config_11b_rate(wifi_interface_t, bool);
#define ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE
esp_wifi_connectionless_module_set_wake_interval(uint16_t);
esp_wifi_force_wakeup_acquire();
esp_wifi_force_wakeup_release();
esp_wifi_set_country_code(const char *, bool);
esp_wifi_get_country_code(char *);
esp_wifi_config_80211_tx_rate(wifi_interface_t, wifi_phy_rate_t);
esp_wifi_config_80211_tx(wifi_interface_t, wifi_tx_rate_config_t *);
esp_wifi_disable_pmf_config(wifi_interface_t);
esp_wifi_sta_get_aid(uint16_t *);
esp_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *);
esp_wifi_set_dynamic_cs(bool);
esp_wifi_sta_get_rssi(int *);
esp_wifi_set_band(wifi_band_t);
esp_wifi_get_band(wifi_band_t *);
esp_wifi_set_band_mode(wifi_band_mode_t);
esp_wifi_get_band_mode(wifi_band_mode_t *);
esp_wifi_set_protocols(wifi_interface_t, wifi_protocols_t *);
esp_wifi_get_protocols(wifi_interface_t, wifi_protocols_t *);
esp_wifi_set_bandwidths(wifi_interface_t, wifi_bandwidths_t *);
esp_wifi_get_bandwidths(wifi_interface_t, wifi_bandwidths_t *);
Files
loading...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/esp_wifi/include/esp_wifi.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ /* Notes about WiFi Programming * * WiFi programming model can be depicted as following picture: * * * default handler user handler * ------------- --------------- --------------- * | | event | | callback or | | * | tcpip | ---------> | event | ----------> | application | * | stack | | task | event | task | * |-----------| |-------------| |-------------| * /|\ | * | | * event | | * | | * | | * --------------- | * | | | * | WiFi Driver |/__________________| * | |\ API call * | | * |-------------| * * The WiFi driver can be consider as black box, it knows nothing about the high layer code, such as * TCPIP stack, application task, event task etc, all it can do is to receive API call from high layer * or post event queue to a specified Queue, which is initialized by API esp_wifi_init(). * * The event task is a daemon task, which receives events from WiFi driver or from other subsystem, such * as TCPIP stack, event task will call the default callback function on receiving the event. For example, * on receiving event WIFI_EVENT_STA_CONNECTED, it will call esp_netif API to start the DHCP * client in it's default handler. * * Application can register it's own event callback function by API esp_event_init, then the application callback * function will be called after the default callback. Also, if application doesn't want to execute the callback * in the event task, what it needs to do is to post the related event to application task in the application callback function. * * The application task (code) generally mixes all these thing together, it calls APIs to init the system/WiFi and * handle the events when necessary. * *//* ... */ #ifndef __ESP_WIFI_H__ #define __ESP_WIFI_H__ #include <stdint.h> #include <stdbool.h> #include "esp_err.h" #include "esp_wifi_types.h" #include "esp_event.h" #include "esp_wifi_crypto_types.h" #include "esp_wifi_default.h"7 includes #ifdef __cplusplus extern "C" { #endif #define ESP_ERR_WIFI_NOT_INIT (ESP_ERR_WIFI_BASE + 1) /*!< WiFi driver was not installed by esp_wifi_init */ #define ESP_ERR_WIFI_NOT_STARTED (ESP_ERR_WIFI_BASE + 2) /*!< WiFi driver was not started by esp_wifi_start */ #define ESP_ERR_WIFI_NOT_STOPPED (ESP_ERR_WIFI_BASE + 3) /*!< WiFi driver was not stopped by esp_wifi_stop */ #define ESP_ERR_WIFI_IF (ESP_ERR_WIFI_BASE + 4) /*!< WiFi interface error */ #define ESP_ERR_WIFI_MODE (ESP_ERR_WIFI_BASE + 5) /*!< WiFi mode error */ #define ESP_ERR_WIFI_STATE (ESP_ERR_WIFI_BASE + 6) /*!< WiFi internal state error */ #define ESP_ERR_WIFI_CONN (ESP_ERR_WIFI_BASE + 7) /*!< WiFi internal control block of station or soft-AP error */ #define ESP_ERR_WIFI_NVS (ESP_ERR_WIFI_BASE + 8) /*!< WiFi internal NVS module error */ #define ESP_ERR_WIFI_MAC (ESP_ERR_WIFI_BASE + 9) /*!< MAC address is invalid */ #define ESP_ERR_WIFI_SSID (ESP_ERR_WIFI_BASE + 10) /*!< SSID is invalid */ #define ESP_ERR_WIFI_PASSWORD (ESP_ERR_WIFI_BASE + 11) /*!< Password is invalid */ #define ESP_ERR_WIFI_TIMEOUT (ESP_ERR_WIFI_BASE + 12) /*!< Timeout error */ #define ESP_ERR_WIFI_WAKE_FAIL (ESP_ERR_WIFI_BASE + 13) /*!< WiFi is in sleep state(RF closed) and wakeup fail */ #define ESP_ERR_WIFI_WOULD_BLOCK (ESP_ERR_WIFI_BASE + 14) /*!< The caller would block */ #define ESP_ERR_WIFI_NOT_CONNECT (ESP_ERR_WIFI_BASE + 15) /*!< Station still in disconnect status */ #define ESP_ERR_WIFI_POST (ESP_ERR_WIFI_BASE + 18) /*!< Failed to post the event to WiFi task */ #define ESP_ERR_WIFI_INIT_STATE (ESP_ERR_WIFI_BASE + 19) /*!< Invalid WiFi state when init/deinit is called */ #define ESP_ERR_WIFI_STOP_STATE (ESP_ERR_WIFI_BASE + 20) /*!< Returned when WiFi is stopping */ #define ESP_ERR_WIFI_NOT_ASSOC (ESP_ERR_WIFI_BASE + 21) /*!< The WiFi connection is not associated */ #define ESP_ERR_WIFI_TX_DISALLOW (ESP_ERR_WIFI_BASE + 22) /*!< The WiFi TX is disallowed */ #define ESP_ERR_WIFI_TWT_FULL (ESP_ERR_WIFI_BASE + 23) /*!< no available flow id */ #define ESP_ERR_WIFI_TWT_SETUP_TIMEOUT (ESP_ERR_WIFI_BASE + 24) /*!< Timeout of receiving twt setup response frame, timeout times can be set during twt setup */ #define ESP_ERR_WIFI_TWT_SETUP_TXFAIL (ESP_ERR_WIFI_BASE + 25) /*!< TWT setup frame tx failed */ #define ESP_ERR_WIFI_TWT_SETUP_REJECT (ESP_ERR_WIFI_BASE + 26) /*!< The twt setup request was rejected by the AP */ #define ESP_ERR_WIFI_DISCARD (ESP_ERR_WIFI_BASE + 27) /*!< Discard frame */ #define ESP_ERR_WIFI_ROC_IN_PROGRESS (ESP_ERR_WIFI_BASE + 28) /*!< ROC op is in progress */26 defines typedef struct wifi_osi_funcs_t wifi_osi_funcs_t; /** * @brief WiFi stack configuration parameters passed to esp_wifi_init call. *//* ... */ typedef struct { wifi_osi_funcs_t* osi_funcs; /**< WiFi OS functions */ wpa_crypto_funcs_t wpa_crypto_funcs; /**< WiFi station crypto functions when connect */ int static_rx_buf_num; /**< WiFi static RX buffer number */ int dynamic_rx_buf_num; /**< WiFi dynamic RX buffer number */ int tx_buf_type; /**< WiFi TX buffer type */ int static_tx_buf_num; /**< WiFi static TX buffer number */ int dynamic_tx_buf_num; /**< WiFi dynamic TX buffer number */ int rx_mgmt_buf_type; /**< WiFi RX MGMT buffer type */ int rx_mgmt_buf_num; /**< WiFi RX MGMT buffer number */ int cache_tx_buf_num; /**< WiFi TX cache buffer number */ int csi_enable; /**< WiFi channel state information enable flag */ int ampdu_rx_enable; /**< WiFi AMPDU RX feature enable flag */ int ampdu_tx_enable; /**< WiFi AMPDU TX feature enable flag */ int amsdu_tx_enable; /**< WiFi AMSDU TX feature enable flag */ int nvs_enable; /**< WiFi NVS flash enable flag */ int nano_enable; /**< Nano option for printf/scan family enable flag */ int rx_ba_win; /**< WiFi Block Ack RX window size */ int wifi_task_core_id; /**< WiFi Task Core ID */ int beacon_max_len; /**< WiFi softAP maximum length of the beacon */ int mgmt_sbuf_num; /**< WiFi management short buffer number, the minimum value is 6, the maximum value is 32 */ uint64_t feature_caps; /**< Enables additional WiFi features and capabilities */ bool sta_disconnected_pm; /**< WiFi Power Management for station at disconnected status */ int espnow_max_encrypt_num; /**< Maximum encrypt number of peers supported by espnow */ int tx_hetb_queue_num; /**< WiFi TX HE TB QUEUE number for STA HE TB PPDU transmission */ bool dump_hesigb_enable; /**< enable dump sigb field */ int magic; /**< WiFi init magic number, it should be the last field */ }{ ... } wifi_init_config_t; #ifdef CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM #define WIFI_STATIC_TX_BUFFER_NUM CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM #else #define WIFI_STATIC_TX_BUFFER_NUM 0 #endif #ifdef CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM #define WIFI_CACHE_TX_BUFFER_NUM CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM #else #define WIFI_CACHE_TX_BUFFER_NUM 0 #endif #ifdef CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM #define WIFI_DYNAMIC_TX_BUFFER_NUM CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM #else #define WIFI_DYNAMIC_TX_BUFFER_NUM 0 #endif #ifdef CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF #define WIFI_RX_MGMT_BUF_NUM_DEF CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF #else #define WIFI_RX_MGMT_BUF_NUM_DEF 0 #endif #if CONFIG_ESP_WIFI_CSI_ENABLED #define WIFI_CSI_ENABLED 1 #else #define WIFI_CSI_ENABLED 0 #endif #if CONFIG_ESP_WIFI_AMPDU_RX_ENABLED #define WIFI_AMPDU_RX_ENABLED 1 #else #define WIFI_AMPDU_RX_ENABLED 0 #endif #if CONFIG_ESP_WIFI_AMPDU_TX_ENABLED #define WIFI_AMPDU_TX_ENABLED 1 #else #define WIFI_AMPDU_TX_ENABLED 0 #endif #if CONFIG_ESP_WIFI_AMSDU_TX_ENABLED #define WIFI_AMSDU_TX_ENABLED 1 #else #define WIFI_AMSDU_TX_ENABLED 0 #endif #if CONFIG_ESP_WIFI_NVS_ENABLED #define WIFI_NVS_ENABLED 1 #else #define WIFI_NVS_ENABLED 0 #endif #if CONFIG_NEWLIB_NANO_FORMAT #define WIFI_NANO_FORMAT_ENABLED 1 #else #define WIFI_NANO_FORMAT_ENABLED 0 #endif extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; extern wifi_osi_funcs_t g_wifi_osi_funcs; #define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F #ifdef CONFIG_ESP_WIFI_AMPDU_RX_ENABLED #define WIFI_DEFAULT_RX_BA_WIN CONFIG_ESP_WIFI_RX_BA_WIN #else #define WIFI_DEFAULT_RX_BA_WIN 0 /* unused if ampdu_rx_enable == false */ #endif #if CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_1 #define WIFI_TASK_CORE_ID 1 #else #define WIFI_TASK_CORE_ID 0 #endif #ifdef CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN #define WIFI_SOFTAP_BEACON_MAX_LEN CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN #else #define WIFI_SOFTAP_BEACON_MAX_LEN 752 #endif #ifdef CONFIG_ESP_WIFI_MGMT_SBUF_NUM #define WIFI_MGMT_SBUF_NUM CONFIG_ESP_WIFI_MGMT_SBUF_NUM #else #define WIFI_MGMT_SBUF_NUM 32 #endif #if CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE #define WIFI_STA_DISCONNECTED_PM_ENABLED true #else #define WIFI_STA_DISCONNECTED_PM_ENABLED false #endif #if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE #define WIFI_ENABLE_WPA3_SAE (1<<0) #else #define WIFI_ENABLE_WPA3_SAE 0 #endif #if WIFI_CACHE_TX_BUFFER_NUM > 0 #define WIFI_ENABLE_CACHE_TX_BUFFER (1<<1) #else #define WIFI_ENABLE_CACHE_TX_BUFFER 0 #endif #if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT #define WIFI_FTM_INITIATOR (1<<2) #else #define WIFI_FTM_INITIATOR 0 #endif #if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT #define WIFI_FTM_RESPONDER (1<<3) #else #define WIFI_FTM_RESPONDER 0 #endif #if CONFIG_ESP_WIFI_GCMP_SUPPORT #define WIFI_ENABLE_GCMP (1<<4) #else #define WIFI_ENABLE_GCMP 0 #endif #if CONFIG_ESP_WIFI_GMAC_SUPPORT #define WIFI_ENABLE_GMAC (1<<5) #else #define WIFI_ENABLE_GMAC 0 #endif #if CONFIG_ESP_WIFI_11R_SUPPORT #define WIFI_ENABLE_11R (1<<6) #else #define WIFI_ENABLE_11R 0 #endif #if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT #define WIFI_ENABLE_ENTERPRISE (1<<7) #else #define WIFI_ENABLE_ENTERPRISE 0 #endif #if CONFIG_ESP_WIFI_ENABLE_DUMP_HESIGB && !WIFI_CSI_ENABLED #define WIFI_DUMP_HESIGB_ENABLED true #else #define WIFI_DUMP_HESIGB_ENABLED false #endif #if CONFIG_ESP_WIFI_TX_HETB_QUEUE_NUM #define WIFI_TX_HETB_QUEUE_NUM CONFIG_ESP_WIFI_TX_HETB_QUEUE_NUM #else #define WIFI_TX_HETB_QUEUE_NUM 1 #endif #define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0) #define CONFIG_FEATURE_CACHE_TX_BUF_BIT (1<<1) #define CONFIG_FEATURE_FTM_INITIATOR_BIT (1<<2) #define CONFIG_FEATURE_FTM_RESPONDER_BIT (1<<3) #define CONFIG_FEATURE_GCMP_BIT (1<<4) #define CONFIG_FEATURE_GMAC_BIT (1<<5) #define CONFIG_FEATURE_11R_BIT (1<<6) #define CONFIG_FEATURE_WIFI_ENT_BIT (1<<7) /* Set additional WiFi features and capabilities */ #define WIFI_FEATURE_CAPS (WIFI_ENABLE_WPA3_SAE | \ WIFI_ENABLE_CACHE_TX_BUFFER | \ WIFI_FTM_INITIATOR | \ WIFI_FTM_RESPONDER | \ WIFI_ENABLE_GCMP | \ WIFI_ENABLE_GMAC | \ WIFI_ENABLE_11R | \ WIFI_ENABLE_ENTERPRISE)... #define WIFI_INIT_CONFIG_DEFAULT() { \ .osi_funcs = &g_wifi_osi_funcs, \ .wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \ .static_rx_buf_num = CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM,\ .dynamic_rx_buf_num = CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM,\ .tx_buf_type = CONFIG_ESP_WIFI_TX_BUFFER_TYPE,\ .static_tx_buf_num = WIFI_STATIC_TX_BUFFER_NUM,\ .dynamic_tx_buf_num = WIFI_DYNAMIC_TX_BUFFER_NUM,\ .rx_mgmt_buf_type = CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF,\ .rx_mgmt_buf_num = WIFI_RX_MGMT_BUF_NUM_DEF,\ .cache_tx_buf_num = WIFI_CACHE_TX_BUFFER_NUM,\ .csi_enable = WIFI_CSI_ENABLED,\ .ampdu_rx_enable = WIFI_AMPDU_RX_ENABLED,\ .ampdu_tx_enable = WIFI_AMPDU_TX_ENABLED,\ .amsdu_tx_enable = WIFI_AMSDU_TX_ENABLED,\ .nvs_enable = WIFI_NVS_ENABLED,\ .nano_enable = WIFI_NANO_FORMAT_ENABLED,\ .rx_ba_win = WIFI_DEFAULT_RX_BA_WIN,\ .wifi_task_core_id = WIFI_TASK_CORE_ID,\ .beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN, \ .mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, \ .feature_caps = WIFI_FEATURE_CAPS, \ .sta_disconnected_pm = WIFI_STA_DISCONNECTED_PM_ENABLED, \ .espnow_max_encrypt_num = CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM, \ .tx_hetb_queue_num = WIFI_TX_HETB_QUEUE_NUM, \ .dump_hesigb_enable = WIFI_DUMP_HESIGB_ENABLED, \ .magic = WIFI_INIT_CONFIG_MAGIC\ }{...} 10 defines /** * @brief Initialize WiFi * Allocate resource for WiFi driver, such as WiFi control structure, RX/TX buffer, * WiFi NVS structure etc. This WiFi also starts WiFi task * * @attention 1. This API must be called before all other WiFi API can be called * @attention 2. Always use WIFI_INIT_CONFIG_DEFAULT macro to initialize the configuration to default values, this can * guarantee all the fields get correct value when more fields are added into wifi_init_config_t * in future release. If you want to set your own initial values, overwrite the default values * which are set by WIFI_INIT_CONFIG_DEFAULT. Please be notified that the field 'magic' of * wifi_init_config_t should always be WIFI_INIT_CONFIG_MAGIC! * * @param config pointer to WiFi initialized configuration structure; can point to a temporary variable. * * @return * - ESP_OK: succeed * - ESP_ERR_NO_MEM: out of memory * - others: refer to error code esp_err.h *//* ... */ esp_err_t esp_wifi_init(const wifi_init_config_t *config); /** * @brief Deinit WiFi * Free all resource allocated in esp_wifi_init and stop WiFi task * * @attention 1. This API should be called if you want to remove WiFi driver from the system * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_deinit(void); /** * @brief Set the WiFi operating mode * * Set the WiFi operating mode as station, soft-AP, station+soft-AP or NAN. * The default mode is station mode. * * @param mode WiFi operating mode * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument * - others: refer to error code in esp_err.h *//* ... */ esp_err_t esp_wifi_set_mode(wifi_mode_t mode); /** * @brief Get current operating mode of WiFi * * @param[out] mode store current WiFi mode * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_mode(wifi_mode_t *mode); /** * @brief Start WiFi according to current configuration * If mode is WIFI_MODE_STA, it creates station control block and starts station * If mode is WIFI_MODE_AP, it creates soft-AP control block and starts soft-AP * If mode is WIFI_MODE_APSTA, it creates soft-AP and station control block and starts soft-AP and station * If mode is WIFI_MODE_NAN, it creates NAN control block and starts NAN * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: It doesn't normally happen, the function called inside the API was passed invalid argument, user should check if the WiFi related config is correct * - ESP_ERR_NO_MEM: out of memory * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong * - ESP_FAIL: other WiFi internal errors *//* ... */ esp_err_t esp_wifi_start(void); /** * @brief Stop WiFi * If mode is WIFI_MODE_STA, it stops station and frees station control block * If mode is WIFI_MODE_AP, it stops soft-AP and frees soft-AP control block * If mode is WIFI_MODE_APSTA, it stops station/soft-AP and frees station/soft-AP control block * If mode is WIFI_MODE_NAN, it stops NAN and frees NAN control block * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_stop(void); /** * @brief Restore WiFi stack persistent settings to default values * * This function will reset settings made using the following APIs: * - esp_wifi_set_bandwidth, * - esp_wifi_set_protocol, * - esp_wifi_set_config related * - esp_wifi_set_mode * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_restore(void); /** * @brief Connect WiFi station to the AP. * * @attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode * @attention 2. If station interface is connected to an AP, call esp_wifi_disconnect to disconnect. * @attention 3. The scanning triggered by esp_wifi_scan_start() will not be effective until connection between device and the AP is established. * If device is scanning and connecting at the same time, it will abort scanning and return a warning message and error * number ESP_ERR_WIFI_STATE. * @attention 4. This API attempts to connect to an Access Point (AP) only once. To enable reconnection in case of a connection failure, please use * the 'failure_retry_cnt' feature in the 'wifi_sta_config_t'. Users are suggested to implement reconnection logic in their application * for scenarios where the specified AP does not exist, or reconnection is desired after the device has received a disconnect event. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_WIFI_MODE: WiFi mode error * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong * - ESP_ERR_WIFI_SSID: SSID of AP which station connects is invalid *//* ... */ esp_err_t esp_wifi_connect(void); /** * @brief Disconnect WiFi station from the AP. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi was not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start * - ESP_FAIL: other WiFi internal errors *//* ... */ esp_err_t esp_wifi_disconnect(void); /** * @brief Currently this API is just an stub API * * @return * - ESP_OK: succeed * - others: fail *//* ... */ esp_err_t esp_wifi_clear_fast_connect(void); /** * @brief deauthenticate all stations or associated id equals to aid * * @param aid when aid is 0, deauthenticate all stations, otherwise deauthenticate station whose associated id is aid * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_WIFI_MODE: WiFi mode is wrong *//* ... */ esp_err_t esp_wifi_deauth_sta(uint16_t aid); /** * @brief Scan all available APs. * * @attention If this API is called, the found APs are stored in WiFi driver dynamic allocated memory. And then * can be freed in esp_wifi_scan_get_ap_records(), esp_wifi_scan_get_ap_record() or esp_wifi_clear_ap_list(), * so call any one to free the memory once the scan is done. * @attention The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds. * Values above 1500ms may cause station to disconnect from AP and are not recommended. * * @param config configuration settings for scanning, if set to NULL default settings will be used * of which default values are show_hidden:false, scan_type:active, scan_time.active.min:0, * scan_time.active.max:120 milliseconds, scan_time.passive:360 milliseconds * home_chan_dwell_time:30ms * * @param block if block is true, this API will block the caller until the scan is done, otherwise * it will return immediately * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start * - ESP_ERR_WIFI_TIMEOUT: blocking scan is timeout * - ESP_ERR_WIFI_STATE: WiFi still connecting when invoke esp_wifi_scan_start * - others: refer to error code in esp_err.h *//* ... */ esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, bool block); /** * @brief Set default parameters used for scanning by station. * * @attention The values set using this API are also used for scans used while connecting. * * @attention The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds. * * @attention The home_chan_dwell_time needs to be a minimum of 30ms and a maximum of 150ms. * * @attention Set any of the parameters to 0 to indicate using the default parameters - * scan_time.active.min : 0ms, scan_time.active.max : 120ms home_chan_dwell_time : 30ms * scan_time.passive : 360ms * * @attention Default values can be retrieved using the macro WIFI_SCAN_PARAMS_DEFAULT_CONFIG() * * @attention Set the config parameter to NULL to reset previously set scan parameters to their default values. * * @param config default configuration settings for all scans by stations * * @return * - ESP_OK: succeed * - ESP_FAIL: failed as station mode has not been started yet * - ESP_ERR_INVALID_ARG: values provided do not satisfy the requirements * - ESP_ERR_NOT_SUPPORTED: This API is not supported in AP mode yet * - ESP_ERR_INVALID_STATE: a scan/connect is in progress right now, cannot change scan parameters * - others: refer to error code in esp_err.h *//* ... */ esp_err_t esp_wifi_set_scan_parameters(const wifi_scan_default_params_t *config); /** * @brief Get default parameters used for scanning by station. * * @param config structure variable within which scan default params will be stored * * @return * - ESP_OK: succeed * - ESP_ERR_INVALID_ARG: passed parameter does not point to a valid memory * - others: refer to error code in esp_err.h *//* ... */ esp_err_t esp_wifi_get_scan_parameters(wifi_scan_default_params_t *config); /** * @brief Stop the scan in process * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start *//* ... */ esp_err_t esp_wifi_scan_stop(void); /** * @brief Get number of APs found in last scan * * @param[out] number store number of APs found in last scan * * @attention This API can only be called when the scan is completed, otherwise it may get wrong value. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number); /** * @brief Get AP list found in last scan. * * @attention This API will free all memory occupied by scanned AP list. * * @param[inout] number As input param, it stores max AP number ap_records can hold. * As output param, it receives the actual AP number this API returns. * @param ap_records wifi_ap_record_t array to hold the found APs * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_NO_MEM: out of memory *//* ... */ esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records); /** * @brief Get one AP record from the scanned AP list. * * @attention Different from esp_wifi_scan_get_ap_records(), this API only gets one AP record * from the scanned AP list each time. This API will free the memory of one AP record, * if the user doesn't get all records in the scannned AP list, then needs to call esp_wifi_clear_ap_list() * to free the remaining memory. * * @param[out] ap_record pointer to one AP record * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_FAIL: scan APs is NULL, means all AP records fetched or no AP found *//* ... */ esp_err_t esp_wifi_scan_get_ap_record(wifi_ap_record_t *ap_record); /** * @brief Clear AP list found in last scan * * @attention This API will free all memory occupied by scanned AP list. * When the obtained AP list fails, AP records must be cleared,otherwise it may cause memory leakage. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_WIFI_MODE: WiFi mode is wrong * - ESP_ERR_INVALID_ARG: It doesn't normally happen, the function called inside the API was passed invalid argument, user should check if the WiFi related config is correct *//* ... */ esp_err_t esp_wifi_clear_ap_list(void); /** * @brief Get information of AP to which the device is associated with * * @attention When the obtained country information is empty, it means that the AP does not carry country information * * @param ap_info the wifi_ap_record_t to hold AP information * sta can get the connected ap's phy mode info through the struct member * phy_11b,phy_11g,phy_11n,phy_lr in the wifi_ap_record_t struct. * For example, phy_11b = 1 imply that ap support 802.11b mode * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_CONN: The station interface don't initialized * - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status *//* ... */ esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info); /** * @brief Set current WiFi power save type * * @attention Default power save type is WIFI_PS_MIN_MODEM. * * @param type power save type * * @return ESP_OK: succeed *//* ... */ esp_err_t esp_wifi_set_ps(wifi_ps_type_t type); /** * @brief Get current WiFi power save type * * @attention Default power save type is WIFI_PS_MIN_MODEM. * * @param[out] type: store current power save type * * @return ESP_OK: succeed *//* ... */ esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type); /** * @brief Set protocol type of specified interface * The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N). * if CONFIG_SOC_WIFI_HE_SUPPORT and band mode is 2.4G, the default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_11AX). * if CONFIG_SOC_WIFI_SUPPORT_5G and band mode is 5G, the default protocol is (WIFI_PROTOCOL_11A|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_11AC|WIFI_PROTOCOL_11AX). * * @attention 1. When WiFi band mode is 2.4G only, support 802.11b or 802.11bg or 802.11bgn or 802.11bgnax or LR mode * @attention 2. When WiFi band mode is 5G only, support 802.11a or 802.11an or 802.11anac or 802.11anacax * @attention 3. Can not set WiFi protocol under band mode 2.4G + 5G (WIFI_BAND_MODE_AUTO), you can use esp_wifi_set_protocols instead * @attention 4. API return ESP_ERR_NOT_SUPPORTED if the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * * @param ifx interface * @param protocol_bitmap WiFi protocol bitmap * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_NOT_SUPPORTED: This API is not supported when the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * - others: refer to error codes in esp_err.h *//* ... */ esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap); /** * @brief Get the current protocol bitmap of the specified interface * * @attention 1. When WiFi band mode is 2.4G only, it will return the protocol supported in the 2.4G band * @attention 2. When WiFi band mode is 5G only, it will return the protocol supported in the 5G band * @attention 3. Can not get WiFi protocol under band mode 2.4G + 5G (WIFI_BAND_MODE_AUTO), you can use esp_wifi_get_protocols instead * @attention 4. API return ESP_ERR_NOT_SUPPORTED if the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * * @param ifx interface * @param[out] protocol_bitmap store current WiFi protocol bitmap of interface ifx * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_NOT_SUPPORTED: This API is not supported when the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * - others: refer to error codes in esp_err.h *//* ... */ esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap); /** * @brief Set the bandwidth of specified interface * * @attention 1. WIFI_BW_HT40 is supported only when the interface support 11N * @attention 2. When the interface supports 11AX/11AC, it only supports setting WIFI_BW_HT20. * @attention 3. Can not set WiFi bandwidth under band mode 2.4G + 5G (WIFI_BAND_MODE_AUTO), you can use esp_wifi_set_bandwidths instead * @attention 4. API return ESP_ERR_NOT_SUPPORTED if the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * * @param ifx interface to be configured * @param bw bandwidth * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_NOT_SUPPORTED: This API is not supported when the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * - others: refer to error codes in esp_err.h *//* ... */ esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw); /** * @brief Get the bandwidth of specified interface * * @attention 1. Can not get WiFi bandwidth under band mode 2.4G + 5G (WIFI_BAND_MODE_AUTO), you can use esp_wifi_get_bandwidths instead * @attention 2. API return ESP_ERR_NOT_SUPPORTED if the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * * @param ifx interface to be configured * @param[out] bw store bandwidth of interface ifx * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_NOT_SUPPORTED: This API is not supported when the band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO) *//* ... */ esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw); /** * @brief Set primary/secondary channel of device * * @attention 1. This API should be called after esp_wifi_start() and before esp_wifi_stop() * @attention 2. When device is in STA mode, this API should not be called when STA is scanning or connecting to an external AP * @attention 3. When device is in softAP mode, this API should not be called when softAP has connected to external STAs * @attention 4. When device is in STA+softAP mode, this API should not be called when in the scenarios described above * @attention 5. The channel info set by this API will not be stored in NVS. So If you want to remember the channel used before WiFi stop, * you need to call this API again after WiFi start, or you can call `esp_wifi_set_config()` to store the channel info in NVS. * * @param primary for HT20, primary is the channel number, for HT40, primary is the primary channel * @param second for HT20, second is ignored, for HT40, second is the second channel * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start *//* ... */ esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second); /** * @brief Get the primary/secondary channel of device * * @attention 1. API return false if try to get a interface that is not enable * * @param primary store current primary channel * @param[out] second store current second channel * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second); /** * @brief configure country info * * @attention 1. It is discouraged to call this API since this doesn't validate the per-country rules, * it's up to the user to fill in all fields according to local regulations. * Please use esp_wifi_set_country_code instead. * @attention 2. The default country is "01" (world safe mode) {.cc="01", .schan=1, .nchan=11, .policy=WIFI_COUNTRY_POLICY_AUTO}. * @attention 3. The third octet of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '. * @attention 4. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which * the station is connected is used. E.g. if the configured country info is {.cc="US", .schan=1, .nchan=11} * and the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14} * then the country info that will be used is {.cc="JP", .schan=1, .nchan=14}. If the station disconnected * from the AP the country info is set back to the country info of the station automatically, * {.cc="US", .schan=1, .nchan=11} in the example. * @attention 5. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, then the configured country info is used always. * @attention 6. When the country info is changed because of configuration or because the station connects to a different * external AP, the country IE in probe response/beacon of the soft-AP is also changed. * @attention 7. The country configuration is stored into flash. * @attention 8. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the * country info. * * @param country the configured country info * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_set_country(const wifi_country_t *country); /** * @brief get the current country info * * @param country country info * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_country(wifi_country_t *country); /** * @brief Set MAC address of WiFi station, soft-AP or NAN interface. * * @attention 1. This API can only be called when the interface is disabled * @attention 2. Above mentioned interfaces have different MAC addresses, do not set them to be the same. * @attention 3. The bit 0 of the first byte of MAC address can not be 1. For example, the MAC address * can set to be "1a:XX:XX:XX:XX:XX", but can not be "15:XX:XX:XX:XX:XX". * * @param ifx interface * @param mac the MAC address * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_WIFI_MAC: invalid mac address * - ESP_ERR_WIFI_MODE: WiFi mode is wrong * - others: refer to error codes in esp_err.h *//* ... */ esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]); /** * @brief Get mac of specified interface * * @param ifx interface * @param[out] mac store mac of the interface ifx * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_WIFI_IF: invalid interface *//* ... */ esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]); /** * @brief The RX callback function in the promiscuous mode. * Each time a packet is received, the callback function will be called. * * @param buf Data received. Type of data in buffer (wifi_promiscuous_pkt_t or wifi_pkt_rx_ctrl_t) indicated by 'type' parameter. * @param type promiscuous packet type. * *//* ... */ typedef void (* wifi_promiscuous_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type); /** * @brief Register the RX callback function in the promiscuous mode. * * Each time a packet is received, the registered callback function will be called. * * @param cb callback * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb); /** * @brief Enable the promiscuous mode. * * @param en false - disable, true - enable * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_set_promiscuous(bool en); /** * @brief Get the promiscuous mode. * * @param[out] en store the current status of promiscuous mode * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_promiscuous(bool *en); /** * @brief Enable the promiscuous mode packet type filter. * * @note The default filter is to filter all packets except WIFI_PKT_MISC * * @param filter the packet type filtered in promiscuous mode. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter); /** * @brief Get the promiscuous filter. * * @param[out] filter store the current status of promiscuous filter * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_promiscuous_filter(wifi_promiscuous_filter_t *filter); /** * @brief Enable subtype filter of the control packet in promiscuous mode. * * @note The default filter is to filter none control packet. * * @param filter the subtype of the control packet filtered in promiscuous mode. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter); /** * @brief Get the subtype filter of the control packet in promiscuous mode. * * @param[out] filter store the current status of subtype filter of the control packet in promiscuous mode * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter); /** * @brief Set the configuration of the STA, AP or NAN * * @attention 1. This API can be called only when specified interface is enabled, otherwise, API fail * @attention 2. For station configuration, bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP. * @attention 3. ESP devices are limited to only one channel, so when in the soft-AP+station mode, the soft-AP will adjust its channel automatically to be the same as * the channel of the station. * @attention 4. The configuration will be stored in NVS for station and soft-AP * * @param interface interface * @param conf station, soft-AP or NAN configuration * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_WIFI_MODE: invalid mode * - ESP_ERR_WIFI_PASSWORD: invalid password * - ESP_ERR_WIFI_NVS: WiFi internal NVS error * - others: refer to the error code in esp_err.h *//* ... */ esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf); /** * @brief Get configuration of specified interface * * @param interface interface * @param[out] conf station or soft-AP configuration * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_WIFI_IF: invalid interface *//* ... */ esp_err_t esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf); /** * @brief Forward declare wifi_sta_list_t. The definition depends on the target device * that implements esp_wifi *//* ... */ typedef struct wifi_sta_list_t wifi_sta_list_t; /** * @brief Get STAs associated with soft-AP * * @attention SSC only API * * @param[out] sta station list * ap can get the connected sta's phy mode info through the struct member * phy_11b,phy_11g,phy_11n,phy_lr in the wifi_sta_info_t struct. * For example, phy_11b = 1 imply that sta support 802.11b mode * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_WIFI_MODE: WiFi mode is wrong * - ESP_ERR_WIFI_CONN: WiFi internal error, the station/soft-AP control block is invalid *//* ... */ esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta); /** * @brief Get AID of STA connected with soft-AP * * @param mac STA's mac address * @param[out] aid Store the AID corresponding to STA mac * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_NOT_FOUND: Requested resource not found * - ESP_ERR_WIFI_MODE: WiFi mode is wrong * - ESP_ERR_WIFI_CONN: WiFi internal error, the station/soft-AP control block is invalid *//* ... */ esp_err_t esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid); /** * @brief Set the WiFi API configuration storage type * * @attention 1. The default value is WIFI_STORAGE_FLASH * * @param storage : storage type * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_set_storage(wifi_storage_t storage); /** * @brief Function signature for received Vendor-Specific Information Element callback. * @param ctx Context argument, as passed to esp_wifi_set_vendor_ie_cb() when registering callback. * @param type Information element type, based on frame type received. * @param sa Source 802.11 address. * @param vnd_ie Pointer to the vendor specific element data received. * @param rssi Received signal strength indication. *//* ... */ typedef void (*esp_vendor_ie_cb_t)(void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const vendor_ie_data_t *vnd_ie, int rssi); /** * @brief Set 802.11 Vendor-Specific Information Element * * @param enable If true, specified IE is enabled. If false, specified IE is removed. * @param type Information Element type. Determines the frame type to associate with the IE. * @param idx Index to set or clear. Each IE type can be associated with up to two elements (indices 0 & 1). * @param vnd_ie Pointer to vendor specific element data. First 6 bytes should be a header with fields matching vendor_ie_data_t. * If enable is false, this argument is ignored and can be NULL. Data does not need to remain valid after the function returns. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init() * - ESP_ERR_INVALID_ARG: Invalid argument, including if first byte of vnd_ie is not WIFI_VENDOR_IE_ELEMENT_ID (0xDD) * or second byte is an invalid length. * - ESP_ERR_NO_MEM: Out of memory *//* ... */ esp_err_t esp_wifi_set_vendor_ie(bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie); /** * @brief Register Vendor-Specific Information Element monitoring callback. * * @param cb Callback function * @param ctx Context argument, passed to callback function. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx); /** * @brief Set maximum transmitting power after WiFi start. * * @attention 1. Maximum power before WiFi startup is limited by PHY init data bin. * @attention 2. The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable. * @attention 3. Mapping Table {Power, max_tx_power} = {{8, 2}, {20, 5}, {28, 7}, {34, 8}, {44, 11}, * {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}. * @attention 4. Param power unit is 0.25dBm, range is [8, 84] corresponding to 2dBm - 20dBm. * @attention 5. Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8, 19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 79],72}, {[80, 84],80}}. * * @param power Maximum WiFi transmitting power. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument, e.g. parameter is out of range *//* ... */ esp_err_t esp_wifi_set_max_tx_power(int8_t power); /** * @brief Get maximum transmitting power after WiFi start * * @param power Maximum WiFi transmitting power, unit is 0.25dBm. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_max_tx_power(int8_t *power); /** * @brief Set mask to enable or disable some WiFi events * * @attention 1. Mask can be created by logical OR of various WIFI_EVENT_MASK_ constants. * Events which have corresponding bit set in the mask will not be delivered to the system event handler. * @attention 2. Default WiFi event mask is WIFI_EVENT_MASK_AP_PROBEREQRECVED. * @attention 3. There may be lots of stations sending probe request data around. * Don't unmask this event unless you need to receive probe request data. * * @param mask WiFi event mask. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_set_event_mask(uint32_t mask); /** * @brief Get mask of WiFi events * * @param mask WiFi event mask. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_event_mask(uint32_t *mask); /** * @brief Send raw ieee80211 data * * @attention Currently only support for sending beacon/probe request/probe response/action and non-QoS * data frame * * @param ifx interface if the Wi-Fi mode is Station, the ifx should be WIFI_IF_STA. If the Wi-Fi * mode is SoftAP, the ifx should be WIFI_IF_AP. If the Wi-Fi mode is Station+SoftAP, the * ifx should be WIFI_IF_STA or WIFI_IF_AP. If the ifx is wrong, the API returns ESP_ERR_WIFI_IF. * @param buffer raw ieee80211 buffer * @param len the length of raw buffer, the len must be <= 1500 Bytes and >= 24 Bytes * @param en_sys_seq indicate whether use the internal sequence number. If en_sys_seq is false, the * sequence in raw buffer is unchanged, otherwise it will be overwritten by WiFi driver with * the system sequence number. * Generally, if esp_wifi_80211_tx is called before the Wi-Fi connection has been set up, both * en_sys_seq==true and en_sys_seq==false are fine. However, if the API is called after the Wi-Fi * connection has been set up, en_sys_seq must be true, otherwise ESP_ERR_INVALID_ARG is returned. * * @return * - ESP_OK: success * - ESP_ERR_WIFI_IF: Invalid interface * - ESP_ERR_INVALID_ARG: Invalid parameter * - ESP_ERR_WIFI_NO_MEM: out of memory *//* ... */ esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq); /** * @brief The RX callback function of Channel State Information(CSI) data. * * Each time a CSI data is received, the callback function will be called. * * @param ctx context argument, passed to esp_wifi_set_csi_rx_cb() when registering callback function. * @param data CSI data received. The memory that it points to will be deallocated after callback function returns. * *//* ... */ typedef void (* wifi_csi_cb_t)(void *ctx, wifi_csi_info_t *data); /** * @brief Register the RX callback function of CSI data. * * Each time a CSI data is received, the callback function will be called. * * @param cb callback * @param ctx context argument, passed to callback function * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init *//* ... */ esp_err_t esp_wifi_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx); /** * @brief Set CSI data configuration * * @param config configuration * * return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_set_csi_config(const wifi_csi_config_t *config); /** * @brief Get CSI data configuration * * @param config configuration * * return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_csi_config(wifi_csi_config_t *config); /** * @brief Enable or disable CSI * * @param en true - enable, false - disable * * return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_set_csi(bool en); /** * @brief Set antenna GPIO configuration * * @param config Antenna GPIO configuration. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: Invalid argument, e.g. parameter is NULL, invalid GPIO number etc *//* ... */ esp_err_t esp_wifi_set_ant_gpio(const wifi_ant_gpio_config_t *config) __attribute__((deprecated("Please use esp_phy_set_ant_gpio instead"))); /** * @brief Get current antenna GPIO configuration * * @param config Antenna GPIO configuration. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument, e.g. parameter is NULL *//* ... */ esp_err_t esp_wifi_get_ant_gpio(wifi_ant_gpio_config_t *config) __attribute__((deprecated("Please use esp_phy_get_ant_gpio instead"))); /** * @brief Set antenna configuration * * @param config Antenna configuration. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: Invalid argument, e.g. parameter is NULL, invalid antenna mode or invalid GPIO number *//* ... */ esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config) __attribute__((deprecated("Please use esp_phy_set_ant instead"))); /** * @brief Get current antenna configuration * * @param config Antenna configuration. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument, e.g. parameter is NULL *//* ... */ esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config) __attribute__((deprecated("Please use esp_phy_get_ant instead"))); /** * @brief Get the TSF time * In Station mode or SoftAP+Station mode if station is not connected or station doesn't receive at least * one beacon after connected, will return 0 * * @attention Enabling power save may cause the return value inaccurate, except WiFi modem sleep * * @param interface The interface whose tsf_time is to be retrieved. * * @return 0 or the TSF time *//* ... */ int64_t esp_wifi_get_tsf_time(wifi_interface_t interface); /** * @brief Set the inactive time of the STA or AP * * @attention 1. For Station, If the station does not receive a beacon frame from the connected SoftAP during the inactive time, * disconnect from SoftAP. Default 6s. * @attention 2. For SoftAP, If the softAP doesn't receive any data from the connected STA during inactive time, * the softAP will force deauth the STA. Default is 300s. * @attention 3. The inactive time configuration is not stored into flash * * @param ifx interface to be configured. * @param sec Inactive time. Unit seconds. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument, For Station, if sec is less than 3. For SoftAP, if sec is less than 10. *//* ... */ esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec); /** * @brief Get inactive time of specified interface * * @param ifx Interface to be configured. * @param sec Inactive time. Unit seconds. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec); /** * @brief Dump WiFi statistics * * @param modules statistic modules to be dumped * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_statis_dump(uint32_t modules); /** * @brief Set RSSI threshold, if average rssi gets lower than threshold, WiFi task will post event WIFI_EVENT_STA_BSS_RSSI_LOW. * * @attention If the user wants to receive another WIFI_EVENT_STA_BSS_RSSI_LOW event after receiving one, this API needs to be * called again with an updated/same RSSI threshold. * * @param rssi threshold value in dbm between -100 to 10 * Note that in some rare cases where signal strength is very strong, rssi values can be slightly positive. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_set_rssi_threshold(int32_t rssi); /** * @brief Start an FTM Initiator session by sending FTM request * If successful, event WIFI_EVENT_FTM_REPORT is generated with the result of the FTM procedure * * @attention 1. Use this API only in Station mode. * @attention 2. If FTM is initiated on a different channel than Station is connected in or internal SoftAP is started in, * FTM defaults to a single burst in ASAP mode. * * @param cfg FTM Initiator session configuration * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg); /** * @brief End the ongoing FTM Initiator session * * @attention This API works only on FTM Initiator * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_ftm_end_session(void); /** * @brief Set offset in cm for FTM Responder. An equivalent offset is calculated in picoseconds * and added in TOD of FTM Measurement frame (T1). * * @attention Use this API only in AP mode before performing FTM as responder * * @param offset_cm T1 Offset to be added in centimeters * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_ftm_resp_set_offset(int16_t offset_cm); /** * @brief Get FTM measurements report copied into a user provided buffer. * * @attention 1. To get the FTM report, user first needs to allocate a buffer of size * (sizeof(wifi_ftm_report_entry_t) * num_entries) where the API will fill up to num_entries * valid FTM measurements in the buffer. Total number of entries can be found in the event * WIFI_EVENT_FTM_REPORT as ftm_report_num_entries * @attention 2. The internal FTM report is freed upon use of this API which means the API can only be used * once after every FTM session initiated * @attention 3. Passing the buffer as NULL merely frees the FTM report * * @param report Pointer to the buffer for receiving the FTM report * @param num_entries Number of FTM report entries to be filled in the report * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries); /** * @brief Enable or disable 11b rate of specified interface * * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). * @attention 2. Only when really need to disable 11b rate call this API otherwise don't call this. * * @param ifx Interface to be configured. * @param disable true means disable 11b rate while false means enable 11b rate. * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable); #define ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE 0 /** * @brief Set wake interval for connectionless modules to wake up periodically. * * @attention 1. Only one wake interval for all connectionless modules. * @attention 2. This configuration could work at connected status. * When ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work at disconnected status. * @attention 3. Event WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START would be posted each time wake interval starts. * @attention 4. Recommend to configure interval in multiples of hundred. (e.g. 100ms) * @attention 5. Recommend to configure interval to ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE to get stable performance at coexistence mode. * * @param wake_interval Milliseconds after would the chip wake up, from 1 to 65535. *//* ... */ esp_err_t esp_wifi_connectionless_module_set_wake_interval(uint16_t wake_interval); /** * @brief Request extra reference of Wi-Fi radio. * Wi-Fi keep active state(RF opened) to be able to receive packets. * * @attention Please pair the use of `esp_wifi_force_wakeup_acquire` with `esp_wifi_force_wakeup_release`. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start *//* ... */ esp_err_t esp_wifi_force_wakeup_acquire(void); /** * @brief Release extra reference of Wi-Fi radio. * Wi-Fi go to sleep state(RF closed) if no more use of radio. * * @attention Please pair the use of `esp_wifi_force_wakeup_acquire` with `esp_wifi_force_wakeup_release`. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start *//* ... */ esp_err_t esp_wifi_force_wakeup_release(void); /** * @brief configure country * * @attention 1. When ieee80211d_enabled, the country info of the AP to which * the station is connected is used. E.g. if the configured country is US * and the country info of the AP to which the station is connected is JP * then the country info that will be used is JP. If the station disconnected * from the AP the country info is set back to the country info of the station automatically, * US in the example. * @attention 2. When ieee80211d_enabled is disabled, then the configured country info is used always. * @attention 3. When the country info is changed because of configuration or because the station connects to a different * external AP, the country IE in probe response/beacon of the soft-AP is also changed. * @attention 4. The country configuration is stored into flash. * @attention 5. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the * country info. * @attention 6. Supported country codes are "01"(world safe mode) "AT","AU","BE","BG","BR", * "CA","CH","CN","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HK","HR","HU", * "IE","IN","IS","IT","JP","KR","LI","LT","LU","LV","MT","MX","NL","NO","NZ","PL","PT", * "RO","SE","SI","SK","TW","US" * * @attention 7. When country code "01" (world safe mode) is set, SoftAP mode won't contain country IE. * @attention 8. The default country is "01" (world safe mode) and ieee80211d_enabled is TRUE. * @attention 9. The third octet of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '. * * @param country the configured country ISO code * @param ieee80211d_enabled 802.11d is enabled or not * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled); /** * @brief get the current country code * * @param country country code * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_country_code(char *country); /** * @brief Config 80211 tx rate of specified interface * * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). * @attention 2. Can not set 80211 tx rate under 11A/11AC/11AX protocol, you can use esp_wifi_config_80211_tx instead. * * @param ifx Interface to be configured. * @param rate Phy rate to be configured. * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); /** * @brief Config 80211 tx rate and phymode of specified interface * * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). * * @param ifx Interface to be configured. * @param config rate_config to be configured. * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_config_80211_tx(wifi_interface_t ifx, wifi_tx_rate_config_t *config); /** * @brief Disable PMF configuration for specified interface * * @attention This API should be called after esp_wifi_set_config() and before esp_wifi_start(). * * @param ifx Interface to be configured. * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_disable_pmf_config(wifi_interface_t ifx); /** * @brief Get the Association id assigned to STA by AP * * @param[out] aid store the aid * * @attention aid = 0 if station is not connected to AP. * * @return * - ESP_OK: succeed *//* ... */ esp_err_t esp_wifi_sta_get_aid(uint16_t *aid); /** * @brief Get the negotiated phymode after connection. * * @param[out] phymode store the negotiated phymode. * * @return * - ESP_OK: succeed *//* ... */ esp_err_t esp_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode); /** * @brief Config dynamic carrier sense * * @attention This API should be called after esp_wifi_start(). * * @param enabled Dynamic carrier sense is enabled or not. * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_set_dynamic_cs(bool enabled); /** * @brief Get the rssi information of AP to which the device is associated with * * @attention 1. This API should be called after station connected to AP. * @attention 2. Use this API only in WIFI_MODE_STA or WIFI_MODE_APSTA mode. * * @param rssi store the rssi info received from last beacon. * * @return * - ESP_OK: succeed * - ESP_ERR_INVALID_ARG: invalid argument * - ESP_FAIL: failed *//* ... */ esp_err_t esp_wifi_sta_get_rssi(int *rssi); /** * @brief Set WiFi current band. * * @attention 1. This API is only operational when the WiFi band mode is configured to 2.4G + 5G (WIFI_BAND_MODE_AUTO) * @attention 2. When device is in STA mode, this API should not be called when STA is scanning or connecting to an external AP * @attention 3. When device is in softAP mode, this API should not be called when softAP has connected to external STAs * @attention 4. When device is in STA+softAP mode, this API should not be called when in the scenarios described above * @attention 5. It is recommended not to use this API. If you want to change the current band, you can use esp_wifi_set_channel instead. * * @param[in] band WiFi band 2.4G / 5G * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_set_band(wifi_band_t band); /** * @brief Get WiFi current band. * * @param[in] band store current band of WiFi * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_band(wifi_band_t* band); /** * @brief Set WiFi band mode. * * @attention 1. When the WiFi band mode is set to 2.4G only, it operates exclusively on the 2.4GHz channels. * @attention 2. When the WiFi band mode is set to 5G only, it operates exclusively on the 5GHz channels. * @attention 3. When the WiFi band mode is set to 2.4G + 5G (WIFI_BAND_MODE_AUTO), it can operate on both the 2.4GHz and 5GHz channels. * @attention 4. WiFi band mode can be set to 5G only or 2.4G + 5G (WIFI_BAND_MODE_AUTO) if CONFIG_SOC_WIFI_SUPPORT_5G is supported. * @attention 5. If CONFIG_SOC_WIFI_SUPPORT_5G is not supported, the API will return ESP_ERR_INVALID_ARG when the band mode is set to either 5G only or 2.4G + 5G (WIFI_BAND_MODE_AUTO). * @attention 6. When a WiFi band mode change triggers a band change, if no channel is set for the current band, a default channel will be assigned: channel 1 for 2.4G band and channel 36 for 5G band. * * @param[in] band_mode store the band mode of WiFi * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start * - ESP_ERR_INVALID_ARG: invalid argument * *//* ... */ esp_err_t esp_wifi_set_band_mode(wifi_band_mode_t band_mode); /** * @brief get WiFi band mode. * * @param[in] band_mode store the band mode of WiFi * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_band_mode(wifi_band_mode_t* band_mode); #if CONFIG_ESP_COEX_POWER_MANAGEMENT /** * @brief Enable Wi-Fi coexistence power management * * @attention This API should be called after esp_wifi_init(). * * @param enabled Wi-Fi coexistence power management is enabled or not. * * @return * - ESP_OK: succeed * - others: failed *//* ... */ esp_err_t esp_wifi_coex_pwr_configure(bool enabled);/* ... */ #endif /** * @brief Set the supported WiFi protocols for the specified interface. * * @attention 1. When the WiFi band mode is set to 2.4G only, it will not set 5G protocol * @attention 2. When the WiFi band mode is set to 5G only, it will not set 2.4G protocol * @attention 3. This API supports setting the maximum protocol. For example, if the 2.4G protocol is set to 802.11n, it will automatically configure to 802.11b/g/n. * * @param ifx interface * @param protocols WiFi protocols include 2.4G protocol and 5G protocol * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - others: refer to error codes in esp_err.h *//* ... */ esp_err_t esp_wifi_set_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols); /** * @brief Get the current protocol of the specified interface and specified band * * @attention 1. The 5G protocol can only be read when CONFIG_SOC_WIFI_SUPPORT_5G is enabled. * @attention 2. When the WiFi band mode is set to 2.4G only, it will not get 5G protocol * @attention 3. When the WiFi band mode is set to 5G only, it will not get 2.4G protocol * * @param ifx interface * @param[out] protocols store current WiFi protocols of interface ifx * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument * - others: refer to error codes in esp_err.h *//* ... */ esp_err_t esp_wifi_get_protocols(wifi_interface_t ifx, wifi_protocols_t *protocols); /** * @brief Set the bandwidth of specified interface and specified band * * @attention 1. WIFI_BW_HT40 is supported only when the interface support 11N * @attention 2. When the interface supports 11AX/11AC, it only supports setting WIFI_BW_HT20. * @attention 3. When the WiFi band mode is set to 2.4G only, it will not set 5G bandwidth * @attention 4. When the WiFi band mode is set to 5G only, it will not set 2.4G bandwidth * * @param ifx interface to be configured * @param bw WiFi bandwidths include 2.4G bandwidth and 5G bandwidth * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument * - others: refer to error codes in esp_err.h *//* ... */ esp_err_t esp_wifi_set_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t* bw); /** * @brief Get the bandwidth of specified interface and specified band * * @attention 1. The 5G bandwidth can only be read when CONFIG_SOC_WIFI_SUPPORT_5G is enabled. * @attention 2. When the WiFi band mode is set to 2.4G only, it will not get 5G bandwidth * @attention 3. When the WiFi band mode is set to 5G only, it will not get 2.4G bandwidth * * @param ifx interface to be configured * @param[out] bw store bandwidths of interface ifx * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_IF: invalid interface * - ESP_ERR_INVALID_ARG: invalid argument *//* ... */ esp_err_t esp_wifi_get_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw); #ifdef __cplusplus }{...} #endif /* ... */ #endif /* __ESP_WIFI_H__ */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.