2C ESP8266 SDK Programming Guide EN V1.3.0

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 162 [warning: Documents this large are best viewed by clicking the View PDF Link!]

ESP8266 SDK API Guide
Version 1.3.0
Espressif Systems IOT Team
Copyright (c) 2015
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Disclaimer and Copyright Notice
Information in this document, including URL references, is subject to change without notice.
THIS DOCUMENT IS PROVIDED AS IS WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY
WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY PARTICULAR
PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR
SAMPLE. All liability, including liability for infringement of any proprietary rights, relating to use of
information in this document is disclaimed. No licenses express or implied, by estoppel or otherwise,
to any intellectual property rights are granted herein.
The Wi-Fi Alliance Member Logo is a trademark of the Wi-Fi Alliance.
All trade names, trademarks and registered trademarks mentioned in this document are property of
their respective owners, and are hereby acknowledged.
Copyright © 2015 Espressif Systems Inc. All rights reserved.
Espressif Systems Confidential / Friday, Aug 7, 2015 2 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
1. Preambles 13 .................................................................................................
2. Overview 14 ....................................................................................................
3. Application Programming Interface (APIs) 15 ..............................................
3.1. Software Timer!15"........................................................................................
1. os_timer_arm!15 ..........................................................................................
2. os_timer_disarm!16 .....................................................................................
3. os_timer_setfn!16 ........................................................................................
4. system_timer_reinit!16 .................................................................................
5. os_timer_arm_us!17 ....................................................................................
3.2. Hardware Timer!17".......................................................................................
1. hw_timer_init!18 ..........................................................................................
2. hw_timer_arm !18 ........................................................................................
3. hw_timer_set_func!18 ..................................................................................
4. hardware timer example !19 ........................................................................
3.3. System APIs!20"..........................................................................................
1. system_get_sdk_version!20 .........................................................................
2. system_restore!20 .......................................................................................
3. system_restart!20 ........................................................................................
4. system_init_done_cb!21 ..............................................................................
5. system_get_chip_id!21 ................................................................................
6. system_get_vdd33!21 .................................................................................
7. system_adc_read!22 ...................................................................................
8. system_deep_sleep!22 ................................................................................
9. system_deep_sleep_set_option!23 ..............................................................
10. system_phy_set_rfoption!24 ........................................................................
11. system_phy_set_max_tpw!24 ......................................................................
12. system_phy_set_tpw_via_vdd33!25 .............................................................
13. system_set_os_print!25 ...............................................................................
14. system_print_meminfo!26 ............................................................................
15. system_get_free_heap_size!26 ....................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 3 162
Table of Content
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
16. system_os_task!26 ......................................................................................
17. system_os_post!27 .....................................................................................
18. system_get_time!28 .....................................................................................
19. system_get_rtc_time!28 ...............................................................................
20. system_rtc_clock_cali_proc!29 ....................................................................
21. system_rtc_mem_write!29 ...........................................................................
22. system_rtc_mem_read!30 ...........................................................................
23. system_uart_swap!31 ..................................................................................
24. system_uart_de_swap!31 ............................................................................
25. system_get_boot_version!31 .......................................................................
26. system_get_userbin_addr!32 .......................................................................
27. system_get_boot_mode!32 .........................................................................
28. system_restart_enhance!32 .........................................................................
29. system_update_cpu_freq!33 ........................................................................
30. system_get_cpu_freq!33 ..............................................................................
31. system_get_flash_size_map!34 ....................................................................
32. system_get_rst_info !34 ...............................................................................
33. system_soft_wdt_stop!35 ............................................................................
34. system_soft_wdt_restart!36 .........................................................................
35. system_soft_wdt_feed!36 ............................................................................
36. os_memset!36 .............................................................................................
37. os_memcpy!37 ............................................................................................
38. os_strlen!37 .................................................................................................
39. os_printf!38 .................................................................................................
40. os_bzero!38 .................................................................................................
41. os_delay_us!38 ............................................................................................
42. os_install_putc1!39 ......................................................................................
3.4. SPI Flash Related APIs!39"..........................................................................
1. spi_flash_get_id!39 ......................................................................................
2. spi_flash_erase_sector!39 ............................................................................
3. spi_flash_write!40 ........................................................................................
4. spi_flash_read!40 .........................................................................................
5. system_param_save_with_protect !41 .........................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 4 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
6. system_param_load !42 ...............................................................................
7. spi_flash_set_read_func!43 ..........................................................................
3.5. Wi-Fi Related APIs!45".................................................................................
1. wifi_get_opmode!45 ....................................................................................
2. wifi_get_opmode_default!45 ........................................................................
3. wifi_set_opmode!46 .....................................................................................
4. wifi_set_opmode_current!46 ........................................................................
5. wifi_station_get_config!46 ............................................................................
6. wifi_station_get_config_default!47 ................................................................
7. wifi_station_set_config!47 ............................................................................
8. wifi_station_set_config_current!48 ...............................................................
9. wifi_station_connect!49 ...............................................................................
10. wifi_station_disconnect!49 ...........................................................................
11. wifi_station_get_connect_status!50 .............................................................
12. wifi_station_scan!50 ....................................................................................
13. scan_done_cb_t!51 .....................................................................................
14. wifi_station_ap_number_set!51 ....................................................................
15. wifi_station_get_ap_info!52 ..........................................................................
16. wifi_station_ap_change!52 ...........................................................................
17. wifi_station_get_current_ap_id!52 ................................................................
18. wifi_station_get_auto_connect!53 ................................................................
19. wifi_station_set_auto_connect!53 ................................................................
20. wifi_station_dhcpc_start!53 .........................................................................
21. wifi_station_dhcpc_stop!54 .........................................................................
22. wifi_station_dhcpc_status!54 .......................................................................
23. wifi_station_set_reconnect_policy!55 ...........................................................
24. wifi_station_get_rssi!55 ................................................................................
25. wifi_station_set_hostname!56 ......................................................................
26. wifi_station_get_hostname!56 ......................................................................
27. wifi_softap_get_config!56 ............................................................................
28. wifi_softap_get_config_default!57 ................................................................
29. wifi_softap_set_config!57 .............................................................................
30. wifi_softap_set_config_current!57 ................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 5 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
31. wifi_softap_get_station_num!58 ...................................................................
32. wifi_softap_get_station_info!58 ....................................................................
33. wifi_softap_free_station_info!59 ...................................................................
34. wifi_softap_dhcps_start!59 ..........................................................................
35. wifi_softap_dhcps_stop!60 ..........................................................................
36. wifi_softap_set_dhcps_lease!60 ...................................................................
37. wifi_softap_get_dhcps_lease!62 ..................................................................
38. wifi_softap_dhcps_status!62 ........................................................................
39. wifi_softap_set_dhcps_offer_option!62 ........................................................
40. wifi_set_phy_mode!63 .................................................................................
41. wifi_get_phy_mode!63 .................................................................................
42. wifi_get_ip_info!64 .......................................................................................
43. wifi_set_ip_info!64 .......................................................................................
44. wifi_set_macaddr!65 ....................................................................................
45. wifi_get_macaddr!66 ...................................................................................
46. wifi_set_sleep_type!67 .................................................................................
47. wifi_get_sleep_type!67 .................................................................................
48. wifi_status_led_install!67 ..............................................................................
49. wifi_status_led_uninstall!68 ..........................................................................
50. wifi_set_broadcast_if!68 ...............................................................................
51. wifi_get_broadcast _if!69 .............................................................................
52. wifi_set_event_handler_cb!69 ......................................................................
53. wifi_get_channel!70 .....................................................................................
54. wifi_set_channel!71 .....................................................................................
55. wifi_wps_enable!71 .....................................................................................
56. wifi_wps_disable!72 .....................................................................................
57. wifi_wps_start!72 .........................................................................................
58. wifi_set_wps_cb!73 .....................................................................................
3.6. ESP-NOW APIs!74"......................................................................................
1. esp_now_init!74 ...........................................................................................
2. esp_now_deinit!74 .......................................................................................
3. esp_now_register_recv_cb!75 .....................................................................
4. esp_now_unregister_recv_cb!75 ..................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 6 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
5. esp_now_register_send_cb!75 ....................................................................
6. esp_now_unregister_send_cb!76 .................................................................
7. esp_now_send!76 .......................................................................................
8. esp_now_add_peer!77 ................................................................................
9. esp_now_del_peer!78 ..................................................................................
10. esp_now_set_self_role!78 ............................................................................
11. esp_now_get_self_role!78 ............................................................................
12. esp_now_set_peer_role!79 ..........................................................................
13. esp_now_get_peer_role!79 ..........................................................................
14. esp_now_set_peer_key!80 ..........................................................................
15. esp_now_get_peer_key!80 ..........................................................................
16. esp_now_set_peer_channel!81 ....................................................................
17. esp_now_get_peer_channel!81 ...................................................................
18. esp_now_is_peer_exist!81 ...........................................................................
19. esp_now_fetch_peer!82 ..............................................................................
20. esp_now_get_cnt_info!82 ............................................................................
21. esp_now_set_kok!83 ...................................................................................
3.7. Upgrade (FOTA) APIs!84".............................................................................
1. system_upgrade_userbin_check!84 .............................................................
2. system_upgrade_flag_set!84 .......................................................................
3. system_upgrade_flag_check!84 ...................................................................
4. system_upgrade_start!85 ............................................................................
5. system_upgrade_reboot!85 .........................................................................
3.8. Snier Related APIs!86"...............................................................................
1. wifi_promiscuous_enable!86 ........................................................................
2. wifi_promiscuous_set_mac!86 .....................................................................
3. wifi_set_promiscuous_rx_cb!87 ...................................................................
3.9. smart config APIs!88"..................................................................................
1. smartconfig_start!88 ....................................................................................
2. smartconfig_stop!90 ....................................................................................
3.10. SNTP APIs!91"............................................................................................
1. sntp_setserver!91 ........................................................................................
2. sntp_getserver!91 ........................................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 7 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
3. sntp_setservername!91 ...............................................................................
4. sntp_getservername!92 ...............................................................................
5. sntp_init!92 ..................................................................................................
6. sntp_stop!92 ...............................................................................................
7. sntp_get_current_timestamp!92 ..................................................................
8. sntp_get_real_time!93 ..................................................................................
9. SNTP Example!94 ......................................................................................
4. TCP/UDP APIs 95 ...........................................................................................
4.1. Generic TCP/UDP APIs!95".........................................................................
1. espconn_delete!95 ......................................................................................
2. espconn_gethostbyname!95 .......................................................................
3. espconn_port!96 .........................................................................................
4. espconn_regist_sentcb!97 ...........................................................................
5. espconn_regist_recvcb!97 ...........................................................................
6. espconn_sent_callback!97 ..........................................................................
7. espconn_recv_callback!98 ...........................................................................
8. espconn_send!98 ........................................................................................
9. espconn_sent!99 .........................................................................................
4.2. TCP APIs!100".............................................................................................
1. espconn_accept!100 ...................................................................................
2. espconn_secure_accept!100 .......................................................................
3. espconn_regist_time!101 .............................................................................
4. espconn_get_connection_info!101 ..............................................................
5. espconn_connect!102 .................................................................................
6. espconn_connect_callback!103 ...................................................................
7. espconn_regist_connectcb!103 ...................................................................
8. espconn_set_opt!103 ..................................................................................
9. espconn_clear_opt!104 ...............................................................................
10. espconn_set_keepalive!105 .........................................................................
11. espconn_get_keepalive!106 ........................................................................
12. espconn_reconnect_callback!107 ................................................................
13. espconn_regist_reconcb!107 .......................................................................
14. espconn_disconnect!108 .............................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 8 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
15. espconn_regist_disconcb!108 .....................................................................
16. espconn_regist_write_finish!109 ..................................................................
17. espconn_secure_set_size!109 .....................................................................
18. espconn_secure_get_size!110 .....................................................................
19. espconn_secure_connect!110 .....................................................................
20. espconn_secure_send!111 ..........................................................................
21. espconn_secure_sent!112 ...........................................................................
22. espconn_secure_disconnect!112 ................................................................
23. espconn_secure_ca_disable!113 .................................................................
24. espconn_secure_ca_enable!113 ..................................................................
25. espconn_tcp_get_max_con!114 ..................................................................
26. espconn_tcp_set_max_con!114 ..................................................................
27. espconn_tcp_get_max_con_allow!115 ........................................................
28. espconn_tcp_set_max_con_allow!115 ........................................................
29. espconn_recv_hold!115 ...............................................................................
30. espconn_recv_unhold!116 ...........................................................................
4.3. UDP APIs!116".............................................................................................
1. espconn_create!116 ....................................................................................
2. espconn_igmp_join!117 ...............................................................................
3. espconn_igmp_leave!117 ............................................................................
4. espconn_dns_setserver!117 ........................................................................
4.4. mDNS APIs!118".........................................................................................
1. espconn_mdns_init!118 ...............................................................................
2. espconn_mdns_close!119 ...........................................................................
3. espconn_mdns_server_register!119 ............................................................
4. espconn_mdns_server_unregister!119 .........................................................
5. espconn_mdns_get_servername!120 ..........................................................
6. espconn_mdns_set_servername!120 ..........................................................
7. espconn_mdns_set_hostname!120 .............................................................
8. espconn_mdns_get_hostname!121 .............................................................
9. espconn_mdns_disable!121 ........................................................................
10. espconn_mdns_enable!121 .........................................................................
5. Application Related 122 ................................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 9 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
5.1. AT APIs!122"................................................................................................
1. at_response_ok!122 ....................................................................................
2. at_response_error!122 .................................................................................
3. at_cmd_array_regist!122 .............................................................................
4. at_get_next_int_dec!123 ..............................................................................
5. at_data_str_copy!123 ..................................................................................
6. at_init!124 ....................................................................................................
7. at_port_print!124 .........................................................................................
8. at_set_custom_info!124 ...............................................................................
9. at_enter_special_state!125 ..........................................................................
10. at_leave_special_state!125 ..........................................................................
11. at_get_version!125 ......................................................................................
12. at_register_uart_rx_intr!126 ..........................................................................
13. at_response!126 ..........................................................................................
14. at_register_response_func!127 ....................................................................
5.2. Related JSON APIs!128"..............................................................................
1. jsonparse_setup!128 ...................................................................................
2. jsonparse_next!128 .....................................................................................
3. jsonparse_copy_value!128 ...........................................................................
4. jsonparse_get_value_as_int!129 ..................................................................
5. jsonparse_get_value_as_long!129 ...............................................................
6. jsonparse_get_len!129 .................................................................................
7. jsonparse_get_value_as_type!130 ...............................................................
8. jsonparse_strcmp_value!130 .......................................................................
9. jsontree_set_up!130 ....................................................................................
10. jsontree_reset!131 .......................................................................................
11. jsontree_path_name!131 .............................................................................
12. jsontree_write_int!132 ..................................................................................
13. jsontree_write_int_array!132 ........................................................................
14. jsontree_write_string!132 .............................................................................
15. jsontree_print_next!133 ...............................................................................
16. jsontree_find_next!133 .................................................................................
6. Definitions & Structures 134 .........................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 10 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
6.1. Timer!134"....................................................................................................
6.2. WiFi Related Structures!134".......................................................................
1. Station Related!134 .....................................................................................
2. soft-AP related!134 ....................................................................................
3. scan related!135 ..........................................................................................
4. WiFi event related structure!135 ...................................................................
5. smart config structure!138 ...........................................................................
6.3. JSON Related Structure!138"......................................................................
1. json structure!138 ........................................................................................
2. json macro definition!139 .............................................................................
6.4. espconn parameters!140"............................................................................
1. callback function!140 ...................................................................................
2. espconn!140 ...............................................................................................
6.5. interrupt related definition!142"....................................................................
7. Peripheral Related Drivers 144 .....................................................................
7.1. GPIO Related APIs!144"..............................................................................
1. PIN Related Macros!144 ..............................................................................
2. gpio_output_set!144 ....................................................................................
3. GPIO input and output macro!145 ...............................................................
4. GPIO interrupt !145 .....................................................................................
5. gpio_pin_intr_state_set!145 .........................................................................
6. GPIO Interrupt Handler!146 .........................................................................
7.2. UART Related APIs!146"..............................................................................
1. uart_init!146 .................................................................................................
2. uart0_tx_buffer!147 ......................................................................................
3. uart0_rx_intr_handler!147 ............................................................................
7.3. I2C Master Related APIs!148".....................................................................
1. i2c_master_gpio_init!148 .............................................................................
2. i2c_master_init!148 ......................................................................................
3. i2c_master_start!148 ...................................................................................
4. i2c_master_stop!149 ...................................................................................
5. i2c_master_send_ack!149 ...........................................................................
6. i2c_master_send_nack!149 .........................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 11 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
7. i2c_master_checkAck!149 ...........................................................................
8. i2c_master_readByte!150 ............................................................................
9. i2c_master_writeByte!150 ............................................................................
7.4. PWM Related!151".......................................................................................
1. pwm_init!151 ...............................................................................................
2. pwm_start!152 ............................................................................................
3. pwm_set_duty!152 ......................................................................................
4. pwm_get_duty!152 ......................................................................................
5. pwm_set_period !153 ..................................................................................
6. pwm_get_period !153 ..................................................................................
7. get_pwm_version !153 ................................................................................
8. Appendix 154 ..................................................................................................
8.1. ESPCONN Programming!154".....................................................................
1. TCP Client Mode!154 ..................................................................................
2. TCP Server Mode!154 .................................................................................
3. espconn callback !155 .................................................................................
8.2. RTC APIs Example!155"..............................................................................
8.3. Snier Structure Introduction!157"..............................................................
8.4. ESP8266 soft-AP and station channel configuration!161"..........................
8.5. ESP8266 boot messages!162....................................................................
Espressif Systems Confidential / Friday, Aug 7, 2015 12 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
1. Preambles
ESP8266 WiFi SoC offers a complete and self-contained Wi-Fi networking solution; it can be used to
host applications or to offload Wi-Fi networking functions from another application processor. When
the ESP8266 hosts application, it boots up directly from an external flash. It has an integrated cache
to improve the performance of system’s running applications. Alternately, serving as a Wi-Fi adapter,
wireless internet access can be added into any microcontroller-based design with simple
connectivity through UART interface or the CPU AHB bridge interface.
ESP8266EX is amongst the most integrated WiFi chip in the industry; it integrates the antenna
switches, RF balun, power amplifier, low noise receive amplifier, filters, power management modules,
it requires minimal external circuitry, and the entire solution, including front-end module, is designed
to occupy minimal PCB area.
ESP8266EX also integrates an enhanced version of Tensilica’s L106 Diamond series 32-bit processor,
with on-chip SRAM, on top of its Wi-Fi functionalities. ESP8266EX is often integrated with external
sensors and other application specific devices through its GPIOs. Codes for such applications are
provided in examples in the SDK.
Sophisticated system-level features include fast sleep/wake switching for energy-efficient VoIP,
adaptive radio biasing for low-power operations, advanced signal processing, spur cancellation and
radio co-existence features for common cellular, Bluetooth, DDR, LVDS, LCD interference mitigation.
The SDK based on ESP8266 IoT platform offers users an easy, fast and efficient way to develop IoT
devices. This programming guide provides overview of the SDK as well as details on the API. It is
written for embedded software developers to help them program on ESP8266 IoT platform.
Espressif Systems Confidential / Friday, Aug 7, 2015 13 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
2. Overview
The SDK provides a set of interfaces for data receive and transmit functions over the Wi-Fi and TCP/
IP layers so programmers can focus on application development at a higher level. Users can easily
make use of the corresponding interfaces to receive and transmit data.
All networking functions on the ESP8266 IoT platform are realized in the library, and are not
transparent to users. Instead, users can initialize the interface in user_main.c.
void user_init(void) is the default method provided. Users can add functions like firmware
initialization, network parameters setting, and timer initialization in the interface.
void user_rf_pre_init(void) need to be added in user_main.c since SDK_v1.1.0, refers to the
IOT_Demo. It is provided for RF initialization. User can call system_phy_set_rfoption to set RF
option in user_rf_pre_init, or call system_deep_sleep_set_option before deep-sleep. If RF is
disabled, ESP8266 station and soft-AP will both be disabled, so please don’t call related APIs, and Wi-
Fi function can not be used either.
The SDK provides APIs to handle JSON, and users can also use self-defined data types to handle the
them.
Notice
Using non-OS SDK which is single-threaded, the CPU should not take long to execute tasks:
If a task occupies the CPU too long, ESP8266 can't feed the dog, it will cause a watchdog
reset
If interrupt is disabled, CPU can only be occupied in us range and the time should not be
more than 10 us; if interrupt is not disabled, it is suggested that CPU should not be
occupied more than 500 ms.
We suggest using a timer to check periodically, if users need to call os_delay_us or function
while, or function for in timer callback, please do not occupy CPU more than 10 ms.
Using non-OS SDK, please do not call any function defined with ICACHE_FLASH_ATTR in the
interrupt handler.
We suggest using RTOS SDK, RTOS to schedule different tasks.
Espressif Systems Confidential / Friday, Aug 7, 2015 14 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 15 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 16 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 17 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 18 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 19 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
3.3. System APIs
1. system_get_sdk_version
Function: !
Get SDK version
Prototype: !
const char* system_get_sdk_version(void)
Parameter: !
none
Return: !
SDK version
Example
os_printf(SDK version: %s \n, system_get_sdk_version());
2. system_restore
Function: !
Reset to default settings of following APIs wifi_station_set_auto_connect,
wifi_set_phy_mode, wifi_softap_set_config related, wifi_station_set_config
related, wifi_set_opmode, and APs information recorded by #define AP_CACHE
Prototype:!
void system_restore(void)
Parameters:!
null
Return:!
null
3. system_restart
Function: !
Restart
Prototype:!
void system_restart(void)
Parameters:!
null
Espressif Systems Confidential / Friday, Aug 7, 2015 20 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 21 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
system_get_vdd33 can only be called when TOUT pin is suspended
The 107th byte in esp_init_data_default.bin0󺗑127byteis named as
“vdd33_const“ , when TOUT pin is suspended vdd33_const must be set as
0xFF that is 255
Prototype: !
uint16 system_get_vdd33(void)
Parameter: !
none
Return: !
power voltage of VDD33, unit1/1024 V
7. system_adc_read
Function: !
Measure the input voltage of TOUT pin 6, unit1/1024 V
Note:
system_adc_read is only available when wire TOUT"pin to external
circuitry. Input Voltage Range"restricted to 0 ~ 1.0V.
The 107th byte in esp_init_data_default.bin(0󺗑127byte) is named as
“vdd33_const”, and when wire TOUT"pin to external circuitry, the
vdd33_const must be set as real power voltage of VDD3P3"pin 3 and 4.
The range of operating voltage of ESP8266 is 1.8V~3.6Vthe unit of
vdd33_const is 0.1Vso effective value range of vdd33_const is [18,
36]. If vdd33_const is an ineffective value which in [0, 18) or (36,
255), ESP8266 RF calibration will use 3.3V by default.
Prototype: !
uint16 system_adc_read(void)
Parameter: !
none
Return: !
input voltage of TOUT pin 6, unit1/1024 V
8. system_deep_sleep
Function: !
Configures chip for deep-sleep mode. When the device is in deep-sleep, it
automatically wakes up periodically; the period is configurable. Upon waking
up, the device boots up from user_init.
Espressif Systems Confidential / Friday, Aug 7, 2015 22 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 23 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 24 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 25 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 26 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 27 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 28 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 29 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 30 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 31 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 32 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 33 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 34 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 35 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 36 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 37 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 38 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 39 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 40 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 41 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 42 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 43 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 44 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 45 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 46 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 47 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 48 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 49 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 50 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 51 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 52 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 53 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 54 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 55 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 56 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 57 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 58 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 59 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 60 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 61 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 62 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 63 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 64 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 65 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 66 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 67 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 68 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 69 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 70 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 71 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 72 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 73 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 74 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 75 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 76 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 77 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 78 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 79 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 80 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 81 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 82 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 83 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 84 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 85 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 86 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 87 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 88 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 89 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 90 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 91 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 92 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 93 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 94 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 95 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 96 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 97 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 98 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 99 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 100 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 101 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 102 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 103 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 104 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 105 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 106 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 107 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 108 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 109 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 110 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 111 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 112 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 113 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 114 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 115 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 116 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 117 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 118 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 119 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 120 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 121 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 122 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 123 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 124 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 125 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 126 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 127 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 128 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 129 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 130 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 131 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 132 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 133 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 134 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 135 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 136 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 137 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 138 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 139 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 140 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 141 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 142 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 143 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 144 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 145 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 146 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 147 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 148 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 149 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 150 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 151 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 152 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 153 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
8. Appendix
8.1. ESPCONN Programming
1. TCP Client Mode
Notes
ESP8266, working in Station mode, will start client connections when given an IP address.
ESP8266, working in soft-AP mode, will start client connections when the devices connected
to the ESP8266 are given IP addresses.
Steps
Initialize espconn parameters according to protocols.
Register connect callback function, and register reconnect callback function.
(Call espconn_regist_connectcb and espconn_regist_reconcb )
Call espconn_connect function and set up the connection with TCP Server.
Registered connected callback functions will be called after successful connection, which will
register corresponding callback function. We recommend registering a disconnect callback
function.
(Call espconn_regist_recvcb , espconn_regist_sentcb and espconn_regist_disconcb
in connected callback)
When using receive callback function or sent callback function to run disconnect, it is
recommended to set a time delay to make sure that the all firmware functions are completed.
2. TCP Server Mode
Notes
If the ESP8266 is in Station mode, it will start server listening when given an IP address.
If the ESP8266 is in soft-AP mode, it will start server listening.
Steps
Initialize espconn parameters according to protocols.
Register connect callback and reconnect callback function.
(Call espconn_regist_connectcb and espconn_regist_reconcb )
Call espconn_accept function to listen to the connection with host.
Espressif Systems Confidential / Friday, Aug 7, 2015 154 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Register Function
Callback
Description
espconn_regist_connectcb
espconn_connect_callback
TCP connected successfully
espconn_regist_reconcb
espconn_reconnect_callback
Error occurTCP disconnected
espconn_regist_sentcb
espconn_sent_callback
Sent TCP or UDP data
espconn_regist_recvcb
espconn_recv_callback
Received TCP or UDP data
espconn_regist_write_finish
espconn_write_finish_callback
Write data into TCP-send-buffer
espconn_regist_disconcb
espconn_disconnect_callback
TCP disconnected successfully
Espressif Systems Confidential / Friday, Aug 7, 2015 155 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 156 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 157 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 158 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
Espressif Systems Confidential / Friday, Aug 7, 2015 159 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
LEN == X * 10
buf contains structure sniffer_buf: this structure is reliable, data packets represented by it
have been verified by CRC.
sniffer_buf.cnt shows the number of packets in buf. The value of len is decided by
sniffer_buf.cnt.
sniffer_buf.cnt==0, invalid buf; otherwise, len = 50 + cnt * 10
sniffer_buf.buf contains the first 36 bytes of IEEE80211 packet. Starting from
sniffer_buf.lenseq[0], each structure lenseq shows the length of a packet. lenseq[0]
shows the length of the first packet. If there are two packets where (sniffer_buf.cnt ==
2), lenseq[1] shows the length of the second packet.
If sniffer_buf.cnt > 1, it is a AMPDU packet. Because headers of each MPDU packets are
similar, we only provide the length of each packet (from the header of MAC packet to FCS)
This structure contains: length of packet, MAC address of both communication sides, length
of the packet header.
LEN == 12
buf contains structure RxControl; but this structure is not reliable. It cannot show the MAC
addresses of both communication sides, or the length of the packet header.
It does not show the number or the length of the sub-packets of AMPDU packets.
This structure contains: length of the packet, rssi and FEC_CODING.
RSSI and FEC_CODING are used to judge whether the packets are from the same device.
Summary
It is recommended that users speed up the processing of individual packets, otherwise, some follow-
up packets may be lost.
Format of an entire IEEE802.11 packet is shown as below.
The first 24 bytes of MAC header of the data packet are needed:
Address 4 field is decided by FromDS and ToDS in Frame Control;
Espressif Systems Confidential / Friday, Aug 7, 2015 160 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
QoS Control field is decided by Subtype in Frame Control;
HT Control field is decided by Order Field in Frame Control;
For more details, refer to IEEE Std 80211-2012.
For WEP encrypted packets, the MAC header is followed by an 4-byte IV, and there is a 4-
byte ICV before the FCS.
For TKIP encrypted packets, the MAC header is followed by a 4-byte IV and a 4-byte EIV, and
there are an 8-byte MIC and a 4-byte ICV before the FCS.
For CCMP encrypted packets, the MAC header is followed by an 8-byte CCMP header, and
there is an 8-byte MIC before the FCS.
8.4. ESP8266 soft-AP and station channel configuration
Even though ESP8266 supports the softAP+station mode, it is limited to only one hardware channel.
In the softAP+station mode, the ESP8266 soft-AP will adjust its channel configuration to be same as
the ESP8266 station.
This limitation may cause some inconveniences in the softAP+station mode that users need to pay
special attention to, for example:
Case 1:
(1) When the user connects the ESP8266 to a router (for example, channel 6),
(2) and sets the ESP8266 soft-AP through wifi_softap_set_config,
(3) If the value is effective, the API will return to true. However, the channel will be automatically
adjusted to channel 6 in order to be in line with the ESP8266 station interface. This is because
there is only one hardware channel in this mode.
Case 2:
(1) If the user sets the channel of the ESP8266 soft-AP through wifi_softap_set_config (for
example, channel 5),
(2) other stations will connect to the ESP8266 soft-AP,
(3) then the user connects the ESP8266 station to a router (for example, channel 6),
(4) the ESP8266 softAP will adjust its channel to be as same as the ESP8266 station (which is
channel 6 in this case).
(5) As a result of the change of channel, the station Wi-Fi connected to the ESP8266 soft-AP in
step two will be disconnected.
Case 3:
(1) Other stations are connected to the ESP8266 softAP .
Espressif Systems Confidential / Friday, Aug 7, 2015 161 162
! ! " !
Espressif Systems
ESP8266 SDK Programming Guide
(2) If the ESP8266‘s station interface has been scanning or trying to connect to a target router, the
ESP8266 softAP-end connection may break.
This is because the ESP8266 station will try to find its target router in different channels, which means
it will keep changing channels, and as a result, the ESP8266 channel is changing, too. Therefore, the
ESP8266 softAP-end connection may break.
In cases like this, users can set a timer to call wifi_station_disconnect to stop the ESP8266 station
from continuously trying to connect to the router. Or use wifi_station_set_reconnect_policy or
wifi_station_set_auto_connect to disable the ESP8266 station from reconnecting to the router.
8.5. ESP8266 boot messages
ESP8266 outputs boot messages through UART0 with baud rate 74880:
Messages
Description
rst cause
1: power on
2: external reset
4: hardware watchdog-reset
boot mode
(first parameter)
1 ESP8266 is in UART-down mode (download firmware into Flash)
2 ESP8266 is in Flash-boot mode (boot up from Flash)
chksum
If chksum == csum, it means that read Flash correctly during booting.
Espressif Systems Confidential / Friday, Aug 7, 2015 162 162

Navigation menu