WGM110 API Reference Manual

WGM110 API Reference Manual
This document contains the full API reference for the Wizard Gecko
WGM110 Wi-Fi Module, firmware version 1.0.0.
The Wizard Gecko family of the Silicon Labs' Wi-Fi modules deliver
a high-performance, low energy and easy-to-use Wi-Fi solution
integrated into a small form factor package. Wizard Gecko Wi-Fi
modules combine an integrated antenna, a high-performance Wi-Fi
transceiver, an energy efficient 32-bit MCU and ready to use Wi-Fi
software and SDK.
silabs.com | Smart. Connected. Energy-friendly.
KEY POINTS
• Wizard Gecko SDK v1.0.0
API Reference Manual for
the WGM110 Wi-Fi Module
Rev. 1.1
WGM110 API Reference Manual
Table of Contents
1. Introduction to Wizard Gecko Software Architecture
. . . . . . . . . . . . . . . . 1
1.1 Wizard Gecko Wi-Fi BGAPI™ Protocol .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 1
1.2 Wizard Gecko BGLib™ Library .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 3
1.3 Wizard Gecko BGScript™ Scripting Language .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 3
1.4 Wizard Gecko Wi-FI Stack and Endpoints
1.4.1 Using Endpoints . . . . . . . .
1.4.2 Predefined Endpoints. . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 4
. 5
. 6
.
.
.
.
.
.
.
.
.
2. API Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 BGAPI Protocol Definition . . .
2.1.1 Packet Format . . . . . .
2.1.2 Message Types . . . . .
2.1.3 Command Class IDs . . . .
2.1.4 Packet Exchange . . . . .
2.1.5 Introduction to BGAPI over SPI
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2.2 BGLib Functions Definition
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 9
2.3 BGScript API Definition.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 9
2.4 Data Types .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 9
.
.
.
.
7
7
7
8
8
8
3. API Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.1 Configuration Command Class
3.1.1 config commands . . . .
3.1.1.1 cmd_config_get_mac . .
3.1.1.2 cmd_config_set_mac . .
3.1.2 config events . . . . .
3.1.2.1 evt_config_mac_address .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.12
.12
.13
.14
.14
.15
3.2 Device Firmware Upgrade (DFU) Command Class
3.2.1 dfu commands . . . . . . . . . . . .
3.2.1.1 cmd_dfu_flash_set_address . . . . . . .
3.2.1.2 cmd_dfu_flash_upload . . . . . . . .
3.2.1.3 cmd_dfu_flash_upload_finish . . . . . .
3.2.1.4 cmd_dfu_reset . . . . . . . . . . .
3.2.2 dfu events . . . . . . . . . . . . .
3.2.2.1 evt_dfu_boot . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.16
.17
.18
.19
.20
.21
.21
.22
3.3 Endpoint Command Class. . . . . . .
3.3.1 endpoint commands . . . . . . . .
3.3.1.1 cmd_endpoint_close . . . . . . .
3.3.1.2 cmd_endpoint_disable. . . . . . .
3.3.1.3 cmd_endpoint_send . . . . . . .
3.3.1.4 cmd_endpoint_set_active . . . . .
3.3.1.5 cmd_endpoint_set_streaming . . . .
3.3.1.6 cmd_endpoint_set_streaming_destination
3.3.1.7 cmd_endpoint_set_transmit_size . . .
3.3.2 endpoint events . . . . . . . . .
3.3.2.1 evt_endpoint_closing . . . . . . .
3.3.2.2 evt_endpoint_data . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.22
.23
.24
.26
.27
.28
.30
.32
.34
.35
.35
.36
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Table of Contents
ii
WGM110 API Reference Manual
3.3.2.3 evt_endpoint_error . . .
3.3.2.4 evt_endpoint_status . .
3.3.2.5 evt_endpoint_syntax_error
3.3.3 endpoint enumerations . .
3.3.3.1 enum_endpoint_type . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.37
.38
.39
.39
.40
3.4 Persistent Store Command Class
3.4.1 flash commands . . . . .
3.4.1.1 cmd_flash_ps_defrag . . .
3.4.1.2 cmd_flash_ps_dump . . .
3.4.1.3 cmd_flash_ps_erase . . .
3.4.1.4 cmd_flash_ps_erase_all . .
3.4.1.5 cmd_flash_ps_load . . . .
3.4.1.6 cmd_flash_ps_save . . .
3.4.2 flash events . . . . . . .
3.4.2.1 evt_flash_ps_key . . . .
3.4.2.2 evt_flash_ps_key_changed .
3.4.3 flash defines . . . . . . .
3.4.3.1 define_flash_ps_keys . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.40
.40
.41
.42
.43
.44
.45
.46
.47
.47
.48
.48
.49
3.5 Hardware Command Class . . . . . .
3.5.1 hardware commands . . . . . . . .
3.5.1.1 cmd_hardware_adc_read . . . . .
3.5.1.2 cmd_hardware_configure_gpio . . . .
3.5.1.3 cmd_hardware_configure_gpio_interrupt
3.5.1.4 cmd_hardware_read_gpio . . . . .
3.5.1.5 cmd_hardware_rtc_get_time . . . .
3.5.1.6 cmd_hardware_rtc_init . . . . . .
3.5.1.7 cmd_hardware_rtc_set_alarm . . . .
3.5.1.8 cmd_hardware_rtc_set_time. . . . .
3.5.1.9 cmd_hardware_set_soft_timer . . . .
3.5.1.10 cmd_hardware_spi_transfer . . . .
3.5.1.11 cmd_hardware_timer_init . . . . .
3.5.1.12 cmd_hardware_timer_initcc . . . .
3.5.1.13 cmd_hardware_write_gpio . . . . .
3.5.2 hardware events . . . . . . . . .
3.5.2.1 evt_hardware_interrupt . . . . . .
3.5.2.2 evt_hardware_rtc_alarm . . . . . .
3.5.2.3 evt_hardware_soft_timer . . . . . .
3.5.3 hardware enumerations . . . . . . .
3.5.3.1 enum_hardware_adc_input . . . . .
3.5.3.2 enum_hardware_gpio_mode . . . .
3.5.3.3 enum_hardware_gpio_port . . . . .
3.5.3.4 enum_hardware_gpio_trigger . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.50
.51
.52
.53
.55
.56
.58
.60
.61
.63
.65
.67
.68
.70
.72
.73
.73
.74
.74
.75
.75
.75
.75
.76
3.6 HTTP Server Command Class . .
3.6.1 https commands . . . . . .
3.6.1.1 cmd_https_add_path . . . .
3.6.1.2 cmd_https_api_response . . .
3.6.1.3 cmd_https_api_response_finish
3.6.1.4 cmd_https_enable . . . . .
3.6.2 https events . . . . . . . .
3.6.2.1 evt_https_api_request . . . .
3.6.2.2 evt_https_api_request_data . .
3.6.2.3 evt_https_api_request_finished.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.76
.76
.77
.78
.79
.80
.81
.81
.82
.83
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Table of Contents
iii
WGM110 API Reference Manual
3.6.2.4 evt_https_api_request_header .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.84
3.7 I2C Command Class .
3.7.1 i2c commands . . .
3.7.1.1 cmd_i2c_start_read
3.7.1.2 cmd_i2c_start_write
3.7.1.3 cmd_i2c_stop. . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.85
.85
.86
.87
.88
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3.8 SDCard Command Class . . . . . . . . . . . . . . . . . . . . . . . . . .89
3.8.1 sdhc commands . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
3.8.1.1 cmd_sdhc_fchdir . . . . . . . . . . . . . . . . . . . . . . . . . . .91
3.8.1.2 cmd_sdhc_fchmode . . . . . . . . . . . . . . . . . . . . . . . . . .92
3.8.1.3 cmd_sdhc_fclose . . . . . . . . . . . . . . . . . . . . . . . . . . .93
3.8.1.4 cmd_sdhc_fdelete . . . . . . . . . . . . . . . . . . . . . . . . . . .94
3.8.1.5 cmd_sdhc_fdir . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
3.8.1.6 cmd_sdhc_fmkdir . . . . . . . . . . . . . . . . . . . . . . . . . . .96
3.8.1.7 cmd_sdhc_fopen . . . . . . . . . . . . . . . . . . . . . . . . . . .97
3.8.1.8 cmd_sdhc_fread. . . . . . . . . . . . . . . . . . . . . . . . . . . .99
3.8.1.9 cmd_sdhc_frename
. . . . . . . . . . . . . . . . . . . . . . . . 100
.
3.8.1.10 cmd_sdhc_fwrite . . . . . . . . . . . . . . . . . . . . . . . . . .101
3.8.2 sdhc events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.8.2.1 evt_sdhc_fdata . . . . . . . . . . . . . . . . . . . . . . . . . . .102
3.8.2.2 evt_sdhc_ffile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.8.2.3 evt_sdhc_fpwd
. . . . . . . . . . . . . . . . . . . . . . . . . . .104
3.8.2.4 evt_sdhc_ready . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.9 Wi-Fi Command Class . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.9.1 sme commands
. . . . . . . . . . . . . . . . . . . . . . . . . . 107
.
3.9.1.1 cmd_sme_ap_client_disconnect
. . . . . . . . . . . . . . . . . . . . .108
3.9.1.2 cmd_sme_connect_bssid . . . . . . . . . . . . . . . . . . . . . . . . 109
3.9.1.3 cmd_sme_connect_ssid . . . . . . . . . . . . . . . . . . . . . . . . 111
3.9.1.4 cmd_sme_disconnect . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.9.1.5 cmd_sme_get_signal_quality
. . . . . . . . . . . . . . . . . . . . . .115
3.9.1.6 cmd_sme_scan_results_sort_rssi . . . . . . . . . . . . . . . . . . . . . 116
3.9.1.7 cmd_sme_set_11n_mode
. . . . . . . . . . . . . . . . . . . . . . 1. 18
3.9.1.8 cmd_sme_set_ap_hidden
. . . . . . . . . . . . . . . . . . . . . . 119
.
3.9.1.9 cmd_sme_set_ap_max_clients . . . . . . . . . . . . . . . . . . . . . . 120
3.9.1.10 cmd_sme_set_ap_password . . . . . . . . . . . . . . . . . . . . . . 121
3.9.1.11 cmd_sme_set_eap_configuration
. . . . . . . . . . . . . . . . . . . 122
.
3.9.1.12 cmd_sme_set_eap_type_ca_certificate
. . . . . . . . . . . . . . . . . 123
.
3.9.1.13 cmd_sme_set_eap_type_password . . . . . . . . . . . . . . . . . . . . 124
3.9.1.14 cmd_sme_set_eap_type_server_common_name . . . . . . . . . . . . . . .125
3.9.1.15 cmd_sme_set_eap_type_user_certificate . . . . . . . . . . . . . . . . . . 126
3.9.1.16 cmd_sme_set_eap_type_username. . . . . . . . . . . . . . . . . . . . 127
3.9.1.17 cmd_sme_set_operating_mode . . . . . . . . . . . . . . . . . . . . . 128
3.9.1.18 cmd_sme_set_password
. . . . . . . . . . . . . . . . . . . . . . .129
3.9.1.19 cmd_sme_set_scan_channels
. . . . . . . . . . . . . . . . . . . . 130
.
3.9.1.20 cmd_sme_start_ap_mode . . . . . . . . . . . . . . . . . . . . . . . 131
3.9.1.21 cmd_sme_start_scan
. . . . . . . . . . . . . . . . . . . . . . . 133
.
3.9.1.22 cmd_sme_start_ssid_scan . . . . . . . . . . . . . . . . . . . . . . . 135
3.9.1.23 cmd_sme_start_wps . . . . . . . . . . . . . . . . . . . . . . . . . 137
3.9.1.24 cmd_sme_stop_ap_mode . . . . . . . . . . . . . . . . . . . . . . . 139
3.9.1.25 cmd_sme_stop_scan. . . . . . . . . . . . . . . . . . . . . . . . . 140
3.9.1.26 cmd_sme_stop_wps . . . . . . . . . . . . . . . . . . . . . . . . . 141
3.9.1.27 cmd_sme_wifi_off . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Table of Contents
iv
WGM110 API Reference Manual
3.9.1.28 cmd_sme_wifi_on . . . . . . . . . . . . . . . . . . . . . . . . . . 143
3.9.2 sme events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
3.9.2.1 evt_sme_ap_client_joined
. . . . . . . . . . . . . . . . . . . . . . 1
. 44
3.9.2.2 evt_sme_ap_client_left
. . . . . . . . . . . . . . . . . . . . . . . 1. 45
3.9.2.3 evt_sme_ap_mode_failed
. . . . . . . . . . . . . . . . . . . . . . 146
.
3.9.2.4 evt_sme_ap_mode_started . . . . . . . . . . . . . . . . . . . . . . . 147
3.9.2.5 evt_sme_ap_mode_stopped. . . . . . . . . . . . . . . . . . . . . . . 148
3.9.2.6 evt_sme_connect_failed . . . . . . . . . . . . . . . . . . . . . . . . 149
3.9.2.7 evt_sme_connect_retry
. . . . . . . . . . . . . . . . . . . . . . . .150
3.9.2.8 evt_sme_connected
. . . . . . . . . . . . . . . . . . . . . . . . 1. 51
3.9.2.9 evt_sme_disconnected
. . . . . . . . . . . . . . . . . . . . . . . 1. 52
3.9.2.10 evt_sme_interface_status . . . . . . . . . . . . . . . . . . . . . . .153
3.9.2.11 evt_sme_scan_result. . . . . . . . . . . . . . . . . . . . . . . . . 154
3.9.2.12 evt_sme_scan_result_drop . . . . . . . . . . . . . . . . . . . . . . . 155
3.9.2.13 evt_sme_scan_sort_finished . . . . . . . . . . . . . . . . . . . . . .156
3.9.2.14 evt_sme_scan_sort_result . . . . . . . . . . . . . . . . . . . . . . . 157
3.9.2.15 evt_sme_scanned . . . . . . . . . . . . . . . . . . . . . . . . . . 158
3.9.2.16 evt_sme_signal_quality . . . . . . . . . . . . . . . . . . . . . . . . 159
3.9.2.17 evt_sme_wifi_is_off
. . . . . . . . . . . . . . . . . . . . . . . . .160
3.9.2.18 evt_sme_wifi_is_on
. . . . . . . . . . . . . . . . . . . . . . . . .161
3.9.2.19 evt_sme_wps_completed
. . . . . . . . . . . . . . . . . . . . . . .162
3.9.2.20 evt_sme_wps_credential_password . . . . . . . . . . . . . . . . . . . . 163
3.9.2.21 evt_sme_wps_credential_ssid. . . . . . . . . . . . . . . . . . . . . . 164
3.9.2.22 evt_sme_wps_failed . . . . . . . . . . . . . . . . . . . . . . . . . 165
3.9.2.23 evt_sme_wps_stopped . . . . . . . . . . . . . . . . . . . . . . . . 166
3.9.3 sme enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
3.9.3.1 enum_sme_eap_type . . . . . . . . . . . . . . . . . . . . . . . . . 166
3.10 System Class Commands
. . . . . . . . . . . . . . . . . . . . . . . .167
3.10.1 system commands . . . . . . . . . . . . . . . . . . . . . . . . . .168
3.10.1.1 cmd_system_hello
. . . . . . . . . . . . . . . . . . . . . . . . 168
.
3.10.1.2 cmd_system_reset
. . . . . . . . . . . . . . . . . . . . . . . . 1. 69
3.10.1.3 cmd_system_set_max_power_saving_state . . . . . . . . . . . . . . . . . 170
3.10.1.4 cmd_system_sync
. . . . . . . . . . . . . . . . . . . . . . . . 171
.
3.10.2 system events . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
3.10.2.1 evt_system_boot . . . . . . . . . . . . . . . . . . . . . . . . . . 172
3.10.2.2 evt_system_power_saving_state . . . . . . . . . . . . . . . . . . . . . 173
3.10.2.3 evt_system_sw_exception . . . . . . . . . . . . . . . . . . . . . . . 174
3.10.3 system enumerations
. . . . . . . . . . . . . . . . . . . . . . . . .174
3.10.3.1 enum_system_power_saving_state . . . . . . . . . . . . . . . . . . . . 175
3.11 TCP Stack Command Class
. . . . . . . . . . . . . . . . . . . . . . 176
.
3.11.1 tcpip commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
3.11.1.1 cmd_tcpip_configure . . . . . . . . . . . . . . . . . . . . . . . . . 178
3.11.1.2 cmd_tcpip_dhcp_enable_routing . . . . . . . . . . . . . . . . . . . . . 180
3.11.1.3 cmd_tcpip_dhcp_set_hostname . . . . . . . . . . . . . . . . . . . . . 181
3.11.1.4 cmd_tcpip_dns_configure . . . . . . . . . . . . . . . . . . . . . . .182
3.11.1.5 cmd_tcpip_dns_gethostbyname . . . . . . . . . . . . . . . . . . . . . 184
3.11.1.6 cmd_tcpip_dnssd_add_service
. . . . . . . . . . . . . . . . . . . . .185
3.11.1.7 cmd_tcpip_dnssd_add_service_attribute . . . . . . . . . . . . . . . . . . 186
3.11.1.8 cmd_tcpip_dnssd_add_service_instance . . . . . . . . . . . . . . . . . . 187
3.11.1.9 cmd_tcpip_dnssd_remove_service . . . . . . . . . . . . . . . . . . . . 188
3.11.1.10 cmd_tcpip_dnssd_start_service . . . . . . . . . . . . . . . . . . . . . 189
3.11.1.11 cmd_tcpip_dnssd_stop_service . . . . . . . . . . . . . . . . . . . . . 190
3.11.1.12 cmd_tcpip_mdns_set_hostname
. . . . . . . . . . . . . . . . . . . .191
Table of Contents
v
WGM110 API Reference Manual
3.11.1.13 cmd_tcpip_mdns_start . . . . . . . . . . . . . . . . . . . . . . . . 192
3.11.1.14 cmd_tcpip_mdns_stop . . . . . . . . . . . . . . . . . . . . . . . . 193
3.11.1.15 cmd_tcpip_multicast_join . . . . . . . . . . . . . . . . . . . . . . . 194
3.11.1.16 cmd_tcpip_multicast_leave
. . . . . . . . . . . . . . . . . . . . . .195
3.11.1.17 cmd_tcpip_start_tcp_server . . . . . . . . . . . . . . . . . . . . . . 196
3.11.1.18 cmd_tcpip_start_udp_server . . . . . . . . . . . . . . . . . . . . . . 198
3.11.1.19 cmd_tcpip_tcp_connect
. . . . . . . . . . . . . . . . . . . . . . .200
3.11.1.20 cmd_tcpip_tls_connect. . . . . . . . . . . . . . . . . . . . . . . . 202
3.11.1.21 cmd_tcpip_tls_set_authmode
. . . . . . . . . . . . . . . . . . . . 2
. 04
3.11.1.22 cmd_tcpip_tls_set_user_certificate. . . . . . . . . . . . . . . . . . . . 205
3.11.1.23 cmd_tcpip_udp_bind
. . . . . . . . . . . . . . . . . . . . . . . .206
3.11.1.24 cmd_tcpip_udp_connect . . . . . . . . . . . . . . . . . . . . . . .207
3.11.2 tcpip events
. . . . . . . . . . . . . . . . . . . . . . . . . . . 2. 08
3.11.2.1 evt_tcpip_configuration . . . . . . . . . . . . . . . . . . . . . . . . 208
3.11.2.2 evt_tcpip_dns_configuration
. . . . . . . . . . . . . . . . . . . . . .209
3.11.2.3 evt_tcpip_dns_gethostbyname_result . . . . . . . . . . . . . . . . . . . 210
3.11.2.4 evt_tcpip_dnssd_service_failed . . . . . . . . . . . . . . . . . . . . .211
3.11.2.5 evt_tcpip_dnssd_service_started . . . . . . . . . . . . . . . . . . . . . 212
3.11.2.6 evt_tcpip_dnssd_service_stopped
. . . . . . . . . . . . . . . . . . . .213
3.11.2.7 evt_tcpip_endpoint_status . . . . . . . . . . . . . . . . . . . . . . . 214
3.11.2.8 evt_tcpip_mdns_failed
. . . . . . . . . . . . . . . . . . . . . . . .215
3.11.2.9 evt_tcpip_mdns_started . . . . . . . . . . . . . . . . . . . . . . . . 216
3.11.2.10 evt_tcpip_mdns_stopped . . . . . . . . . . . . . . . . . . . . . . . 217
3.11.2.11 evt_tcpip_tls_verify_result. . . . . . . . . . . . . . . . . . . . . . . 218
3.11.2.12 evt_tcpip_udp_data . . . . . . . . . . . . . . . . . . . . . . . . . 219
3.12 Utilities for BGScript Command Class
. . . . . . . . . . . . . . . . . . .
3.12.1 util commands. . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.12.1.1 cmd_util_atoi
. . . . . . . . . . . . . . . . . . . . . . . . . .
3.12.1.2 cmd_util_itoa
. . . . . . . . . . . . . . . . . . . . . . . . . .
.219
219
.220
.221
3.13 X.509 Command Class
. . . . . . . . . . . . . . . . . . . . . . . . .222
3.13.1 x509 commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
3.13.1.1 cmd_x509_add_certificate . . . . . . . . . . . . . . . . . . . . . . . 223
3.13.1.2 cmd_x509_add_certificate_data . . . . . . . . . . . . . . . . . . . . . 224
3.13.1.3 cmd_x509_add_certificate_finish . . . . . . . . . . . . . . . . . . . . . 225
3.13.1.4 cmd_x509_add_private_key
. . . . . . . . . . . . . . . . . . . . . .226
3.13.1.5 cmd_x509_add_private_key_data
. . . . . . . . . . . . . . . . . . . .227
3.13.1.6 cmd_x509_add_private_key_finish . . . . . . . . . . . . . . . . . . . . 228
3.13.1.7 cmd_x509_delete_certificate . . . . . . . . . . . . . . . . . . . . . . 229
3.13.1.8 cmd_x509_list_certificates . . . . . . . . . . . . . . . . . . . . . . . 230
3.13.1.9 cmd_x509_reset_store . . . . . . . . . . . . . . . . . . . . . . . . 231
3.13.2 x509 events
. . . . . . . . . . . . . . . . . . . . . . . . . . . 2
. 31
3.13.2.1 evt_x509_certificate . . . . . . . . . . . . . . . . . . . . . . . . . 232
3.13.2.2 evt_x509_certificate_subject . . . . . . . . . . . . . . . . . . . . . .233
3.13.2.3 evt_x509_certificates_listed
. . . . . . . . . . . . . . . . . . . . . 2
. 34
3.13.3 x509 enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . 234
3.13.3.1 enum_x509_store . . . . . . . . . . . . . . . . . . . . . . . . . . 234
3.13.3.2 enum_x509_type . . . . . . . . . . . . . . . . . . . . . . . . . . 234
3.14 Error codes
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.234
4. Document Revision History . . . . . . . . . . . . . . . . . . . . . . . . . 237
Table of Contents
vi
WGM110 API Reference Manual
Introduction to Wizard Gecko Software Architecture
1. Introduction to Wizard Gecko Software Architecture
The Silicon Labs Wizard Gecko WGM110 Wi-Fi Module contains a complete 802.11 MAC and IP networking stack, providing everything required for creating wireless devices that works together with existing Wi-Fi infrastructure and devices.
Wizard Gecko software supports three different modes of use:
• Standalone mode: all software including the application software runs on the Wizard Gecko Module.
• Hosted mode: an external host runs the application software which controls the Wizard Gecko Device using a well-defined binary
based transport protocol called BGAPI™.
• Mixed mode: a part of the application runs on the Wizard Gecko Module while the rest of the application runs on an external host.
In all of these cases, the Wizard Gecko software provides a complete 802.11 MAC and IP networking stack, additional 802.11 or IP
stack software is not required, which enables simple and fast application development.
The figure below shows both the standalone and mixed mode stack architectures.
Figure 1.1. Wizard Gecko Software Architecture
1.1 Wizard Gecko Wi-Fi BGAPI™ Protocol
For applications, where a separate host (MCU) is used to implement the end user application, a transport protocol is needed between
the host and the Wizard Gecko Wi-Fi stack. This transport protocol is used to communicate with the Wi-Fi stack as well to transmit and
receive data packets. This protocol is called BGAPI and it is a binary communication protocol designed specifically to ease integration
with external host devices having limited resources.
The BGAPI protocol provides access to layers (also referred to as command classes) listed in the following table.
Table 1.1. BGAPI Protocol Layers (Command Classes)
BGAPI Layer
Description
System
Various system functions, such as querying the hardware status or system reset
Configuration
Provides access to the device parameters such as the MAC address
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 1
WGM110 API Reference Manual
Introduction to Wizard Gecko Software Architecture
BGAPI Layer
Description
TCP/IP
Gives access to the TCP/IP stack and various protocols like TCP and UDP
SME
Provides access to 802.11 MAC and procedures like Access Point discovery
Endpoint
Provides functions for controlling the data and peripheral endpoints
Hardware
An interface for accessing the various hardware modules such as timers and ADC
Persistent Store
Allows the user to read/write from/to non-volatile memory
Device Firmware Upgrade
Provides access to firmware update functions
I2C
An interface for accessing I2C functionality
HTTP Server
Provides functions for interfacing with the built-in HTTP Server
X.509
Allows the user to manage the X.509 certificate store
SD Card
Gives access to the built-in SD card functions
Util
Provides helper functions for BGScript development
Note: BGAPI protocol is designed to be used over UART, SPI or USB.
The BGAPI protocol is a command - response type protocol similar to AT commands. BGAPI uses binary format instead of the ASCII
format. The basic principle of BGAPI messaging is shown in the the next figure. The user must wait for a response after sending each
command and before issuing the next command. Some commands also invoke events. The BGAPI packet format uses a single bit to
identify between commands/responses (0x08) and events (0x88) as shown in the figure below.
Figure 1.2. BGAPI Messaging is Based on the Command - Response - Event Principle
Note: When sending commands over BGAPI you always have to wait for the BGAPI response before issuing a new command to the
Module.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 2
WGM110 API Reference Manual
Introduction to Wizard Gecko Software Architecture
1.2 Wizard Gecko BGLib™ Library
To enable easy development using the BGAPI protocol, a C host library is provided. This library is based on easily portable ANSI C
code, which is delivered as part of the Wizard Gecko Software Development Kit (SDK). The purpose of the BGLib library is to simplify
application development within different host environments.
Figure 1.3. Purpose of BGLib in the Wizard Gecko Software Architecture
1.3 Wizard Gecko BGScript™ Scripting Language
Wizard Gecko software allows BGScript application developers to create standalone devices without the need for a separate host. The
Wizard Gecko Module can run BGScript applications along the Module software stack and this is beneficial in cases where the end
product size, cost and current consumption needs to be minimized. BGScript provides access to the same software and hardware interfaces as the BGAPI protocol. BGScript code can be developed and compiled with free tools provided as part of the Wizard Gecko Software Development Kit.
The purpose of the BGScript scripting language in the Wizard Gecko Software Architecture is to enable software applications to run
inside the Module and without the need for an external host, as shown in the following figure.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 3
WGM110 API Reference Manual
Introduction to Wizard Gecko Software Architecture
Figure 1.4. Purpose of BGScript in the Wizard Gecko Software Architecture
For more information on BGScript, its use and example applications please see the UG170: Wizard Gecko BGScript™ User's Guide.
This guide also contains a short description on the benefits and limitations of BGScript as a guidance to designers contemplating the
question whether to start application development based on a standalone or host architecture approach.
1.4 Wizard Gecko Wi-FI Stack and Endpoints
This section describes how endpoints are used in the Wizard Gecko Wi-Fi stack.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 4
WGM110 API Reference Manual
Introduction to Wizard Gecko Software Architecture
1.4.1 Using Endpoints
Endpoints is the mechanism to route data traffic between destinations, i.e. it is a flexible tool to manage from where the data originates
and where it will be sent. Each endpoint has an Endpoint type (e.g. UART, TCP Server or BGScript) enumerated by the Endpoint type
number, which defines the endpoint characteristics.
Each time a new endpoint is created it gets a unique Endpoint index assigned by the Wi-Fi module. Some Endpoint types have fixed
Endpoint indexes, while others get the index number generated on a demand basis. Examples of endpoints with fixed index numbers
are UART, USB and BGScript.
A good example of a dynamically allocated Endpoint index is when a new TCP Server is created. Upon an incoming TCP connection
the Wi-Fi Module will look at what the next available Endpoint index is, and give the new connection the first available index. This
TCP/IP connection is also called a socket. In the future if any data needs to be written to that socket, it is done by writing to the specific
Endpoint index. Since the socket also receives incoming data, the endpoint for where that data is routed is configurable.
It is important to understand that with bi-directional peripherals, such as a serial port or a TCP socket where data can move both into
and out of the Wi-Fi Module, the connection is configured by defining the source and destination for each endpoint link. For example, in
order to route the data in both directions between a serial port and a TCP socket, the serial port is configured to have the socket as its
endpoint, and the socket is configured to have the serial port as its endpoint.
A typical peripheral (SPI, UART or USB) endpoint will automatically route data to its configured endpoint using BGAPI framing. However, for UART endpoints, it is possible to make the streaming (raw data) endpoint by setting the UART parameter api to "false" in the
project configuration file. During runtime streaming mode enabling is done using the BGAPI command cmd_endpoint_set_streaming.
Figure 1.5. Bi-Directional Streaming in Standalone Mode
If an external microcontroller (MCU) is used, the setup could look quite similar. In the next figure, the data from the Server would get
sent to the MCU, and the sensor would send its data straight to the Server.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 5
WGM110 API Reference Manual
Introduction to Wizard Gecko Software Architecture
Figure 1.6. Bi-Directional Streaming in Mixed Mode
1.4.2 Predefined Endpoints
Wizard Gecko Wi-Fi stack contains several predefined endpoints which are automatically reserved to provide access to some of the
Module's hardware interfaces.
For more information on endpoints see the related Command Class Description section Endpoints in this manual.
Table 1.2. Endpoint Mappings
Endpoint type
Endpoint type number
Endpoint index
Endpoint index details
Free
0
0 - 30
-
UART
1
USART0: 0
Depends on the USART module
used
USART1: 1
USB
2
3
-
TCP Client
4
0 - 30
Dynamically assigned
TCP Server
8
0 - 30
Dynamically assigned
UDP Client
16
0 - 30
Dynamically assigned
UDP Server
32
0 - 30
Dynamically assigned
BGScript
64
2
-
Waiting for closing
128
0 - 30
-
SPI
256
USART0: 0
Depends on the USART module
used
USART1: 1
Drop
1024
31
-
TLS Client
2048
0 - 30
Dynamically assigned
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 6
WGM110 API Reference Manual
API Definition
2. API Definition
This section contains the generic Wizard Gecko Wi-Fi software API definition. The definition consists of three parts:
• BGAPI protocol definition
• BGLib C library description
• BGScript scripting API description
This section of the document only provides the generic definition and description of the API. The actual commands, responses and
events are described in the API Reference section of this manual.
2.1 BGAPI Protocol Definition
For applications, where a separate host is used to implement the application, a transport protocol is required between the host and the
Wizard Gecko Module. The transport protocol is used for controlling the Module software as well as for transmitting and receiving data
packets. This protocol is called BGAPI. It is a binary based communication protocol designed specifically for ease of implementation
within host devices with limited resources.
The BGAPI protocol is available on these peripheral interfaces:
• UART
• SPI (Wizard Gecko Module as the slave and external host as the master)
• USB (Wizard Gecko Module as the device and external host as the host)
Note: The BGAPI transport protocol must explicitly be configured to be in use for the intended host interface, when using the Wi-Fi
module in Network Co-Processor mode. For more details see the Module Configuration User's Guide of the Module.
2.1.1 Packet Format
Packets in either direction use the format indicated in the table below.
Table 2.1. BGAPI Packet Format
Octet
Octet bits
Length
Description
Octet 0
7
Message Type (MT)
0: Command/Response
1: Event
-
6:3
Technology Type (TT)
0001: Wi-Fi
-
2:0
Length High (LH)
Payload length (high bits)
Octet 1
7:0
Length Low (LL)
Payload length (low bits)
Octet 2
7:0
Class ID (CID)
Command class ID
Octet 3
7:0
Command ID (CMD)
Command ID
Octet 4 + N
-
Payload (PL)
Up to 2047 bytes of payload
0 ≤ N ≤ 2047
N = (LH << 8) | LL
Note: N is an 11 bit value which is
formed by left shifting LH and ORing with LL.
2.1.2 Message Types
BGAPI protocol includes the message types listed in the following table.
Note: Command and Response types have the same value by purpose.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 7
WGM110 API Reference Manual
API Definition
Table 2.2. BGAPI Message Types
Message Type (MT) + Technology Type (TT)
Value
Description
Command
0x08
Command from the host to the Module
Response
0x08
Response from the Module to the host
Event
0x88
Event from the Module to the host
2.1.3 Command Class IDs
BGAPI contains the command classes listed in the following table. Each command class is described in more detail in the appropriate
section later in this manual.
Table 2.3. BGAPI Command Classes
Class ID
Description
Explanation
0x00
DFU
Device Firmware Update
0x01
System
Common system control
0x02
Configuration
Module configuration
0x03
WiFi
Wi-Fi connection control
0x04
TCPIP
Module TCP/IP stack control
0x05
Endpoint
Endpoints handling
0x06
Hardware
MCU peripherals control
0x07
PS Store
Persistent Store handling
0x08
I2C
MCU I2C control
0x09
HTTP Server
Module internal HTTP Server
0x0B
X509
Certificate handling
0x0C
SD Card
microSD memory card handling
0x0D
Utilities for BGScript
BGScript utilities
2.1.4 Packet Exchange
Note: When sending commands over BGAPI you always have to wait for the BGAPI response before issuing a new command to the
Module.
2.1.5 Introduction to BGAPI over SPI
When using SPI as a host interface to the Wi-Fi Module, the host controller is the master while the Wi-Fi module is the slave. SPI is a
synchronous interface with the same clock driving both input and output. During BGAPI command sending, the host (master) should
also read possible responses or events sent by the Module. The Module also informs the host that it has data to send using a specified
notify GPIO pin and the host must generate the SPI clock by sending zeros (0's) to the Module.
Note: The Module will assert the configured notify pin to active state (from low to high) when it has data to send to the master. The
notify pin will be set back to low when there are two bytes left to send to the host. The user should always read the header (4 bytes)
and the payload, the size of which is declared in the header.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 8
WGM110 API Reference Manual
API Definition
●
Command & Response
1. Master sends Wi-Fi on command.
MASTER 08 00 03 00
SLAVE 00 00 00 00
2. Slave notifies master by using a notify bit (if configured).
3. Master reads response.
MASTER 00 00 00 00 00 00
SLAVE 08 02 03 00 00 00
●
Event
1. Slave notifies master by using a notify bit (if configured).
2. Master reads event.
MASTER 00 00 00 00 00 00
SLAVE 88 02 03 00 00 00
2.2 BGLib Functions Definition
All the BGAPI commands are also available as ANSI C functions in a separate host library called BGLib. The responses and event on
the other hand are handled as function callbacks. The ANSI C functions are also documented in the API Reference section.
The functions and callbacks are documented as follows:
●
Function and callback documentation in C
/* Function */
void wifi_cmd_system_hello(void);
/* Callback */
void wifi_rsp_system_hello(const void* nul)
The command parameters and return values are the same as used in the BGAPI binary protocol so they are not documented separately.
2.3 BGScript API Definition
The BGScript functions are documented in the API Reference section. The format of the commands varies slightly from the C library
functions. Instead of using callbacks the BGScript functions take the return values as parameters.
BGScript commands are documented as follows:
●
BGScript functions
call system_hello()
The BGScript command parameters and return values are the same as used in the BGAPI binary protocol so they are not documented
separately.
2.4 Data Types
The following table lists all available data types and their length in bytes and includes examples in both human readable and hexadecimal format.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 9
WGM110 API Reference Manual
API Definition
Table 2.4. Data Types
Name
Length (bytes)
Description
hw_addr
6
MAC Address
Example
ipv4
4
Human readable
00:07:80:1A:2B:3C
Packet data (hex)
00 07 80 1A 2B 3C
IPv4 address in big endian format
Example
uint8array
1 - 256
Human readable
192.168.1.1
Packet data (hex)
C0 A8 01 01
Variable length byte array. The first byte defines the length n of
the data that follows, n having the value 0 ≤ n ≤ 255.
Example
uint16array
2 - 2047
Human readable
“Hello”
Packet data (hex)
05 48 65 6c 6c 6f
Variable length byte array. The first two bytes define the length n
of the payload data that follows, n having the value 0 ≤ n ≤ 2045.
Length field is in little endian format.
Note: The payload data length is in bytes (not in multiples of 2)!
Note: The upper limit 2045 is the theoretical maximum value for n
because the actual maximum value depends on the other data in
the message array (excluding the message header).
Example
uint8
1
Human readable
“World!”
Packet data (hex)
06 00 57 6f 72 6c 64 21
8-bit unsigned integer
Example
int8
1
Human readable
167
Packet data (hex)
a7
8-bit signed integer, 2's complement
Example
uint16
2
Human readable
-22
Packet data (hex)
ea
16-bit unsigned integer
Example
silabs.com | Smart. Connected. Energy-friendly.
Human readable
4567
Packet data (hex)
d7 11
Rev. 1.1 | 10
WGM110 API Reference Manual
API Definition
Name
Length (bytes)
Description
int16
2
16-bit signed integer, 2's complement
Example
uint32
4
Human readable
-4567
Packet data (hex)
29 ee
32-bit unsigned integer
Example
int32
4
Human readable
2864434397
Packet data (hex)
dd cc bb aa
32-bit signed integer, 2's complement
Example
silabs.com | Smart. Connected. Energy-friendly.
Human readable
-45678
Packet data (hex)
92 4d ff ff
Rev. 1.1 | 11
WGM110 API Reference Manual
API Reference
3. API Reference
This section describes all commands, enumerations, responses, events and errors. Commands with related enumerations, responses
and events are grouped according to command classes.
3.1 Configuration Command Class
The commands in this class are used to read and write the MAC address of the Module.
This class consists of the following items:
• Commands
• cmd_config_get_mac
• cmd_config_set_mac
• Events
• evt_config_mac_address
Troubleshooting information
Problem
The command cmd_config_get_mac returns the address "00:0b:57:ff:ff:ff".
Possible reason
The Module is totally erased after a flasher tool was used – contact the Silicon Labs Customer Support or set the MAC address always
after a Module reset with the cmd_config_set_mac command. Avoid erasing the Module memory completely when using flasher tools.
3.1.1 config commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 12
WGM110 API Reference Manual
API Reference
3.1.1.1 cmd_config_get_mac
This command is used to read the MAC address of the device.
Table 3.1. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x02
class
Message class: Configuration
3
0x00
method
4
uint8
hw_interface
Message ID
Hardware interface
• 0: Wi-Fi
Table 3.2. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x02
class
Message class: Configuration
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call config_get_mac(hw_interface)(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_config_get_mac(uint8 hw_interface);
/* Response id */
wifi_rsp_config_get_mac_id
/* Response structure */
struct wifi_msg_config_get_mac_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
Table 3.3. Events Generated
Event
Description
config_mac_address
Device MAC address
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 13
WGM110 API Reference Manual
API Reference
3.1.1.2 cmd_config_set_mac
This command is used to write the device MAC address.
The MAC address will be taken into use when the Wi-Fi radio is switched on using the sme_wifi_on command.
Table 3.4. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x07
lolen
Minimum payload length
2
0x02
class
Message class: Configuration
3
0x01
method
4
uint8
hw_interface
5-10
hw_addr
mac
Message ID
Hardware interface
• 0: Wi-Fi
The new MAC address to set
Table 3.5. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x02
class
Message class: Configuration
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call config_set_mac(hw_interface,mac)(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_config_set_mac(uint8 hw_interface, hw_addr mac);
/* Response id */
wifi_rsp_config_set_mac_id
/* Response structure */
struct wifi_msg_config_set_mac_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
3.1.2 config events
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 14
WGM110 API Reference Manual
API Reference
3.1.2.1 evt_config_mac_address
This event indicates the current MAC address of the device.
Table 3.6. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x07
lolen
Minimum payload length
2
0x02
class
Message class: Configuration
3
0x00
method
4
uint8
hw_interface
5-10
hw_addr
mac
Message ID
Hardware interface
• 0: Wi-Fi
The current MAC address
BGScript event
event config_mac_address(hw_interface,mac)
C Functions
/* Event id */
wifi_evt_config_mac_address_id
/* Event structure */
struct wifi_msg_config_mac_address_evt_t
{
uint8 hw_interface;,
hw_addr mac;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 15
WGM110 API Reference Manual
API Reference
3.2 Device Firmware Upgrade (DFU) Command Class
The commands in this class are used to perform firmware updates over one of the host interfaces (e.g. UART, USB or SPI). DFU firmware updates are intended for field updates but not for development time updates.
This class consists of the following items:
• Commands
• cmd_dfu_flash_set_address
• cmd_dfu_flash_upload
• cmd_dfu_flash_upload_finish
• cmd_dfu_reset
• Events
• event_dfu_boot indicates that the command cmd_dfu_reset was finished succesfully
Correct DFU upload sequence
1. Set the Module's power on. The configuration of the host serial communication is the same as the one configured during previous
firmware load.
2. Send the cmd_dfu_reset command with the parameter dfu mode (1).
3. Wait until the event_dfu_boot event is received.
4. Send the cmd_dfu_flash_set_address command with the address value 0 (this is the only possible value).
5. Upload the DFU image file by sending the cmd_dfu_flash_upload command.
Note: Maximum payload size for a single cmd_dfu_flash_upload command is 128 bytes so typically multiple commands must be
sent to upload the entire DFU image file.
Note: Response time will vary according to several parameters related to the the flash memory write operation.
6. Repeat step 5 until the entire DFU image file has been loaded.
7. Send the cmd_dfu_flash_upload_finish command to finalize the loading of the flash.
8. Wait for the system_event_boot event.
Troubleshooting information
Problem
No boot event received after issuing the cmd_dfu_reset command in DFU upload sequence (see step 3 of the DFU Upload sequence).
Possible reasons
• The Module is not powered up.
• The host serial communication (UART, SPI, USB) is not working, for example the UART bit rate has been configured erroneosly.
• The flash memory has been erased completely, use another tool, like SimplicityCommander from SDK, to load the DFU flash image
file. For more details see document QSG122: WGM110 Wi-Fi® Module Software Quick-Start Guide.
• The Module has been damaged.
Problem
No boot event received after issuing the cmd_dfu_flash_upload_finish command in DFU upload sequence (see step 8 of the DFU
Upload sequence).
Possible reasons
• The host serial communication (UART, SPI, USB) is not working, for example the communication part has not been enabled or the
UART bitrate was changed due to the settings defined in the DFU image file. Check UART, SPI or USB settings from the project
configuration file (project.xml).
• Verification of the DFU image has failed. Reset the device using the cmd_dfu_reset command and repeat the DFU Upload sequence.
• Incorrect DFU image. Rebuild the project and/or check that the correct image file is selected for DFU Upload.
Other comments
If the DFU Upload sequence is not completed, for example if the device is unpowered during the upload or if the cmd_dfu_flash_upload_finish command is not sent, there is a possibility that the configuration of the serial host communication interface is lost in
which case the Module will enter into Recovery Mode. If the Module is in Recovery Mode only UART0 in Location 0 can be used for
host communication.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 16
WGM110 API Reference Manual
API Reference
Table 3.7. UART Default Settings in Recovery Mode
Parameter
Value
UART #
UART 0
Location
0
Bitrate
115200
Stop bits
1
Parity
None
Handshake
None
3.2.1 dfu commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 17
WGM110 API Reference Manual
API Reference
3.2.1.1 cmd_dfu_flash_set_address
This command is used to set the flash address offset for the DFU upgrade.
Table 3.8. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x04
lolen
Minimum payload length
2
0x00
class
Message class: Device Firmware Upgrade
3
0x01
method
Message ID
4-7
uint32
address
The flash address offset.
Set to zero.
Table 3.9. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x00
class
Message class: Device Firmware Upgrade
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call dfu_flash_set_address(address)(result)
BGLIB C API
/* Function */
void wifi_cmd_dfu_flash_set_address(uint32 address);
/* Response id */
wifi_rsp_dfu_flash_set_address_id
/* Response structure */
struct wifi_msg_dfu_flash_set_address_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 18
WGM110 API Reference Manual
API Reference
3.2.1.2 cmd_dfu_flash_upload
This command is used to upload a block of firmware data.
Table 3.10. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x00
class
Message class: Device Firmware Upgrade
3
0x02
method
4
uint8array
data
Message ID
Block of firmware data, up to 128 bytes
Table 3.11. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x00
class
Message class: Device Firmware Upgrade
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call dfu_flash_upload(data_len, data_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_dfu_flash_upload(uint8array data);
/* Response id */
wifi_rsp_dfu_flash_upload_id
/* Response structure */
struct wifi_msg_dfu_flash_upload_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 19
WGM110 API Reference Manual
API Reference
3.2.1.3 cmd_dfu_flash_upload_finish
This command is used to finish the DFU upgrade.
The command must be called once all firmware data has been uploaded.
Table 3.12. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x00
class
Message class: Device Firmware Upgrade
3
0x03
method
Message ID
Table 3.13. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x00
class
Message class: Device Firmware Upgrade
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call dfu_flash_upload_finish()(result)
BGLIB C API
/* Function */
void wifi_cmd_dfu_flash_upload_finish();
/* Response id */
wifi_rsp_dfu_flash_upload_finish_id
/* Response structure */
struct wifi_msg_dfu_flash_upload_finish_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 20
WGM110 API Reference Manual
API Reference
3.2.1.4 cmd_dfu_reset
This command is used to reset the device.
The command does not have a response, but it triggers a boot event.
Table 3.14. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x00
class
Message class: Device Firmware Upgrade
3
0x00
method
4
uint8
dfu
Message ID
Boot mode
• 0: Boot to normal mode
• 1: Boot to DFU mode
BGScript command
call dfu_reset(dfu)
BGLIB C API
/* Function */
void wifi_cmd_dfu_reset(uint8 dfu);
/* Command does not have a response */
Table 3.15. Events Generated
Event
Description
system_boot
Sent after the device has booted to normal mode
dfu_boot
Sent after the device has booted to DFU mode
3.2.2 dfu events
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 21
WGM110 API Reference Manual
API Reference
3.2.2.1 evt_dfu_boot
This event indicates that the device booted into DFU mode, and that it is ready to receive commands related to DFU firmware upgrade.
Table 3.16. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x04
lolen
Minimum payload length
2
0x00
class
Message class: Device Firmware Upgrade
3
0x00
method
Message ID
4-7
uint32
version
Version of the bootloader
BGScript event
event dfu_boot(version)
C Functions
/* Event id */
wifi_evt_dfu_boot_id
/* Event structure */
struct wifi_msg_dfu_boot_evt_t
{
uint32 version;
};
3.3 Endpoint Command Class
The commands in this class are used to create and delete endpoints and to route data from and to an endpoint. Defined endpoint types
are listed in the adjoining enumeration.
This class consists of the following items:
• Commands
• cmd_endpoint_close
• cmd_endpoint_disable
• cmd_endpoint_send
• cmd_endpoint_set_active
• cmd_endpoint_set_streaming
• cmd_endpoint_set_streaming_destination
• cmd_endpoint_set_transmit_size
• Events
• evt_endpoint_closing
• evt_endpoint_data
• evt_endpoint_error
• evt_endpoint_status
• evt_endpoint_syntax_error
• Enumerations
• enum_endpoint_type
All host interfaces which have been configured for BGAPI use in the project configuration file (using parameter; api=”true”) will send
BGAPI events generated by the Module and also can receive BGAPI commands. If more than one host interface has been configured
into BGAPI mode, care must be taken to prevent problems related to issuance of parallel commands.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 22
WGM110 API Reference Manual
API Reference
3.3.1 endpoint commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 23
WGM110 API Reference Manual
API Reference
3.3.1.1 cmd_endpoint_close
This command is used to close a protocol endpoint.
The command must only be used for protocol endpoints such as TCP, UDP and TLS endpoints.
Table 3.17. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x04
method
Message ID
4
uint8
endpoint
Index of the endpoint to close
Range: 0 - 30
Table 3.18. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x04
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the endpoint closed
Range: 0 - 30
BGScript command
call endpoint_close(endpoint)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_endpoint_close(uint8 endpoint);
/* Response id */
wifi_rsp_endpoint_close_id
/* Response structure */
struct wifi_msg_endpoint_close_rsp_t
{
uint16 result;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 24
WGM110 API Reference Manual
API Reference
Table 3.19. Events Generated
Event
Description
endpoint_status
Sent when the endpoint status changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 25
WGM110 API Reference Manual
API Reference
3.3.1.2 cmd_endpoint_disable
This command is used to disable an UART endpoint.
The command effectively switches off an UART interface until the device is reset or power-cycled. When an UART interface is disabled
its pins go to high-impedance state.
Table 3.20. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x06
method
Message ID
4
uint8
endpoint
Index of the endpoint to disable
Range: 0 - 30
Table 3.21. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x06
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the endpoint disabled
Range: 0 - 30
BGScript command
call endpoint_disable(endpoint)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_endpoint_disable(uint8 endpoint);
/* Response id */
wifi_rsp_endpoint_disable_id
/* Response structure */
struct wifi_msg_endpoint_disable_rsp_t
{
uint16 result;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 26
WGM110 API Reference Manual
API Reference
3.3.1.3 cmd_endpoint_send
This command is used to send data to a given endpoint.
Table 3.22. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x00
method
Message ID
4
uint8
endpoint
Index of the endpoint to which the data will be sent
Range: 0 - 31
5
uint8array
data
Data to be sent
Table 3.23. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the endpoint where the data was sent
Range: 0 - 31
BGScript command
call endpoint_send(endpoint,data_len, data_data)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_endpoint_send(uint8 endpoint, uint8array data);
/* Response id */
wifi_rsp_endpoint_send_id
/* Response structure */
struct wifi_msg_endpoint_send_rsp_t
{
uint16 result;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 27
WGM110 API Reference Manual
API Reference
3.3.1.4 cmd_endpoint_set_active
This command is used to activate or deactivate endpoints.
Configured endpoints are active by default, i.e., you can send data to them, and data can be received from them. This command allows
you to temporarily halt the outgoing data from an endpoint by deactivating it. For example, deactivating a BGAPI UART endpoint will
prevent BGAPI events and responses from being sent out of the UART interface. Similarly, deactivating the BGScript endpoint will prevent events from being passed to the script, thus preventing the calls from being executed.
Table 3.24. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x02
method
Message ID
4
uint8
endpoint
Index of the endpoint to configure
Range: 0 - 30
5
uint8
active
Endpoint status
• 0: inactive
• 1: active
Table 3.25. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the endpoint configured
Range: 0 - 30
BGScript command
call endpoint_set_active(endpoint,active)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_endpoint_set_active(uint8 endpoint, uint8 active);
/* Response id */
wifi_rsp_endpoint_set_active_id
/* Response structure */
struct wifi_msg_endpoint_set_active_rsp_t
{
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 28
WGM110 API Reference Manual
API Reference
uint16 result;,
uint8 endpoint;
};
Table 3.26. Events Generated
Event
Description
endpoint_status
Sent when the endpoint status changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 29
WGM110 API Reference Manual
API Reference
3.3.1.5 cmd_endpoint_set_streaming
This command is used to switch an endpoint between streaming or BGAPI modes.
When an endpoint is in streaming mode, received data is passed unmodified to another endpoint such as TCP and sent data written asis to a peripheral interface. In BGAPI mode, received data is handled as BGAPI protocol messages and sent data is encapsulated in
evt_endpoint_data events.
This command can currently be used only with UART endpoints. If the switch from streaming to BGAPI mode is made while there is
incoming or outgoing UART data, data loss may occur.
Table 3.27. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x01
method
Message ID
4
uint8
endpoint
Index of the endpoint to configure
Range: 0 - 30
5
uint8
streaming
Endpoint mode
• 0: BGAPI mode
• 1: streaming mode
Table 3.28. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the endpoint configured
Range: 0 - 30
BGScript command
call endpoint_set_streaming(endpoint,streaming)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_endpoint_set_streaming(uint8 endpoint, uint8 streaming);
/* Response id */
wifi_rsp_endpoint_set_streaming_id
/* Response structure */
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 30
WGM110 API Reference Manual
API Reference
struct wifi_msg_endpoint_set_streaming_rsp_t
{
uint16 result;,
uint8 endpoint;
};
Table 3.29. Events Generated
Event
Description
endpoint_status
Sent when the endpoint status changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 31
WGM110 API Reference Manual
API Reference
3.3.1.6 cmd_endpoint_set_streaming_destination
This command is used to set the destination endpoint to which the received data from an endpoint will be routed to.
The command is only applicable for endpoints that can be configured in streaming mode.
Table 3.30. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x03
method
Message ID
4
uint8
endpoint
Index of the endpoint in streaming mode to configure
Range: 0 - 30
5
int8
destination_endpoint Index of the destination endpoint
• -1: routed to all BGAPI/BGScript endpoints
• 0 - 30: routed to a specific endpoint
• 31: received data is discarded
Table 3.31. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the endpoint configured
Range: 0 - 30
BGScript command
call endpoint_set_streaming_destination(endpoint,destination_endpoint)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_endpoint_set_streaming_destination(uint8 endpoint, int8 destination_endpoint);
/* Response id */
wifi_rsp_endpoint_set_streaming_destination_id
/* Response structure */
struct wifi_msg_endpoint_set_streaming_destination_rsp_t
{
uint16 result;,
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 32
WGM110 API Reference Manual
API Reference
uint8 endpoint;
};
Table 3.32. Events Generated
Event
Description
endpoint_status
Sent when the endpoint status changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 33
WGM110 API Reference Manual
API Reference
3.3.1.7 cmd_endpoint_set_transmit_size
This command is used to set the desired transmit size of a protocol endpoint.
If defined, the endpoint will buffer outgoing data until transmit size is reached and send the data to remote end. This is meant for UDP
endpoints and must not be used with any other type of endpoint, including TCP. Transmit size is not set by default.
Table 3.33. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x05
method
Message ID
4
uint8
endpoint
Index of the endpoint to configure
Range: 0 - 30
5-6
uint16
size
Transmit size
• 0: no defined size
• 1 - 1472: defined size
Table 3.34. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x05
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the endpoint configured
Range: 0 - 30
BGScript command
call endpoint_set_transmit_size(endpoint,size)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_endpoint_set_transmit_size(uint8 endpoint, uint16 size);
/* Response id */
wifi_rsp_endpoint_set_transmit_size_id
/* Response structure */
struct wifi_msg_endpoint_set_transmit_size_rsp_t
{
uint16 result;,
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 34
WGM110 API Reference Manual
API Reference
uint8 endpoint;
};
3.3.2 endpoint events
3.3.2.1 evt_endpoint_closing
This event indicates that a protocol endpoint has been closed.
The event must be acknowledged by calling the endpoint_close command or otherwise the device will not re-use the endpoint index.
This event is only applicable to dynamically assigned endpoints such as TCP, UDP or TLS.
Table 3.35. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x03
method
Message ID
4-5
uint16
reason
Reason of endpoint close
For values refer to the error codes.
6
uint8
endpoint
Index of the endpoint
Range: 0 - 30
BGScript event
event endpoint_closing(reason,endpoint)
C Functions
/* Event id */
wifi_evt_endpoint_closing_id
/* Event structure */
struct wifi_msg_endpoint_closing_evt_t
{
uint16 reason;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 35
WGM110 API Reference Manual
API Reference
3.3.2.2 evt_endpoint_data
This event contains received data from an endpoint.
Table 3.36. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x01
method
Message ID
4
uint8
endpoint
Index of the endpoint which received the data
Range: 0 - 30
5
uint8array
data
The received data
BGScript event
event endpoint_data(endpoint,data_len, data_data)
C Functions
/* Event id */
wifi_evt_endpoint_data_id
/* Event structure */
struct wifi_msg_endpoint_data_evt_t
{
uint8 endpoint;,
uint8array data;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 36
WGM110 API Reference Manual
API Reference
3.3.2.3 evt_endpoint_error
This event indicates an error in an endpoint.
Table 3.37. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x04
method
Message ID
4-5
uint16
reason
Error reason
For values refer to the error codes.
6
uint8
endpoint
Index of the endpoint that generated the event
Range: 0 - 30
BGScript event
event endpoint_error(reason,endpoint)
C Functions
/* Event id */
wifi_evt_endpoint_error_id
/* Event structure */
struct wifi_msg_endpoint_error_evt_t
{
uint16 reason;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 37
WGM110 API Reference Manual
API Reference
3.3.2.4 evt_endpoint_status
This event indicates the status of an endpoint.
Table 3.38. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x08
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x02
method
Message ID
4
uint8
endpoint
Index of the endpoint
Range: 0 - 30
5-8
uint32
type
Type of the endpoint
9
uint8
streaming
Endpoint mode
• 0: BGAPI mode
• 1: streaming mode
10
int8
destination
Index of the endpoint in to which the received data is routed to
• -1: routed to all BGAPI/BGScript endpoints
• 0 - 30: routed to a specific endpoint
• 31: received data is discarded
11
uint8
active
Endpoint status
• 0: inactive
• 1: active
BGScript event
event endpoint_status(endpoint,type,streaming,destination,active)
C Functions
/* Event id */
wifi_evt_endpoint_status_id
/* Event structure */
struct wifi_msg_endpoint_status_evt_t
{
uint8 endpoint;,
uint32 type;,
uint8 streaming;,
int8 destination;,
uint8 active;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 38
WGM110 API Reference Manual
API Reference
3.3.2.5 evt_endpoint_syntax_error
This event indicates that an endpoint detected a BGAPI protocol error in the received data.
The event is triggered if a BGAPI command from the external host contains syntax error(s) or if a command is only partially received.
The BGAPI parser has a 1 second command timeout, and if a valid command is not received within this timeout, an error is raised and
the partial or wrong command is ignored.
Table 3.39. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x05
class
Message class: Endpoint
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the endpoint that generated the event
Range: 0 - 30
BGScript event
event endpoint_syntax_error(result,endpoint)
C Functions
/* Event id */
wifi_evt_endpoint_syntax_error_id
/* Event structure */
struct wifi_msg_endpoint_syntax_error_evt_t
{
uint16 result;,
uint8 endpoint;
};
3.3.3 endpoint enumerations
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 39
WGM110 API Reference Manual
API Reference
3.3.3.1 enum_endpoint_type
This enumeration defines the endpoint types.
Table 3.40. Enumerations
Value
Name
Description
0
endpoint_type_free
Endpoint is not in use
1
endpoint_type_uart
UART
2
endpoint_type_usb
USB
4
endpoint_type_tcp
TCP client
8
endpoint_type_tcp_server
TCP server
16
endpoint_type_udp
UDP client
32
endpoint_type_udp_server
UDP server
64
endpoint_type_script
Scripting
128
endpoint_type_wait_close
Waiting for closing
256
endpoint_type_spi
SPI
1024
endpoint_type_drop
All received data is discarded
2048
endpoint_type_tls
TLS client
3.4 Persistent Store Command Class
The commands in this class are related to reading and saving data of the Module's internal non-volatile 4 KB memory (NVM). This
memory is duplicated to avoid lost data. The structure of the storage is based on "key – value" pairs, where "key" is a unique identifier
of the related data. Key id's above address "0x8000" are reserved for user data. An enumeration defines the system PS keys.
The Module has a minimum internal flash erase cycle value of 20000 before errors. Thus the total amount of data that can be saved in
to the NVM totals 8 MB. This must be taken into consideration when erasing data from the NVM frequently. The erase cycle life time
depends on the amount and variation of saved data, on the saving frequency and on the total memory usage of the NVM.
This class consists of the following items:
• Commands
• cmd_flash_ps_defrag
• cmd_flash_ps_dump
• cmd_flash_ps_erase
• cmd_flash_ps_erase_all
• cmd_flash_ps_load
• cmd_flash_ps_save
• Events
• evt_flash_ps_key carries the value of the saved PS Key.
• evt_flash_ps_key_changed is sent whenever a saved PS Key value is changed.
Recommendations
The NVM of the Module is defragmented automatically during normal operation so the command cmd_flash_ps_defrag is rarely needed. However, to keep the response time of the cmd_flash_ps_save command deterministic, it is recommended that the defragment
command cmd_flash_ps_defrag is called every now and then.
3.4.1 flash commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 40
WGM110 API Reference Manual
API Reference
3.4.1.1 cmd_flash_ps_defrag
This command is used to manually initiate the defragmentation of the Persistent Store.
The Persistent Store is automatically defragmented if there is not enough space when adding a PS key.
Table 3.41. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x00
method
Message ID
Table 3.42. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call flash_ps_defrag()(result)
BGLIB C API
/* Function */
void wifi_cmd_flash_ps_defrag();
/* Response id */
wifi_rsp_flash_ps_defrag_id
/* Response structure */
struct wifi_msg_flash_ps_defrag_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 41
WGM110 API Reference Manual
API Reference
3.4.1.2 cmd_flash_ps_dump
This command is used to dump all the PS keys from the Persistent Store.
The command will generate a series of PS key events. The last PS key event is identified by the key index value 65535, indicating that
the dump has finished listing all PS keys.
Table 3.43. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x01
method
Message ID
Table 3.44. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call flash_ps_dump()(result)
BGLIB C API
/* Function */
void wifi_cmd_flash_ps_dump();
/* Response id */
wifi_rsp_flash_ps_dump_id
/* Response structure */
struct wifi_msg_flash_ps_dump_rsp_t
{
uint16 result;
};
Table 3.45. Events Generated
Event
Description
flash_ps_key
Sent for each PS key in the Persistent Store
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 42
WGM110 API Reference Manual
API Reference
3.4.1.3 cmd_flash_ps_erase
This command is used to erase a single PS key and its value from the Persistent Store.
Table 3.46. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x05
method
4-5
uint16
key
Message ID
Key index
• 0 - 32767: system keys
• 32768 - 65534: user keys
Table 3.47. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x05
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call flash_ps_erase(key)(result)
BGLIB C API
/* Function */
void wifi_cmd_flash_ps_erase(uint16 key);
/* Response id */
wifi_rsp_flash_ps_erase_id
/* Response structure */
struct wifi_msg_flash_ps_erase_rsp_t
{
uint16 result;
};
Table 3.48. Events Generated
Event
Description
flash_ps_key_changed
Sent when a PS key changes in the Persistent Store
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 43
WGM110 API Reference Manual
API Reference
3.4.1.4 cmd_flash_ps_erase_all
This command is used to erase all PS keys from the Persistent Store.
The command removes all system and user keys except the MAC address.
Table 3.49. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x02
method
Message ID
Table 3.50. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call flash_ps_erase_all()(result)
BGLIB C API
/* Function */
void wifi_cmd_flash_ps_erase_all();
/* Response id */
wifi_rsp_flash_ps_erase_all_id
/* Response structure */
struct wifi_msg_flash_ps_erase_all_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 44
WGM110 API Reference Manual
API Reference
3.4.1.5 cmd_flash_ps_load
This command is used to retrieve the value of a PS key from the Persistent Store.
Table 3.51. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x04
method
4-5
uint16
key
Message ID
Key index
• 0 - 32767: system keys
• 32768 - 65534: user keys
Table 3.52. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x04
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8array
value
Key value
Length: 0 - 255 bytes
BGScript command
call flash_ps_load(key)(result,value_len, value_data)
BGLIB C API
/* Function */
void wifi_cmd_flash_ps_load(uint16 key);
/* Response id */
wifi_rsp_flash_ps_load_id
/* Response structure */
struct wifi_msg_flash_ps_load_rsp_t
{
uint16 result;,
uint8array value;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 45
WGM110 API Reference Manual
API Reference
3.4.1.6 cmd_flash_ps_save
This command is used to store a value in the Persistent Store.
Table 3.53. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x03
method
4-5
uint16
key
6
uint8array
value
Message ID
Key index
• 0 - 32767: system keys
• 32768 - 65534: user keys
Key value
Length: 0 - 255 bytes
Table 3.54. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call flash_ps_save(key,value_len, value_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_flash_ps_save(uint16 key, uint8array value);
/* Response id */
wifi_rsp_flash_ps_save_id
/* Response structure */
struct wifi_msg_flash_ps_save_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 46
WGM110 API Reference Manual
API Reference
Table 3.55. Events Generated
Event
Description
flash_ps_key_changed
Sent when a PS key changes in the Persistent Store
3.4.2 flash events
3.4.2.1 evt_flash_ps_key
This event indicates the value of a PS key in the Persistent Store.
Table 3.56. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x00
method
4-5
uint16
key
6
uint8array
value
Message ID
Key index
• 0 - 32767: system keys
• 32768 - 65534: user keys
Key value
Length: 0 - 255 bytes
BGScript event
event flash_ps_key(key,value_len, value_data)
C Functions
/* Event id */
wifi_evt_flash_ps_key_id
/* Event structure */
struct wifi_msg_flash_ps_key_evt_t
{
uint16 key;,
uint8array value;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 47
WGM110 API Reference Manual
API Reference
3.4.2.2 evt_flash_ps_key_changed
This event indicates a PS key has changed in the Persistent Store.
Table 3.57. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x07
class
Message class: Persistent Store
3
0x01
method
4-5
uint16
key
Message ID
Key index
• 0 - 32767: system keys
• 32768 - 65534: user keys
BGScript event
event flash_ps_key_changed(key)
C Functions
/* Event id */
wifi_evt_flash_ps_key_changed_id
/* Event structure */
struct wifi_msg_flash_ps_key_changed_evt_t
{
uint16 key;
};
3.4.3 flash defines
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 48
WGM110 API Reference Manual
API Reference
3.4.3.1 define_flash_ps_keys
This enumeration defines the system PS keys.
Table 3.58. Defines
Value
Name
Description
1
FLASH_ps_key_mac
Device MAC address
2
FLASH_ps_key_ipv4_settings
Device IP configuration
3
FLASH_ps_key_dns0_settings
Device primary DNS server
4
FLASH_ps_key_dns1_settings
Device secondary DNS server
5
FLASH_ps_key_module_service
Device operating mode
20
FLASH_ps_key_ap_ssid
Access Point mode SSID
21
FLASH_ps_key_ap_channel
Access Point mode channel
22
FLASH_ps_key_ap_pw
Access point mode password
23
FLASH_ps_key_ap_wifi_n
Access Point mode 802.11n support enabled or disabled
24
FLASH_ps_key_ap_security
Access Point mode security mode
• 0: open security
• 1: WPA security
• 2: WPA2 security
• 3: WEP security
25
FLASH_ps_key_client_ssid
Client mode SSID
26
FLASH_ps_key_client_pw
Client mode password
30
FLASH_ps_key_dhcps_enable
DHCP server enabled or disabled
31
FLASH_ps_key_dhcps_space
First client IPv4 address assigned by the DHCP server
32
FLASH_ps_key_dhcps_disable_routing
DHCP server gateway and DNS router options enabled
or disabled
35
FLASH_ps_key_dnss_enable
DNS server enabled or disabled
36
FLASH_ps_key_dnss_url
DNS server URL
37
FLASH_ps_key_dnss_any_url
DNS server reply to any URL enabled or disabled
65535
FLASH_ps_key_eof
Last PS key index
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 49
WGM110 API Reference Manual
API Reference
3.5 Hardware Command Class
The commands in this class are used to configure and control peripherals and timers of the Module MCU. There are three enumerations which are used for defining the GPIO (General Purpose Input Output) pin mode (input, output, pull-up, pull-down, filter etc.), the
GPIO pin trigger mode, and the ADC input channel.
This class consists of the following items:
GPIO related
• Commands
• cmd_hardware_configure_gpio
• cmd_hardware_configure_gpio_interrupt
• cmd_hardware_write_gpio
• cmd_hardware_read_gpio
• Events
• evt_hardware_interrupt
ADC related
• Commands
• cmd_hardware_adc_read
Timer related
• Commands
• cmd_hardware_set_soft_timer
• cmd_hardware_timer_init
• cmd_hardware_timer_initcc
• cmd_hardware_rtc_init
• cmd_hardware_rtc_set_time
• cmd_hardware_rtc_get_time
• cmd_hardware_rtc_set_alarm
• Events
• evt_hardware_rtc_alarm
• evt_hardware_soft_timer
SPI related
• Commands
• cmd_hardware_spi_transfer
Examples
1. Reading a value of an ADC input channel.
a. Enable the ADC in project configuration by selecting a suitable reference voltage source.
b. Compile the project and load the firmware into the Module.
c. Read the ADC value using the command cmd_hardware_adc_read with the ADC input channel as a parameter.
d. The value of the analog voltage at the input of the selected ADC channel will be returned in the response.
2. Using an RTC alarm.
a. Initialize the RTC using the cmd_hardware_rtc_init command.
b. Set the date and time of the RTC with cmd_hardware_rtc_set_time command.
c. Wait for the evt_hardware_rtc_alarm event.
Note: RTC date and time are lost on the module power down.
3. Using the PWM (Pulse Width Modulation) output.
a. Initialize the hardware timer with the cmd_hardware_timer_init command and set the PWM frequency.
b. Set the PWM pulse ratio with the cmd_hardware_timer_initcc command.
4. Using GPIO as an external interrupt.
a. Configure the GPIO pin into input mode using the cmd_hardware_configure_gpio command.
b. Configure the same GPIO pin as an interrupt using the cmd_hardware_configure_gpio_interrupt.
c. You can detect an external interrupt occurrance by catching the evt_hardware_interrupt event.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 50
WGM110 API Reference Manual
API Reference
5. Using a GPIO pin as an input.
a. Configure the GPIO pin into input mode using the cmd_hardware_configure_gpio command.
b. Read the status of the GPIO pin defined in step 1 above using the cmd_hardware_read_gpio command.
Note: This command requires that port and pin are defined as masks.
c. Pin status is returned in the response of cmd_hardware_read_gpio command.
6. Using a GPIO pin as an output.
a. Configure the GPIO pin into output mode using the cmd_hardware_configure_gpio. command.
b. Set or clear the pin with the cmd_hardware_write_gpio command.
Note: This command requires that port and pin are defined as masks.
3.5.1 hardware commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 51
WGM110 API Reference Manual
API Reference
3.5.1.1 cmd_hardware_adc_read
This command is used to trigger a single ADC sample conversion.
Conversion parameters are 12-bit resolution and 32 clock cycle conversion time.
Table 3.59. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x07
method
4
uint8
input
Message ID
ADC input
Table 3.60. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x05
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x07
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
input
ADC input
7-8
uint16
value
ADC sample value
BGScript command
call hardware_adc_read(input)(result,input,value)
BGLIB C API
/* Function */
void wifi_cmd_hardware_adc_read(uint8 input);
/* Response id */
wifi_rsp_hardware_adc_read_id
/* Response structure */
struct wifi_msg_hardware_adc_read_rsp_t
{
uint16 result;,
uint8 input;,
uint16 value;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 52
WGM110 API Reference Manual
API Reference
3.5.1.2 cmd_hardware_configure_gpio
This command is used to configure the mode of a specified I/O pin.
Table 3.61. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x04
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x01
method
4
uint8
port
Port index
• 0: PA
• 1: PB
• 2: PC
• 3: PD
• 4: PE
• 5: PF
5
uint8
pin
Pin within the defined port
Message ID
Range: 0 - 15
6
uint8
mode
Pin mode
7
uint8
output
Pin default function
Values in mode 0:
• 0: tri-stated
• 1: tri-stated with pull-up enabled
Values in mode 1:
• 0: glitch filter disabled
• 1: glitch filter enabled
Values in mode 2:
• 0: pull-down enabled
• 1: pull-up enabled
Values in mode 3:
• 0: pull-down enabled
• 1: pull-up enabled
Values in mode 4:
• 0: output low
• 1: output high
Table 3.62. Response
Byte
Type
Name
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x01
method
silabs.com | Smart. Connected. Energy-friendly.
Description
Message ID
Rev. 1.1 | 53
WGM110 API Reference Manual
API Reference
Byte
Type
Name
Description
4-5
uint16
result
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_configure_gpio(port,pin,mode,output)(result)
BGLIB C API
/* Function */
void wifi_cmd_hardware_configure_gpio(uint8 port, uint8 pin, uint8 mode, uint8 output);
/* Response id */
wifi_rsp_hardware_configure_gpio_id
/* Response structure */
struct wifi_msg_hardware_configure_gpio_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 54
WGM110 API Reference Manual
API Reference
3.5.1.3 cmd_hardware_configure_gpio_interrupt
This command is used to configure an interrupt on a specified I/O pin.
Table 3.63. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x02
method
4
uint8
port
Port index
• 0: PA
• 1: PB
• 2: PC
• 3: PD
• 4: PE
• 5: PF
5
uint8
pin
Pin within the defined port
Message ID
Range: 1 - 15
6
uint8
trigger
Trigger for the interrupt
Table 3.64. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_configure_gpio_interrupt(port,pin,trigger)(result)
BGLIB C API
/* Function */
void wifi_cmd_hardware_configure_gpio_interrupt(uint8 port, uint8 pin, uint8 trigger);
/* Response id */
wifi_rsp_hardware_configure_gpio_interrupt_id
/* Response structure */
struct wifi_msg_hardware_configure_gpio_interrupt_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 55
WGM110 API Reference Manual
API Reference
3.5.1.4 cmd_hardware_read_gpio
This command is used to read the logic state of pins of a specified I/O-port.
Table 3.65. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x04
method
4
uint8
port
5-6
uint16
mask
Message ID
Port index
• 0: PA
• 1: PB
• 2: PC
• 3: PD
• 4: PE
• 5: PF
Bitmask of the pins within in the defined port to read.
If a bit is zero, the corresponding pin is ignored. If a bit is one, the
corresponding pin is read.
Table 3.66. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x04
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x04
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6-7
uint16
data
Bitmask of the pin state for the pins in the requeset mask.
If a bit is zero, the corresponding pin is low. If a bit is one, the corresponding pin is high.
The state of the pins that are not part of the request mask is zero.
BGScript command
call hardware_read_gpio(port,mask)(result,data)
BGLIB C API
/* Function */
void wifi_cmd_hardware_read_gpio(uint8 port, uint16 mask);
/* Response id */
wifi_rsp_hardware_read_gpio_id
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 56
WGM110 API Reference Manual
API Reference
/* Response structure */
struct wifi_msg_hardware_read_gpio_rsp_t
{
uint16 result;,
uint16 data;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 57
WGM110 API Reference Manual
API Reference
3.5.1.5 cmd_hardware_rtc_get_time
This command is used to read the current Real Time Clock (RTC) time.
Table 3.67. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x0a
method
Message ID
Table 3.68. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x0a
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x0a
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6-7
int16
year
Current year
Range: 2000 - 2099
8
int8
month
Current month
Range: 1 - 12
9
int8
day
Current day
Range: 1 - 31
10
int8
weekday
11
int8
hour
Current weekday
• 0: Sunday
• 1: Monday
• 2: Tuesday
• 3: Wednesday
• 4: Thursday
• 5: Friday
• 6: Saturday
Current hour
Range: 0 - 23
12
int8
minute
Current minute
Range: 0 - 59
13
int8
second
Current second
Range: 0 - 59
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 58
WGM110 API Reference Manual
API Reference
BGScript command
call hardware_rtc_get_time()(result,year,month,day,weekday,hour,minute,second)
BGLIB C API
/* Function */
void wifi_cmd_hardware_rtc_get_time();
/* Response id */
wifi_rsp_hardware_rtc_get_time_id
/* Response structure */
struct wifi_msg_hardware_rtc_get_time_rsp_t
{
uint16 result;,
int16 year;,
int8 month;,
int8 day;,
int8 weekday;,
int8 hour;,
int8 minute;,
int8 second;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 59
WGM110 API Reference Manual
API Reference
3.5.1.6 cmd_hardware_rtc_init
This command is used to enable or disable the Real Time Clock.
The clock must be initialized using the hardware_rtc_set_time command before it can be used.
Table 3.69. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x08
method
Message ID
4
uint8
enable
RTC state
• 0: disabled
• 1: enabled
Table 3.70. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x08
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_rtc_init(enable)(result)
BGLIB C API
/* Function */
void wifi_cmd_hardware_rtc_init(uint8 enable);
/* Response id */
wifi_rsp_hardware_rtc_init_id
/* Response structure */
struct wifi_msg_hardware_rtc_init_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 60
WGM110 API Reference Manual
API Reference
3.5.1.7 cmd_hardware_rtc_set_alarm
This command is used to set an alarm for the Real Time Clock.
Only one alarm can be active at one time. The alarm can be disabled by disabling the Real Time Clock using the hardware_rtc_init
command.
Table 3.71. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x07
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x0b
method
Message ID
4-5
int16
year
Current year
Range: 2000 - 2099
6
int8
month
Current month
Range: 1 - 12
7
int8
day
Current day
Range: 1 - 31
8
int8
hour
Current hour
Range: 0 - 23
9
int8
minute
Current minute
Range: 0 - 59
10
int8
second
Current second
Range: 0 - 59
Table 3.72. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x0b
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_rtc_set_alarm(year,month,day,hour,minute,second)(result)
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 61
WGM110 API Reference Manual
API Reference
BGLIB C API
/* Function */
void wifi_cmd_hardware_rtc_set_alarm(int16 year, int8 month, int8 day, int8 hour, int8 minute, int8 second);
/* Response id */
wifi_rsp_hardware_rtc_set_alarm_id
/* Response structure */
struct wifi_msg_hardware_rtc_set_alarm_rsp_t
{
uint16 result;
};
Table 3.73. Events Generated
Event
Description
hardware_rtc_alarm
Sent when the RTC alarm is triggered
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 62
WGM110 API Reference Manual
API Reference
3.5.1.8 cmd_hardware_rtc_set_time
This command is used to set the current Real Time Clock time.
Table 3.74. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x07
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x09
method
Message ID
4-5
int16
year
Current year
Range: 2000 - 2099
6
int8
month
Current month
Range: 1 - 12
7
int8
day
Current day
Range: 1 - 31
8
int8
hour
Current hour
Range: 0 - 23
9
int8
minute
Current minute
Range: 0 - 59
10
int8
second
Current second
Range: 0 - 59
Table 3.75. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x09
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_rtc_set_time(year,month,day,hour,minute,second)(result)
BGLIB C API
/* Function */
void wifi_cmd_hardware_rtc_set_time(int16 year, int8 month, int8 day, int8 hour, int8 minute, int8 second);
/* Response id */
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 63
WGM110 API Reference Manual
API Reference
wifi_rsp_hardware_rtc_set_time_id
/* Response structure */
struct wifi_msg_hardware_rtc_set_time_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 64
WGM110 API Reference Manual
API Reference
3.5.1.9 cmd_hardware_set_soft_timer
This command is used to enable a software timer.
Multiple concurrent timers can be running simultaneously as long as an unique handle is used for each.
Table 3.76. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x06
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x00
method
4-7
uint32
time
Message ID
Interval between events in milliseconds.
If 0, the timer is disabled.
8
uint8
handle
Timer handle
Range: 0 - 255
9
uint8
single_shot
Timer repeat
• 0: a repeating timer
• 1: a single-shot timer
Table 3.77. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_set_soft_timer(time,handle,single_shot)(result)
BGLIB C API
/* Function */
void wifi_cmd_hardware_set_soft_timer(uint32 time, uint8 handle, uint8 single_shot);
/* Response id */
wifi_rsp_hardware_set_soft_timer_id
/* Response structure */
struct wifi_msg_hardware_set_soft_timer_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 65
WGM110 API Reference Manual
API Reference
Table 3.78. Events Generated
Event
Description
hardware_soft_timer
Sent after the specified interval has elapsed
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 66
WGM110 API Reference Manual
API Reference
3.5.1.10 cmd_hardware_spi_transfer
This command is used to transfer data using an SPI interface.
The command can only be used when the interface is in SPI master mode. Due to synchronous full duplex nature of SPI, the command
response will contain the same amount of read bytes as was written.
Table 3.79. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x0e
method
Message ID
4
uint8
channel
SPI channel to use
5
uint8array
data
Data to write
Table 3.80. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x0e
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8array
data
Data read
BGScript command
call hardware_spi_transfer(channel,data_len, data_data)(result,data_len, data_data)
BGLIB C API
/* Function */
void wifi_cmd_hardware_spi_transfer(uint8 channel, uint8array data);
/* Response id */
wifi_rsp_hardware_spi_transfer_id
/* Response structure */
struct wifi_msg_hardware_spi_transfer_rsp_t
{
uint16 result;,
uint8array data;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 67
WGM110 API Reference Manual
API Reference
3.5.1.11 cmd_hardware_timer_init
This command is used to configure a hardware timer.
The timer clock signal is derived from the peripheral clock signal using the prescale factor. The timer counter is increased by one at
every clock cycle. When the timer reaches the configured maximum value, it wraps around to zero and continues counting.
Table 3.81. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x06
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x05
method
4
uint8
index
Message ID
Index of the timer
Range: 0 - 1
5
uint8
location
Location of the timer pins
Range: 0 - 6
6-7
uint16
prescale
Prescale factor
• 1: corresponds to 48 MHz
• 2: corresponds to 24 MHz
• 4: corresponds to 12 MHz
• 8: corresponds to 6 MHz
• 16: corresponds to 3 MHz
• 32: corresponds to 1500 kHz
• 64: corresponds to 750 kHz
• 128: corresponds to 375 kHz
• 256: corresponds to 187.5 kHz
• 512: corresponds to 93.75 kHz
• 1024: corresponds to 46.875 kHz
8-9
uint16
top_value
Top value of the timer
Table 3.82. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x05
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_timer_init(index,location,prescale,top_value)(result)
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 68
WGM110 API Reference Manual
API Reference
BGLIB C API
/* Function */
void wifi_cmd_hardware_timer_init(uint8 index, uint8 location, uint16 prescale, uint16 top_value);
/* Response id */
wifi_rsp_hardware_timer_init_id
/* Response structure */
struct wifi_msg_hardware_timer_init_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 69
WGM110 API Reference Manual
API Reference
3.5.1.12 cmd_hardware_timer_initcc
This command is used to configure a hardware timer compare channel.
In PWM mode, the compare channel pin will be held high until the timer reaches the configured compare value, at which point the pin
will be set low until the timer reaches the configured maximum value. After reaching the maximum value, the timer wraps around to
zero and the cycle restarts.
Table 3.83. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x05
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x06
method
4
uint8
index
Message ID
Index of the timer
Range: 0 - 1
5
uint8
channel
Compare channel
Range: 0 - 2
6
uint8
mode
7-8
uint16
compare_value
Compare mode
• 0: disabled
• 1: PWM
Value to compare the timer against
Table 3.84. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x06
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_timer_initcc(index,channel,mode,compare_value)(result)
BGLIB C API
/* Function */
void wifi_cmd_hardware_timer_initcc(uint8 index, uint8 channel, uint8 mode, uint16 compare_value);
/* Response id */
wifi_rsp_hardware_timer_initcc_id
/* Response structure */
struct wifi_msg_hardware_timer_initcc_rsp_t
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 70
WGM110 API Reference Manual
API Reference
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 71
WGM110 API Reference Manual
API Reference
3.5.1.13 cmd_hardware_write_gpio
This command is used to set the logic state of pins on a specified I/O-port.
Table 3.85. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x05
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x03
method
4
uint8
port
5-6
uint16
mask
Message ID
Port index
• 0: PA
• 1: PB
• 2: PC
• 3: PD
• 4: PE
• 5: PF
Bitmask of the pins within the defined port to write.
If a bit is zero, the corresponding pin is ignored. If a bit is one, the
corresponding pin is written.
7-8
uint16
data
Bitmask of the pin state for the pins in the request mask.
If a bit is zero, the corresponding pin is set low. If a bit is one, the
corresponding pin is set high.
The state of the pins that are not part of the request mask is not
changed.
Table 3.86. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call hardware_write_gpio(port,mask,data)(result)
BGLIB C API
/* Function */
void wifi_cmd_hardware_write_gpio(uint8 port, uint16 mask, uint16 data);
/* Response id */
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 72
WGM110 API Reference Manual
API Reference
wifi_rsp_hardware_write_gpio_id
/* Response structure */
struct wifi_msg_hardware_write_gpio_rsp_t
{
uint16 result;
};
3.5.2 hardware events
3.5.2.1 evt_hardware_interrupt
This event indicates that one or more I/O interrupts have been triggered.
Table 3.87. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x08
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x01
method
4-7
uint32
interrupts
Message ID
Bitmask of the triggered interrupts.
If a bit is one, the corresponding interrupt was triggered.
8-11
uint32
timestamp
Timestamp when the event was generated.
The timestamp represents the time in milliseconds since the last
reset.
BGScript event
event hardware_interrupt(interrupts,timestamp)
C Functions
/* Event id */
wifi_evt_hardware_interrupt_id
/* Event structure */
struct wifi_msg_hardware_interrupt_evt_t
{
uint32 interrupts;,
uint32 timestamp;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 73
WGM110 API Reference Manual
API Reference
3.5.2.2 evt_hardware_rtc_alarm
This event indicates an RTC alarm has occurred.
Table 3.88. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x00
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x02
method
Message ID
BGScript event
event hardware_rtc_alarm()
C Functions
/* Event id */
wifi_evt_hardware_rtc_alarm_id
/* Event structure */
struct wifi_msg_hardware_rtc_alarm_evt_t
{
};
3.5.2.3 evt_hardware_soft_timer
This event indicates that a software timer has elapsed.
Table 3.89. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x06
class
Message class: Hardware
3
0x00
method
Message ID
4
uint8
handle
Handle of the elapsed timer
BGScript event
event hardware_soft_timer(handle)
C Functions
/* Event id */
wifi_evt_hardware_soft_timer_id
/* Event structure */
struct wifi_msg_hardware_soft_timer_evt_t
{
uint8 handle;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 74
WGM110 API Reference Manual
API Reference
3.5.3 hardware enumerations
3.5.3.1 enum_hardware_adc_input
This enumeration defines the ADC inputs.
Table 3.90. Enumerations
Value
Name
Description
0
hardware_adc_input_ch0
ADC CH0
1
hardware_adc_input_ch1
ADC CH1
2
hardware_adc_input_ch2
ADC CH2
3
hardware_adc_input_ch3
ADC CH3
4
hardware_adc_input_ch4
ADC CH4
5
hardware_adc_input_ch5
ADC CH5
6
hardware_adc_input_ch6
ADC CH6
7
hardware_adc_input_ch7
ADC CH7
9
hardware_adc_input_vdddiv3
ADC VDD/3
3.5.3.2 enum_hardware_gpio_mode
This enumeration defines the I/O pin modes.
Table 3.91. Enumerations
Value
Name
Description
0
hardware_gpio_mode_disabled
Tri-stated with optional pull-up
1
hardware_gpio_mode_input
Input with optional glitch filter
2
hardware_gpio_mode_input_pull
Input with pull-down or pull-up
3
hardware_gpio_mode_input_pull_filter
Input with glitch filter and pull-down or pull-up
4
hardware_gpio_mode_push_pull
Push-pull output
3.5.3.3 enum_hardware_gpio_port
I/O port definition
Table 3.92. Enumerations
Value
Name
Description
0
hardware_gpio_porta
Port PA
1
hardware_gpio_portb
Port PB
2
hardware_gpio_portc
Port PC
3
hardware_gpio_portd
Port PD
4
hardware_gpio_porte
Port PE
5
hardware_gpio_portf
Port PF
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 75
WGM110 API Reference Manual
API Reference
3.5.3.4 enum_hardware_gpio_trigger
This enumeration defines the triggers for an I/O pin interrupt.
Table 3.93. Enumerations
Value
Name
Description
0
hardware_gpio_trigger_disabled
Interrupt disabled
1
hardware_gpio_trigger_rising
Interrupt triggered by a rising edge
2
hardware_gpio_trigger_falling
Interrupt triggered by a falling edge
3
hardware_gpio_trigger_both
Interrupt triggered by both edges
3.6 HTTP Server Command Class
The commands in this class are used to control the internal HTTP, DHCP and DNS Server operations of the Module.
This class consists of the following items:
• Commands
• cmd_https_add_path
• cmd_https_api_response
• cmd_https_api_response_finish
• cmd_https_enable
• Events
• evt_https_api_request
• evt_api_request_data
• evt_https_api_request_finished
• evt_https_api_request_header
3.6.1 https commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 76
WGM110 API Reference Manual
API Reference
3.6.1.1 cmd_https_add_path
This command is used to add a mapping between an HTTP server path and a resource.
Table 3.94. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x01
method
Message ID
4
uint8
resource
Resource
• 0: flash
• 1: BGAPI/BGScript
• 2: SD card
5
uint8array
path
Server path
Length: 1 - 127 bytes
Table 3.95. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call https_add_path(resource,path_len, path_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_https_add_path(uint8 resource, uint8array path);
/* Response id */
wifi_rsp_https_add_path_id
/* Response structure */
struct wifi_msg_https_add_path_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 77
WGM110 API Reference Manual
API Reference
3.6.1.2 cmd_https_api_response
This command is used to send HTTP response data to a pending HTTP request.
Table 3.96. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x05
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x02
method
Message ID
4-7
uint32
request
Request number
8
uint8array
data
Response data
Table 3.97. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call https_api_response(request,data_len, data_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_https_api_response(uint32 request, uint8array data);
/* Response id */
wifi_rsp_https_api_response_id
/* Response structure */
struct wifi_msg_https_api_response_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 78
WGM110 API Reference Manual
API Reference
3.6.1.3 cmd_https_api_response_finish
This command is used to signal that all HTTP response data has been sent and that the pending HTTP request can be closed.
Table 3.98. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x04
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x03
method
Message ID
4-7
uint32
request
Request number
Table 3.99. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call https_api_response_finish(request)(result)
BGLIB C API
/* Function */
void wifi_cmd_https_api_response_finish(uint32 request);
/* Response id */
wifi_rsp_https_api_response_finish_id
/* Response structure */
struct wifi_msg_https_api_response_finish_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 79
WGM110 API Reference Manual
API Reference
3.6.1.4 cmd_https_enable
This command is used to enable or disable built-in HTTP, DHCP or DNS servers.
Table 3.100. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x00
method
4
uint8
https
HTTP server
• 0: disabled
• 1: enabled
5
uint8
dhcps
DHCP server
• 0: disabled
• 1: enabled
6
uint8
dnss
DNS server
• 0: disabled
• 1: enabled
Message ID
Table 3.101. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call https_enable(https,dhcps,dnss)(result)
BGLIB C API
/* Function */
void wifi_cmd_https_enable(uint8 https, uint8 dhcps, uint8 dnss);
/* Response id */
wifi_rsp_https_enable_id
/* Response structure */
struct wifi_msg_https_enable_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 80
WGM110 API Reference Manual
API Reference
3.6.2 https events
3.6.2.1 evt_https_api_request
This event indicates that an HTTP request has been received.
Table 3.102. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x06
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x00
method
Message ID
4-7
uint32
request
Request number
8
uint8
method
Request method
• 0: GET
• 1: PUT
• 2: POST
• 3: DELETE
9
uint8array
resource
Request resource
BGScript event
event https_api_request(request,method,resource_len, resource_data)
C Functions
/* Event id */
wifi_evt_https_api_request_id
/* Event structure */
struct wifi_msg_https_api_request_evt_t
{
uint32 request;,
uint8 method;,
uint8array resource;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 81
WGM110 API Reference Manual
API Reference
3.6.2.2 evt_https_api_request_data
This event contains HTTP payload data of a particular HTTP request.
Multiple events may be received, or none if the HTTP request does not have any payload data.
Table 3.103. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x05
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x02
method
Message ID
4-7
uint32
request
Request number
8
uint8array
data
Request data
BGScript event
event https_api_request_data(request,data_len, data_data)
C Functions
/* Event id */
wifi_evt_https_api_request_data_id
/* Event structure */
struct wifi_msg_https_api_request_data_evt_t
{
uint32 request;,
uint8array data;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 82
WGM110 API Reference Manual
API Reference
3.6.2.3 evt_https_api_request_finished
This event indicates that all HTTP header data, and payload data, if any, have been fully received for a particular HTTP request.
Table 3.104. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x04
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x03
method
Message ID
4-7
uint32
request
Request number
BGScript event
event https_api_request_finished(request)
C Functions
/* Event id */
wifi_evt_https_api_request_finished_id
/* Event structure */
struct wifi_msg_https_api_request_finished_evt_t
{
uint32 request;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 83
WGM110 API Reference Manual
API Reference
3.6.2.4 evt_https_api_request_header
This event contains HTTP header data of a particular HTTP request.
At least one event per an HTTP request is received.
Table 3.105. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x05
lolen
Minimum payload length
2
0x09
class
Message class: HTTP Server
3
0x01
method
Message ID
4-7
uint32
request
Request number
8
uint8array
data
Request header data
BGScript event
event https_api_request_header(request,data_len, data_data)
C Functions
/* Event id */
wifi_evt_https_api_request_header_id
/* Event structure */
struct wifi_msg_https_api_request_header_evt_t
{
uint32 request;,
uint8array data;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 84
WGM110 API Reference Manual
API Reference
3.7 I2C Command Class
The commands in this class are used to control I2C serial communication.
This class consists of the following commands and events:
• Commands
• cmd_i2c_start_read
• cmd_i2c_start_write
• cmd_i2c_stop
Examples
1. Using I2C for reading and writing data.
a. Enable I2C in the project configuration file by defining the I2C Channels and the Location.
b. Build and load the firmware image file into the Module.
c. Send the cmd_i2c_start_write command using parameters suitable for the connected I2C device.
d. Complete the write function by sending the cmd_i2c_stop command.
e. Start the read by sending the cmd_i2c_read command.
f. Complete the read function by sending the cmd_i2c_stop command
g. The value read from the sensor is contained in the response.
Troubleshooting information
Problem
No data in response of cmd_i2c_start read command .
Possible reasons
• Wrong configuration (e.g. I2C Channel or Location). Check the project configuration file.
• Wrong I2C Channel or Slave address in the command parameters. Check the command call.
• Hardware error. Check the schematics and the PCB layout for any errors.
3.7.1 i2c commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 85
WGM110 API Reference Manual
API Reference
3.7.1.1 cmd_i2c_start_read
This command is used to start an I2C transaction for reading data.
The transaction must be terminated with the i2c_stop command.
Table 3.106. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x08
class
Message class: I2C
3
0x00
method
Message ID
4
uint8
channel
I2C module to use
Range: 0 - 1
5
uint8
slave_address
6
uint8
length
right-aligned 7-bit slave address to use
Amount to read
Length: 1 - 255 bytes
Table 3.107. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x08
class
Message class: I2C
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8array
data
Data read if command was successful
BGScript command
call i2c_start_read(channel,slave_address,length)(result,data_len, data_data)
BGLIB C API
/* Function */
void wifi_cmd_i2c_start_read(uint8 channel, uint8 slave_address, uint8 length);
/* Response id */
wifi_rsp_i2c_start_read_id
/* Response structure */
struct wifi_msg_i2c_start_read_rsp_t
{
uint16 result;,
uint8array data;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 86
WGM110 API Reference Manual
API Reference
3.7.1.2 cmd_i2c_start_write
This command is used to start an I2C transaction for writing data.
The transaction must be terminated with the i2c_stop command.
Table 3.108. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x08
class
Message class: I2C
3
0x01
method
Message ID
4
uint8
channel
I2C module to use
Range: 0 - 1
5
uint8
slave_address
6
uint8array
data
right-aligned 7-bit slave address to use
Data to write
Table 3.109. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x08
class
Message class: I2C
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call i2c_start_write(channel,slave_address,data_len, data_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_i2c_start_write(uint8 channel, uint8 slave_address, uint8array data);
/* Response id */
wifi_rsp_i2c_start_write_id
/* Response structure */
struct wifi_msg_i2c_start_write_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 87
WGM110 API Reference Manual
API Reference
3.7.1.3 cmd_i2c_stop
This command is used to stop a read or write I2C transaction.
Table 3.110. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x08
class
Message class: I2C
3
0x02
method
Message ID
4
uint8
channel
I2C module to use
Range: 0 - 1
Table 3.111. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x08
class
Message class: I2C
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call i2c_stop(channel)(result)
BGLIB C API
/* Function */
void wifi_cmd_i2c_stop(uint8 channel);
/* Response id */
wifi_rsp_i2c_stop_id
/* Response structure */
struct wifi_msg_i2c_stop_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 88
WGM110 API Reference Manual
API Reference
3.8 SDCard Command Class
The commands in this class are intended for file and directory handling of the microSD memory card. The use of these commands
requires that the SD card is enabled in the device configuration file and that the microSD card is physically inserted into the microSD
card slot before the Module is powered up. Supported microSD card types are SD and SDHC with up to 32 GB memory size. Supported file systems are FAT16 and FAT32. LFN (long) and 8.3 (short) filenames are supported. Maximum supported path length is 254
characters with slash (/) and backslash (\) characters allowed in the path name string.
For more information on configuration of the microSD card slot see UG161: WGM110 Wi-Fi® Module Configuration User's Guide.
This class consists of the following commands and events:
• Commands
• cmd_sdhc_fchdir
• cmd_sdhc_fchmode
• cmd_sdhc_fclose
• cmd_sdhc_fdelete
• cmd_sdhc_fdir
• cmd_sdhc_fmkdir
• cmd_sdhc_fopen
• cmd_sdhc_fread
• cmd_sdhc_frename
• cmd_sdhc_fwrite
• Events
• evt_sdhc_fdata
• evt_sdhc_ffile
• evt_sdhc_fpwd
• evt_sdhc_ready
Before using the cmd_sdhc_fread, cmd_sdhc_fwrite or cmd_sdhc_frename command, the file must first be opened by using the
cmd_sdhc_fopen command, using a suitable mode parameter. The file will be closed automatically after renaming with cmd_sdhc_frename command.
EXAMPLES
1. File write sequence
a. Open the file with the cmd_sdhc_fopen command.
i. In case of an existing file use parameter mode 0x02.
ii. In case of a new file use parameter mode 0x0a.
Note: In case the file already exists new data will be appended to the end of the file data.
Note: In case an existing file is opened using parameter mode new file (0x0a), all data in the file will be deleted.
b. Send the cmd_sdhc_fwrite command and include data to write.
Note: The maximum data payload that can be included in the command is 512 bytes.
c. Wait for the evt_sdhc_fready event.
d. Repeat steps 2 and 3 until all data is written into the file.
e. Close the file with the cmd_sdhc_fclose command.
2. File read sequence
a. Open the file with the cmd_sdhc_fopen including the parameter mode bit 0x01.
b. Send the cmd_sdhc_fread command including the parameter fsize which defines the required amount of data in bytes.
Note: fsize value "0" indicates that the entire file is read.
c. Wait for and handle evt_sdhc_fdata event(s).
Note: A single event can contain 512 bytes of data, larger amounts of data wll be divided into several events.
d. Wait for the evt_sdhc_fready event which indicates that all data has been read.
e. Close the file with the cmd_sdhc_fclose command.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 89
WGM110 API Reference Manual
API Reference
3. Reading the current active directory
a. Send the cmd_sdhc_fchdir using parameter " '.' " to get the current active directory.
Note: File read with the cmd_sdhc_fread command continues from the previous position until the file is closed.
Note: File read using parameter fsize 0 (reading of the entire file) means that file read is always started at the beginning of the file. The
file pointer will be left pointing to the end of the file after the file has been read. Partial reading of the file is not possible before the file
has first been closed and reopened to reset the file pointer to point to the beginning of the file.
Troubleshooting information
Problem
The microSD card was removed from the card clot during an operation.
Possible actions
• The only way to continue using the microSD card is to reset the Module.
• If the microSD card was removed from the slot during a write operation, the file system of the memory card might be damaged.
Format the microSD card to the proper file system (FAT16 or FAT32) in a PC and retry.
Problem
The command cmd_sdhc_open returns an error code.
Possible actions
• File permissions do not allow opening of the file in the selected mode. An example case would be trying to write into a Read Only
file. Change file attributes.
• The microSD card was removed and inserted back into the slot after Module initialization. Reset the Module.
• The microSD card is full. Remove unnecessary files.
• Incorrect file path. Check the path or make the directory before trying to open the file.
Problem
The event evt_sdhc_ready with an error result code is received at Module initialization.
Possible actions
• The microSD card is not in the slot. Insert the microSD card into the slot and reset the Module.
• The use of microSD cards has not been enabled in the project configuration file or the USART or the chip select pin have been
configured erroneosly. Check the project configuration file.
• The microSD card has a not supported file system. Format the microSD card into FAT16 or FAT32 using a PC.
• The microSD card type is not supported (e.g. SDXC). Use only SD or SDHC type microSD cards.
3.8.1 sdhc commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 90
WGM110 API Reference Manual
API Reference
3.8.1.1 cmd_sdhc_fchdir
This command is used to change the active directory.
Table 3.112. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x07
method
4
uint8array
dir_name
Message ID
Relative or absolute path of the directory
Table 3.113. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x07
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fchdir(dir_name_len, dir_name_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fchdir(uint8array dir_name);
/* Response id */
wifi_rsp_sdhc_fchdir_id
/* Response structure */
struct wifi_msg_sdhc_fchdir_rsp_t
{
uint16 result;
};
Table 3.114. Events Generated
Event
Description
sdhc_fpwd
Sent when the active directory changed
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 91
WGM110 API Reference Manual
API Reference
3.8.1.2 cmd_sdhc_fchmode
This command is used to change the attributes of a file in current active directory.
Table 3.115. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x09
method
4
uint8
value
File attributes as a bitmask
• 0x01: read only
• 0x02: hidden
• 0x04: system
5
uint8array
fname
File name
Message ID
Table 3.116. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x09
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fchmode(value,fname_len, fname_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fchmode(uint8 value, uint8array fname);
/* Response id */
wifi_rsp_sdhc_fchmode_id
/* Response structure */
struct wifi_msg_sdhc_fchmode_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 92
WGM110 API Reference Manual
API Reference
3.8.1.3 cmd_sdhc_fclose
This command is used to close an open file.
Table 3.117. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x01
method
Message ID
4
uint8
fhandle
Handle of the opened file
Table 3.118. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fclose(fhandle)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fclose(uint8 fhandle);
/* Response id */
wifi_rsp_sdhc_fclose_id
/* Response structure */
struct wifi_msg_sdhc_fclose_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 93
WGM110 API Reference Manual
API Reference
3.8.1.4 cmd_sdhc_fdelete
This command is used to delete a file or an empty subdirectory in current active directory.
Table 3.119. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x05
method
Message ID
4
uint8array
fname
File or directory name
Table 3.120. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x05
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fdelete(fname_len, fname_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fdelete(uint8array fname);
/* Response id */
wifi_rsp_sdhc_fdelete_id
/* Response structure */
struct wifi_msg_sdhc_fdelete_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 94
WGM110 API Reference Manual
API Reference
3.8.1.5 cmd_sdhc_fdir
This command is used to list files of a directory.
The command also lists files and folders with the hidden attribute set.
Table 3.121. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x02
method
4
uint8
mode
File list mode
• 0: single directory
• 1: recursive
5
uint8array
path
Path of the directory to list
Message ID
Length: 1 - 254 bytes
Table 3.122. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fdir(mode,path_len, path_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fdir(uint8 mode, uint8array path);
/* Response id */
wifi_rsp_sdhc_fdir_id
/* Response structure */
struct wifi_msg_sdhc_fdir_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 95
WGM110 API Reference Manual
API Reference
Table 3.123. Events Generated
Event
Description
sdhc_ffile
Sent for each listed file
sdhc_ready
Sent after all the files have been listed with operation value 3.
3.8.1.6 cmd_sdhc_fmkdir
This command is used to create a directory.
Table 3.124. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x06
method
4
uint8array
dir_name
Message ID
Relative or absolute path of the directory
Table 3.125. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x06
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fmkdir(dir_name_len, dir_name_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fmkdir(uint8array dir_name);
/* Response id */
wifi_rsp_sdhc_fmkdir_id
/* Response structure */
struct wifi_msg_sdhc_fmkdir_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 96
WGM110 API Reference Manual
API Reference
3.8.1.7 cmd_sdhc_fopen
This command is used to open a file.
The maximum amount of open files is 10.
Table 3.126. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x00
method
4
uint8
mode
File mode as a bitmask
• 0x01: read
• 0x02: write
• 0x08: create new
5
uint8array
fname
File name
Message ID
Length: 1 - 254 bytes
Table 3.127. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fopen(mode,fname_len, fname_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fopen(uint8 mode, uint8array fname);
/* Response id */
wifi_rsp_sdhc_fopen_id
/* Response structure */
struct wifi_msg_sdhc_fopen_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 97
WGM110 API Reference Manual
API Reference
Table 3.128. Events Generated
Event
Description
sdhc_ffile
Sent when the file has been successfully opened.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 98
WGM110 API Reference Manual
API Reference
3.8.1.8 cmd_sdhc_fread
This command is used to read data from a file.
The read data is sent in multiple evt_sdhc_fdata events, each containing up to 512 bytes of data.
Table 3.129. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x05
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x03
method
Message ID
4
uint8
fhandle
Handle of the opened file
5-8
uint32
fsize
Amount to read
• 0: whole file
• non-zero: amount of bytes
Table 3.130. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fread(fhandle,fsize)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fread(uint8 fhandle, uint32 fsize);
/* Response id */
wifi_rsp_sdhc_fread_id
/* Response structure */
struct wifi_msg_sdhc_fread_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 99
WGM110 API Reference Manual
API Reference
Table 3.131. Events Generated
Event
Description
sdhc_fdata
Sent for each block of data
sdhc_ready
Sent after the read operation has been completed with operation value 1.
3.8.1.9 cmd_sdhc_frename
This command is used to rename a file in the current active directory.
Table 3.132. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x08
method
Message ID
4
uint8
fhandle
Handle of the opened file
5
uint8array
new_name
New file name
Table 3.133. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x08
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_frename(fhandle,new_name_len, new_name_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_frename(uint8 fhandle, uint8array new_name);
/* Response id */
wifi_rsp_sdhc_frename_id
/* Response structure */
struct wifi_msg_sdhc_frename_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 100
WGM110 API Reference Manual
API Reference
3.8.1.10 cmd_sdhc_fwrite
This command is used to a write a block of data to a file.
The data will be appended to the end of the file.
Table 3.134. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x04
method
Message ID
4
uint8
fhandle
Handle of the opened file
5-6
uint16array
fdata
Data to write
Length: 1 - 512 bytes
Table 3.135. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x04
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sdhc_fwrite(fhandle,fdata_len, fdata_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sdhc_fwrite(uint8 fhandle, uint16array fdata);
/* Response id */
wifi_rsp_sdhc_fwrite_id
/* Response structure */
struct wifi_msg_sdhc_fwrite_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 101
WGM110 API Reference Manual
API Reference
Table 3.136. Events Generated
Event
Description
sdhc_ready
Sent after the write operation has been completed with operation value 2.
3.8.2 sdhc events
3.8.2.1 evt_sdhc_fdata
This event contains a block of file data.
Table 3.137. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x01
method
Message ID
4
uint8
fhandle
Handle of the opened file
5-6
uint16array
data
File data
BGScript event
event sdhc_fdata(fhandle,data_len, data_data)
C Functions
/* Event id */
wifi_evt_sdhc_fdata_id
/* Event structure */
struct wifi_msg_sdhc_fdata_evt_t
{
uint8 fhandle;,
uint16array data;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 102
WGM110 API Reference Manual
API Reference
3.8.2.2 evt_sdhc_ffile
This event contains file information.
Table 3.138. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x07
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x02
method
Message ID
4
uint8
fhandle
Handle of the opened file
255: file not opened
5-8
uint32
fsize
File size in bytes
9
uint8
fattrib
File attributes as a bitmask
• 0x01: read only
• 0x02: hidden
• 0x04: system
• 0x10: directory
10
uint8array
fname
File name
BGScript event
event sdhc_ffile(fhandle,fsize,fattrib,fname_len, fname_data)
C Functions
/* Event id */
wifi_evt_sdhc_ffile_id
/* Event structure */
struct wifi_msg_sdhc_ffile_evt_t
{
uint8 fhandle;,
uint32 fsize;,
uint8 fattrib;,
uint8array fname;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 103
WGM110 API Reference Manual
API Reference
3.8.2.3 evt_sdhc_fpwd
This event indicates the current active directory.
Table 3.139. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x03
method
4
uint8array
fdir
Message ID
Directory name with path
BGScript event
event sdhc_fpwd(fdir_len, fdir_data)
C Functions
/* Event id */
wifi_evt_sdhc_fpwd_id
/* Event structure */
struct wifi_msg_sdhc_fpwd_evt_t
{
uint8array fdir;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 104
WGM110 API Reference Manual
API Reference
3.8.2.4 evt_sdhc_ready
This event indicates that an SD card operation has finished.
Table 3.140. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x04
lolen
Minimum payload length
2
0x0c
class
Message class: SD card
3
0x00
method
Message ID
4
uint8
fhandle
Handle of the opened file
5
uint8
operation
6-7
uint16
result
Operation which caused the event
• 0: card detection state
• 1: file read
• 2: file write
• 3: directory listing
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript event
event sdhc_ready(fhandle,operation,result)
C Functions
/* Event id */
wifi_evt_sdhc_ready_id
/* Event structure */
struct wifi_msg_sdhc_ready_evt_t
{
uint8 fhandle;,
uint8 operation;,
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 105
WGM110 API Reference Manual
API Reference
3.9 Wi-Fi Command Class
The commands in this class are used to control Wi-Fi Station Management Entity (SME) functionality, more specifically to control the
Wi-Fi chip functionality of the Module, network scanning and connections of the Wi-Fi client and access point.
This class consists of the following commands and events:
Wi-Fi chip control related
• Commands
• cmd_sme_wifi_on
• cmd_sme_wifi_off
• cmd_sme_set_operating_mode
• cmd_sme_get_signal_quality
• Events
• evt_sme_wifi_is_on
• evt_sme_wifi_is_off
• evt_sme_signal_quality
Wi-Fi network scan related
• Commands
• cmd_sme_set_scan_channels
• cmd_sme_start_scan
• cmd_sme_stop_scan
• cmd_sme_scan_results_sort_rssi
• Events
• evt_sme_scan_result
• evt_sme_scan_result_drop
• evt_sme_scanned
• evt_sme_scan_sort_result
• evt_sme_scan_sort_finished
Client mode connection related
• Commands
• cmd_sme_set_password
• cmd_sme_connect_bssid
• cmd_sme_connect_ssid
• cmd_sme_disconnect
• Events
• evt_sme_connected
• evt_sme_connect_failed
• evt_sme_connect_retry
• evt_sme_interface_status
• evt_sme_disconnected
Client WPS (Wi-Fi Protected Setup) related
• Commands
• cmd_sme_start_wps
• cmd_sme_stop_wps
• Events
• evt_sme_wps_completed
• evt_sme_wps_failed
• evt_sme_wps_credential_ssid
• evt_sme_wps_credential_password
• evt_sme_wps_stopped
Access Point Mode related
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 106
WGM110 API Reference Manual
API Reference
• Commands
• cmd_sme_start_ap_mode
• cmd_sme_stop_ap_mode
• cmd_sme_set_ap_password
• cmd_sme_set_ap_max_clients
• Events
• evt_sme_ap_mode_started
• evt_sme_ap_mode_failed
• evt_sme_ap_mode_stopped
• evt_sme_ap_client_joined
• evt_sme_ap_client_left
Examples
1. Connecting to a Wi-Fi network using SSID and DHCP client
a. Select the operation mode of the client using the cmd_sme_set_operation_mode command.
b. Send the cmd_sme_wifi_on command to power up the Wi-Fi chip.
c. Wait for the evt_sme_wifi_is_on event.
Note: Wi-Fi chip power-up may take upto 10 seconds.
d. Set the network password using the cmd_sme_set_password command.
e. Connect to the network using the cmd_sme_connect_ssid command.
f. Wait for the evt_sme_connected event.
g. The Module will send the events evt_tcpip_configuration and evt_tcpip_dns_configuration while resolving the network parameters.
h. The event evt_sme_interface_status indicates that a connection has been established.
3.9.1 sme commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 107
WGM110 API Reference Manual
API Reference
3.9.1.1 cmd_sme_ap_client_disconnect
This command is used to disconnect a client from the Access Point.
Table 3.141. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x06
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0e
method
4-9
hw_addr
mac_address
Message ID
MAC address of the client
Table 3.142. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0e
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_ap_client_disconnect(mac_address)(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_ap_client_disconnect(hw_addr mac_address);
/* Response id */
wifi_rsp_sme_ap_client_disconnect_id
/* Response structure */
struct wifi_msg_sme_ap_client_disconnect_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
Table 3.143. Events Generated
Event
Description
sme_ap_client_left
Sent after the client has been disconnected
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 108
WGM110 API Reference Manual
API Reference
3.9.1.2 cmd_sme_connect_bssid
This command is used to try to connect to a specific Access Point using its unique BSSID.
The command requires a preceding sme_start_scan or sme_start_ssid_scan command and that the desired Access Point was found
during that scan. When connecting to an Access Point on channel 12 or 13, at least one of the Access Points discovered in the scan
must advertise the use of channels up to 13.
An ongoing connection attempt can be canceled using the sme_disconnect command.
Table 3.144. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x06
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x06
method
4-9
hw_addr
bssid
Message ID
The BSSID of the Access Point to connect to
Table 3.145. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x09
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x06
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
7-12
hw_addr
bssid
Hardware interface
• 0: Wi-Fi
The BSSID of the Access Point that the device will attempt to connect to
BGScript command
call sme_connect_bssid(bssid)(result,hw_interface,bssid)
BGLIB C API
/* Function */
void wifi_cmd_sme_connect_bssid(hw_addr bssid);
/* Response id */
wifi_rsp_sme_connect_bssid_id
/* Response structure */
struct wifi_msg_sme_connect_bssid_rsp_t
{
uint16 result;,
uint8 hw_interface;,
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 109
WGM110 API Reference Manual
API Reference
hw_addr bssid;
};
Table 3.146. Events Generated
Event
Description
sme_connect_retry
Sent when the connection attempt fails and it is automatically retried
sme_connected
Sent when the connection attempt succeeds
sme_connect_failed
Sent when the connection attempt fails
tcpip_configuration
Sent when the IP address of the Wi-Fi interface has been activated
tcpip_dns_configuration
Sent when the DNS address of the Wi-Fi interface has been activated
sme_interface_status
Sent after the Wi-Fi interface has been activated
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 110
WGM110 API Reference Manual
API Reference
3.9.1.3 cmd_sme_connect_ssid
This command is used to start a connection establishment procedure with an Access Point with the given SSID.
Executing this command launches an internal scan procedure in order to discover the Access Points in range. The results of the scan
are NOT exposed via BGAPI nor stored in the internal scan list. The channels used in the scan procedure can be defined with the
sme_set_scan_channels command. If the command has not been executed, all channels will be scanned. When connecting to an Access Point on channel 12 or 13, at least one of the Access Points discovered in the scan must advertise the use of channels up to 13.
An ongoing connection attempt can be canceled using the sme_disconnect command.
Table 3.147. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x07
method
4
uint8array
ssid
Message ID
The SSID of the network to connect to
Table 3.148. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x09
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x07
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
7-12
hw_addr
bssid
Hardware interface
• 0: Wi-Fi
The BSSID of the Access Point that the device will attempt to connect to.
Since the command attempts to connect based on the SSID, this
parameter is not valid and is always zero.
BGScript command
call sme_connect_ssid(ssid_len, ssid_data)(result,hw_interface,bssid)
BGLIB C API
/* Function */
void wifi_cmd_sme_connect_ssid(uint8array ssid);
/* Response id */
wifi_rsp_sme_connect_ssid_id
/* Response structure */
struct wifi_msg_sme_connect_ssid_rsp_t
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 111
WGM110 API Reference Manual
API Reference
{
uint16 result;,
uint8 hw_interface;,
hw_addr bssid;
};
Table 3.149. Events Generated
Event
Description
sme_connect_retry
Sent when the connection attempt fails and it is automatically retried
sme_connected
Sent when the connection attempt succeeds
sme_connect_failed
Sent when the connection attempt fails
tcpip_configuration
Sent when the IP address of the Wi-Fi interface has been activated
tcpip_dns_configuration
Sent when the DNS address of the Wi-Fi interface has been activated
sme_interface_status
Sent after the Wi-Fi interface has been activated
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 112
WGM110 API Reference Manual
API Reference
3.9.1.4 cmd_sme_disconnect
This command is used to cancel an ongoing connection attempt or disconnect from the currently connected Access Point.
Table 3.150. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x08
method
Message ID
Table 3.151. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x08
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_disconnect()(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_disconnect();
/* Response id */
wifi_rsp_sme_disconnect_id
/* Response structure */
struct wifi_msg_sme_disconnect_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
Table 3.152. Events Generated
Event
Description
sme_disconnected
Sent after disconnected
tcpip_configuration
Sent when the IP address of the Wi-Fi interface has been deactivated
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 113
WGM110 API Reference Manual
API Reference
Event
Description
tcpip_dns_configuration
Sent when the DNS address of the Wi-Fi interface has been deactivated
sme_interface_status
Sent after the Wi-Fi interface has been deactivated
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 114
WGM110 API Reference Manual
API Reference
3.9.1.5 cmd_sme_get_signal_quality
This command is used to get a value indicating the signal quality of the connection.
The command is applicable only in client mode
Table 3.153. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x13
method
Message ID
Table 3.154. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x13
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_get_signal_quality()(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_get_signal_quality();
/* Response id */
wifi_rsp_sme_get_signal_quality_id
/* Response structure */
struct wifi_msg_sme_get_signal_quality_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
Table 3.155. Events Generated
Event
Description
sme_signal_quality
Connection signal quality
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 115
WGM110 API Reference Manual
API Reference
3.9.1.6 cmd_sme_scan_results_sort_rssi
This command is used to retrieve results from the internal scan list, sorted according to RSSI value.
The command can be run only after the sme_start_scan command or the sme_start_ssid_scan command has been issued at least
once during the current session.
Table 3.156. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0d
method
Message ID
4
uint8
amount
Maximum amount of entries to retrieve
Range: 1 - 40
Table 3.157. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0d
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_scan_results_sort_rssi(amount)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_scan_results_sort_rssi(uint8 amount);
/* Response id */
wifi_rsp_sme_scan_results_sort_rssi_id
/* Response structure */
struct wifi_msg_sme_scan_results_sort_rssi_rsp_t
{
uint16 result;
};
Table 3.158. Events Generated
Event
Description
sme_scan_sort_result
Sent for each Access Point
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 116
WGM110 API Reference Manual
API Reference
Event
Description
sme_scan_sort_finished
Sent after the operation completes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 117
WGM110 API Reference Manual
API Reference
3.9.1.7 cmd_sme_set_11n_mode
This command is used to select whether 802.11n mode is enabled or disabled.
The mode is enabled by default.
Table 3.159. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x16
method
4
uint8
mode
Message ID
802.11n mode
• 0: disabled
• 1: enabled
Table 3.160. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x16
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_set_11n_mode(mode)(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_11n_mode(uint8 mode);
/* Response id */
wifi_rsp_sme_set_11n_mode_id
/* Response structure */
struct wifi_msg_sme_set_11n_mode_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 118
WGM110 API Reference Manual
API Reference
3.9.1.8 cmd_sme_set_ap_hidden
This command is used to set whether the Access Point is hidden or visible.
The Access Point is set visible by default.
Table 3.161. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x15
method
Message ID
4
uint8
hidden
Visibility
• 0: visible
• 1: hidden
Table 3.162. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x15
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_set_ap_hidden(hidden)(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_ap_hidden(uint8 hidden);
/* Response id */
wifi_rsp_sme_set_ap_hidden_id
/* Response structure */
struct wifi_msg_sme_set_ap_hidden_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 119
WGM110 API Reference Manual
API Reference
3.9.1.9 cmd_sme_set_ap_max_clients
This command is used to set the maximum amount of clients that can be associated to the Access Point simultaneously.
The command does not affect currently connected clients.
Table 3.163. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x10
method
4
uint8
max_clients
Message ID
The maximum amount of clients
Range: 0 - 5
Table 3.164. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x10
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_set_ap_max_clients(max_clients)(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_ap_max_clients(uint8 max_clients);
/* Response id */
wifi_rsp_sme_set_ap_max_clients_id
/* Response structure */
struct wifi_msg_sme_set_ap_max_clients_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 120
WGM110 API Reference Manual
API Reference
3.9.1.10 cmd_sme_set_ap_password
This command is used to set the Wi-Fi password for the Access Point mode.
Table 3.165. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0f
method
4
uint8array
password
Message ID
The password to be used for the Access Point
• WPA/WPA2-PSK is either a hash of 64 hexadecimal characters, or a pass-phrase of 8 to 63 ASCII-encoded characters
• 64-bit WEP key is either 5 ASCII-encoded characters or 10
HEX characters
• 128-bit WEP key is either 13 ASCII-encoded characters or 26
HEX characters
Table 3.166. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0f
method
4
uint8
status
Message ID
Result code
• 0: success
• 128: invalid password
BGScript command
call sme_set_ap_password(password_len, password_data)(status)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_ap_password(uint8array password);
/* Response id */
wifi_rsp_sme_set_ap_password_id
/* Response structure */
struct wifi_msg_sme_set_ap_password_rsp_t
{
uint8 status;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 121
WGM110 API Reference Manual
API Reference
3.9.1.11 cmd_sme_set_eap_configuration
This command is used to set the EAP configuration, which is used when authenticating with a secure Access Point.
Table 3.167. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x17
method
4
uint8
outer_type
Outer (tunneling) EAP type
5
uint8
inner_type
Inner EAP type
6
uint8array
identity
Message ID
Identity
Length: 0 - 255 bytes
Table 3.168. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x17
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_set_eap_configuration(outer_type,inner_type,identity_len, identity_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_eap_configuration(uint8 outer_type, uint8 inner_type, uint8array identity);
/* Response id */
wifi_rsp_sme_set_eap_configuration_id
/* Response structure */
struct wifi_msg_sme_set_eap_configuration_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 122
WGM110 API Reference Manual
API Reference
3.9.1.12 cmd_sme_set_eap_type_ca_certificate
This command is used to set the required CA certificate of an EAP type.
Connection attempt will fail if the certificate chain given by the authentication server cannot be verified using the provided CA certificate.
If no CA certificate has been set, the internal certificate store is checked for a suitable certificate.
Table 3.169. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x1a
method
4
uint8
type
5
uint8array
fingerprint
Message ID
EAP type
Fingerprint of the CA certificate
Length: 16 bytes
Table 3.170. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x1a
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_set_eap_type_ca_certificate(type,fingerprint_len, fingerprint_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_eap_type_ca_certificate(uint8 type, uint8array fingerprint);
/* Response id */
wifi_rsp_sme_set_eap_type_ca_certificate_id
/* Response structure */
struct wifi_msg_sme_set_eap_type_ca_certificate_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 123
WGM110 API Reference Manual
API Reference
3.9.1.13 cmd_sme_set_eap_type_password
This command is used to set the password of an EAP type.
Table 3.171. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x19
method
4
uint8
type
EAP type
5
uint8array
password
Password
Message ID
Length: 0 - 255 bytes
Table 3.172. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x19
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_set_eap_type_password(type,password_len, password_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_eap_type_password(uint8 type, uint8array password);
/* Response id */
wifi_rsp_sme_set_eap_type_password_id
/* Response structure */
struct wifi_msg_sme_set_eap_type_password_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 124
WGM110 API Reference Manual
API Reference
3.9.1.14 cmd_sme_set_eap_type_server_common_name
This command is used to set the required Common Name of an EAP type.
Connection attempt will fail if the Common Name in the server certificate given by the authentication server does not match the set
value. If not set, Common Name value is ignored.
Table 3.173. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x1b
method
4
uint8
type
5
uint8array
common_name
Message ID
EAP type
Server common name
Length: 0 - 255 bytes
Table 3.174. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x1b
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_set_eap_type_server_common_name(type,common_name_len, common_name_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_eap_type_server_common_name(uint8 type, uint8array common_name);
/* Response id */
wifi_rsp_sme_set_eap_type_server_common_name_id
/* Response structure */
struct wifi_msg_sme_set_eap_type_server_common_name_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 125
WGM110 API Reference Manual
API Reference
3.9.1.15 cmd_sme_set_eap_type_user_certificate
This command is used to set the client certificate of an EAP type.
If set, the certificate will be sent to the authentication server if requested by the server during authentication.
Table 3.175. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x1c
method
4
uint8
type
5
uint8array
fingerprint
Message ID
EAP type
Fingerprint of the client certificate
Length: 16 bytes
Table 3.176. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x1c
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_set_eap_type_user_certificate(type,fingerprint_len, fingerprint_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_eap_type_user_certificate(uint8 type, uint8array fingerprint);
/* Response id */
wifi_rsp_sme_set_eap_type_user_certificate_id
/* Response structure */
struct wifi_msg_sme_set_eap_type_user_certificate_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 126
WGM110 API Reference Manual
API Reference
3.9.1.16 cmd_sme_set_eap_type_username
This command is used to set the user name of an EAP type.
Table 3.177. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x18
method
4
uint8
type
5
uint8array
username
Message ID
EAP type
User name
Length: 0 - 255 bytes
Table 3.178. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x18
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_set_eap_type_username(type,username_len, username_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_eap_type_username(uint8 type, uint8array username);
/* Response id */
wifi_rsp_sme_set_eap_type_username_id
/* Response structure */
struct wifi_msg_sme_set_eap_type_username_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 127
WGM110 API Reference Manual
API Reference
3.9.1.17 cmd_sme_set_operating_mode
This command is used to set the Wi-Fi operating mode, either to Wi-Fi client or Wi-Fi Access Point.
The selected operating mode will become effective the next time the Wi-Fi radio is switched on using the sme_wifi_on command.
Table 3.179. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0a
method
4
uint8
mode
Message ID
Operating mode
• 1: client
• 2: Access Point
Table 3.180. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0a
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_set_operating_mode(mode)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_operating_mode(uint8 mode);
/* Response id */
wifi_rsp_sme_set_operating_mode_id
/* Response structure */
struct wifi_msg_sme_set_operating_mode_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 128
WGM110 API Reference Manual
API Reference
3.9.1.18 cmd_sme_set_password
This command is used to set the password used when authenticating with a secure Access Point.
There is no password set by default.
Table 3.181. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x05
method
4
uint8array
password
Message ID
WEP/WPA/WPA2 pre-shared password to be used when connecting to an Access Point
• WPA/WPA2-PSK is either a hash of 64 hexadecimal characters, or a pass-phrase of 8 to 63 ASCII-encoded characters
• 64-bit WEP key is either 5 ASCII-encoded characters or 10
HEX characters
• 128-bit WEP key is either 13 ASCII-encoded characters or 26
HEX characters
Table 3.182. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x05
method
4
uint8
status
Message ID
Result code
• 0: success
• 128: invalid password
BGScript command
call sme_set_password(password_len, password_data)(status)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_password(uint8array password);
/* Response id */
wifi_rsp_sme_set_password_id
/* Response structure */
struct wifi_msg_sme_set_password_rsp_t
{
uint8 status;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 129
WGM110 API Reference Manual
API Reference
3.9.1.19 cmd_sme_set_scan_channels
This command is used to set the default scan channel list.
Table 3.183. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x09
method
4
uint8
hw_interface
5
uint8array
chList
Message ID
Hardware interface
• 0: Wi-Fi
List of channel numbers to scan.
All channels are scanned by default if this command is never
used.
Table 3.184. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x09
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_set_scan_channels(hw_interface,chList_len, chList_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_set_scan_channels(uint8 hw_interface, uint8array chList);
/* Response id */
wifi_rsp_sme_set_scan_channels_id
/* Response structure */
struct wifi_msg_sme_set_scan_channels_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 130
WGM110 API Reference Manual
API Reference
3.9.1.20 cmd_sme_start_ap_mode
This command is used to start the Access Point mode.
In order to start the Access Point on channel 12 or 13, at least one Access Point discovered in a scan must advertise the use of channels up to 13.
Table 3.185. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0b
method
Message ID
4
uint8
channel
Channel to use
Range: 1 - 13
5
uint8
security
6
uint8array
ssid
Security mode
• 0: open security
• 1: WPA security
• 2: WPA2 security
• 3: WEP security
SSID to use
Length: 1 - 32 bytes
Table 3.186. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0b
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_start_ap_mode(channel,security,ssid_len, ssid_data)(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_start_ap_mode(uint8 channel, uint8 security, uint8array ssid);
/* Response id */
wifi_rsp_sme_start_ap_mode_id
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 131
WGM110 API Reference Manual
API Reference
/* Response structure */
struct wifi_msg_sme_start_ap_mode_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
Table 3.187. Events Generated
Event
Description
sme_ap_mode_started
Sent after Access Point mode successfully started
sme_ap_mode_failed
Sent after Access Point mode fails
tcpip_configuration
Sent when the IP address of the Wi-Fi interface has been activated
tcpip_dns_configuration
Sent when the DNS address of the Wi-Fi interface has been activated
sme_interface_status
Sent after Wi-Fi interface has been activated
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 132
WGM110 API Reference Manual
API Reference
3.9.1.21 cmd_sme_start_scan
This command initiates a scan for Access Points.
Scanning is not possible once connected or once Access Point mode has been started.
The internal scan list is cleared before the scan is initiated.
Table 3.188. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x03
method
4
uint8
hw_interface
5
uint8array
chList
Message ID
Hardware interface
• 0: Wi-Fi
The list of channel numbers which will be scanned for Access
Points. If empty, the scan will be performed using the channels
set with the sme_set_scan_channels command.
Table 3.189. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_start_scan(hw_interface,chList_len, chList_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_start_scan(uint8 hw_interface, uint8array chList);
/* Response id */
wifi_rsp_sme_start_scan_id
/* Response structure */
struct wifi_msg_sme_start_scan_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 133
WGM110 API Reference Manual
API Reference
Table 3.190. Events Generated
Event
Description
sme_scan_result
Sent for each Access Point discovered
sme_scan_result_drop
Sent for each Access Point dropped from the internal scan list
sme_scanned
Sent after the scan completes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 134
WGM110 API Reference Manual
API Reference
3.9.1.22 cmd_sme_start_ssid_scan
This command is used to initiate an active scan for Access Points.
Scanning is not possible once connected or once Access Point mode has been started.
The internal scan list is cleared before the scan is initiated.
Table 3.191. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x14
method
4
uint8array
ssid
Message ID
The SSID to scan for
Length: 0 - 32 bytes
If 0, all SSIDs are scanned.
Table 3.192. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x14
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_start_ssid_scan(ssid_len, ssid_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_start_ssid_scan(uint8array ssid);
/* Response id */
wifi_rsp_sme_start_ssid_scan_id
/* Response structure */
struct wifi_msg_sme_start_ssid_scan_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 135
WGM110 API Reference Manual
API Reference
Table 3.193. Events Generated
Event
Description
sme_scan_result
Sent for each Access Point discovered
sme_scan_result_drop
Sent for each Access Point dropped from the internal scan list
sme_scanned
Sent after the scan completes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 136
WGM110 API Reference Manual
API Reference
3.9.1.23 cmd_sme_start_wps
This command is used to start the Wi-Fi Protected Setup (WPS) session.
Only WPS push-button mode (PBC) is supported. The session will timeout in 120 seconds if no Access Point in WPS mode is discovered.
This command can only be used in client mode.
Table 3.194. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x11
method
Message ID
Table 3.195. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x11
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_start_wps()(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_start_wps();
/* Response id */
wifi_rsp_sme_start_wps_id
/* Response structure */
struct wifi_msg_sme_start_wps_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 137
WGM110 API Reference Manual
API Reference
Table 3.196. Events Generated
Event
Description
sme_wps_completed
Sent when WPS session completes successfully
sme_wps_failed
Sent when WPS session fails or timeouts
sme_wps_credential_ssid
Received network name credential
sme_wps_credential_password
Received network password credential
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 138
WGM110 API Reference Manual
API Reference
3.9.1.24 cmd_sme_stop_ap_mode
This command is used to stop the Access Point mode.
Table 3.197. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0c
method
Message ID
Table 3.198. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0c
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_stop_ap_mode()(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_stop_ap_mode();
/* Response id */
wifi_rsp_sme_stop_ap_mode_id
/* Response structure */
struct wifi_msg_sme_stop_ap_mode_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
Table 3.199. Events Generated
Event
Description
sme_ap_mode_stopped
Sent after Access Point mode was stopped
tcpip_configuration
Sent when the IP address of the Wi-Fi interface has been deactivated
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 139
WGM110 API Reference Manual
API Reference
Event
Description
tcpip_dns_configuration
Sent when the DNS address of the Wi-Fi interface has been deactivated
sme_interface_status
Sent after Wi-Fi interface has been deactivated
3.9.1.25 cmd_sme_stop_scan
This command is used to terminate the active scanning procedure.
Table 3.200. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x04
method
Message ID
Table 3.201. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x04
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_stop_scan()(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_stop_scan();
/* Response id */
wifi_rsp_sme_stop_scan_id
/* Response structure */
struct wifi_msg_sme_stop_scan_rsp_t
{
uint16 result;
};
Table 3.202. Events Generated
Event
Description
sme_scanned
Sent after scan stopped
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 140
WGM110 API Reference Manual
API Reference
3.9.1.26 cmd_sme_stop_wps
This command is used to stop the Wi-Fi Protected Setup (WPS) session.
Table 3.203. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x12
method
Message ID
Table 3.204. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x12
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript command
call sme_stop_wps()(result,hw_interface)
BGLIB C API
/* Function */
void wifi_cmd_sme_stop_wps();
/* Response id */
wifi_rsp_sme_stop_wps_id
/* Response structure */
struct wifi_msg_sme_stop_wps_rsp_t
{
uint16 result;,
uint8 hw_interface;
};
Table 3.205. Events Generated
Event
Description
sme_wps_stopped
Sent after WPS session was stopped
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 141
WGM110 API Reference Manual
API Reference
3.9.1.27 cmd_sme_wifi_off
This command is used to turn off the Wi-Fi radio.
Table 3.206. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x01
method
Message ID
Table 3.207. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_wifi_off()(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_wifi_off();
/* Response id */
wifi_rsp_sme_wifi_off_id
/* Response structure */
struct wifi_msg_sme_wifi_off_rsp_t
{
uint16 result;
};
Table 3.208. Events Generated
Event
Description
sme_wifi_is_off
Sent after Wi-Fi radio has been switched off
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 142
WGM110 API Reference Manual
API Reference
3.9.1.28 cmd_sme_wifi_on
This command is used to switch on the Wi-Fi radio.
Table 3.209. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x00
method
Message ID
Table 3.210. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call sme_wifi_on()(result)
BGLIB C API
/* Function */
void wifi_cmd_sme_wifi_on();
/* Response id */
wifi_rsp_sme_wifi_on_id
/* Response structure */
struct wifi_msg_sme_wifi_on_rsp_t
{
uint16 result;
};
Table 3.211. Events Generated
Event
Description
sme_wifi_is_on
Sent after Wi-Fi radio has been switched on
3.9.2 sme events
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 143
WGM110 API Reference Manual
API Reference
3.9.2.1 evt_sme_ap_client_joined
This event indicates that a Wi-Fi client has joined the Access Point.
Table 3.212. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x07
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0d
method
4-9
hw_addr
mac_address
MAC address of the client
10
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
Message ID
BGScript event
event sme_ap_client_joined(mac_address,hw_interface)
C Functions
/* Event id */
wifi_evt_sme_ap_client_joined_id
/* Event structure */
struct wifi_msg_sme_ap_client_joined_evt_t
{
hw_addr mac_address;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 144
WGM110 API Reference Manual
API Reference
3.9.2.2 evt_sme_ap_client_left
This event indicates that a Wi-Fi client has left the Access Point.
In case a client moves out of range or is abruptly powered off, it might take from 180 to 270 seconds for this event to be issued.
Table 3.213. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x07
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0e
method
4-9
hw_addr
mac_address
MAC address of the client
10
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
Message ID
BGScript event
event sme_ap_client_left(mac_address,hw_interface)
C Functions
/* Event id */
wifi_evt_sme_ap_client_left_id
/* Event structure */
struct wifi_msg_sme_ap_client_left_evt_t
{
hw_addr mac_address;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 145
WGM110 API Reference Manual
API Reference
3.9.2.3 evt_sme_ap_mode_failed
This event indicates that the Access Point mode has failed.
Table 3.214. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0c
method
Message ID
4-5
uint16
reason
Reason of fail
For values refer to the error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_ap_mode_failed(reason,hw_interface)
C Functions
/* Event id */
wifi_evt_sme_ap_mode_failed_id
/* Event structure */
struct wifi_msg_sme_ap_mode_failed_evt_t
{
uint16 reason;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 146
WGM110 API Reference Manual
API Reference
3.9.2.4 evt_sme_ap_mode_started
This event indicates that the Access Point mode has been successfully started.
Table 3.215. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0a
method
4
uint8
hw_interface
Message ID
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_ap_mode_started(hw_interface)
C Functions
/* Event id */
wifi_evt_sme_ap_mode_started_id
/* Event structure */
struct wifi_msg_sme_ap_mode_started_evt_t
{
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 147
WGM110 API Reference Manual
API Reference
3.9.2.5 evt_sme_ap_mode_stopped
This event indicates that the Access Point mode has been stopped.
Table 3.216. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0b
method
4
uint8
hw_interface
Message ID
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_ap_mode_stopped(hw_interface)
C Functions
/* Event id */
wifi_evt_sme_ap_mode_stopped_id
/* Event structure */
struct wifi_msg_sme_ap_mode_stopped_evt_t
{
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 148
WGM110 API Reference Manual
API Reference
3.9.2.6 evt_sme_connect_failed
This event indicates a failed connection to an Access Point.
The event may occur if the device is unable to establish a connection to an Access Point or if the Access Point disconnects the device
during the connection.
Table 3.217. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x08
method
Message ID
4-5
uint16
reason
Reason of connect fail
For values refer to the error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_connect_failed(reason,hw_interface)
C Functions
/* Event id */
wifi_evt_sme_connect_failed_id
/* Event structure */
struct wifi_msg_sme_connect_failed_evt_t
{
uint16 reason;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 149
WGM110 API Reference Manual
API Reference
3.9.2.7 evt_sme_connect_retry
This event indicates that a connection attempt failed.
The connection is automatically retried until the retry limit of 10 attempts is exceeded. This event typically appears when the device is
commanded to connect to a wireless network but the given password is wrong. Automatic retries can be stopped with the
cmd_sme_disconnect command.
Table 3.218. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x09
method
4
uint8
hw_interface
Message ID
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_connect_retry(hw_interface)
C Functions
/* Event id */
wifi_evt_sme_connect_retry_id
/* Event structure */
struct wifi_msg_sme_connect_retry_evt_t
{
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 150
WGM110 API Reference Manual
API Reference
3.9.2.8 evt_sme_connected
This event indicates a connection status to an Access Point.
Table 3.219. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x08
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x05
method
4
int8
status
Connection status
• 0: connected
• 1: not connected
5
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
6-11
hw_addr
bssid
Message ID
The BSSID of the device that the device connected to
BGScript event
event sme_connected(status,hw_interface,bssid)
C Functions
/* Event id */
wifi_evt_sme_connected_id
/* Event structure */
struct wifi_msg_sme_connected_evt_t
{
int8 status;,
uint8 hw_interface;,
hw_addr bssid;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 151
WGM110 API Reference Manual
API Reference
3.9.2.9 evt_sme_disconnected
This event indicates a disconnection from an Access Point.
The event occurs either because the sme_disconnect command was issued or connection to an Access Point was lost. Connection loss
could occur because the Access Point has been switched off or the user has moved out of range. The timeout for detecting a lost connection is 50 beacons which under typical network configuration translates to roughly 5 seconds.
Table 3.220. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x06
method
Message ID
4-5
uint16
reason
Disconnect reason
For values refer to the error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_disconnected(reason,hw_interface)
C Functions
/* Event id */
wifi_evt_sme_disconnected_id
/* Event structure */
struct wifi_msg_sme_disconnected_evt_t
{
uint16 reason;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 152
WGM110 API Reference Manual
API Reference
3.9.2.10 evt_sme_interface_status
This event indicates the current Wi-Fi interface status.
Table 3.221. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x07
method
4
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
5
uint8
status
Interface status
• 0: interface down
• 1: interface up
Message ID
BGScript event
event sme_interface_status(hw_interface,status)
C Functions
/* Event id */
wifi_evt_sme_interface_status_id
/* Event structure */
struct wifi_msg_sme_interface_status_evt_t
{
uint8 hw_interface;,
uint8 status;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 153
WGM110 API Reference Manual
API Reference
3.9.2.11 evt_sme_scan_result
This event indicates that an Access Point has been discovered.
After a scan has been started this event is sent every time an Access Point is discovered. Access Point is also added to internal scan
list and it is possible to connect to it.
Table 3.222. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x0c
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x02
method
4-9
hw_addr
bssid
The BSSID of the Access Point which was discovered
10
int8
channel
The channel on which the Access Point was detected
11-12
int16
rssi
The received signal strength indication of the Access Point
13
int8
snr
The signal to noise ratio of the Access Point
14
uint8
secure
15
uint8array
ssid
Message ID
Access Point security status as a bitmask
• bit 0: defines whether Access Point supports secure connections
• bit 1: defines whether the Access Point supports WPS
The SSID of the network the Access Point belongs to
BGScript event
event sme_scan_result(bssid,channel,rssi,snr,secure,ssid_len, ssid_data)
C Functions
/* Event id */
wifi_evt_sme_scan_result_id
/* Event structure */
struct wifi_msg_sme_scan_result_evt_t
{
hw_addr bssid;,
int8 channel;,
int16 rssi;,
int8 snr;,
uint8 secure;,
uint8array ssid;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 154
WGM110 API Reference Manual
API Reference
3.9.2.12 evt_sme_scan_result_drop
This event indicates that the Access Point was dropped from the internal scan list.
The internal scan list has a limit of 40 Access Points. If the limit is exceeded, Access Point with the weakest signal strength is removed
from the list to make room for new Access Points. It is no longer possible to connect to it anymore using the sme_connect_bssid command.
Table 3.223. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x06
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x03
method
4-9
hw_addr
bssid
Message ID
The BSSID of the Access Point that was dropped
BGScript event
event sme_scan_result_drop(bssid)
C Functions
/* Event id */
wifi_evt_sme_scan_result_drop_id
/* Event structure */
struct wifi_msg_sme_scan_result_drop_evt_t
{
hw_addr bssid;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 155
WGM110 API Reference Manual
API Reference
3.9.2.13 evt_sme_scan_sort_finished
This event indicates that the scan result sort is finished.
Table 3.224. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x00
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x10
method
Message ID
BGScript event
event sme_scan_sort_finished()
C Functions
/* Event id */
wifi_evt_sme_scan_sort_finished_id
/* Event structure */
struct wifi_msg_sme_scan_sort_finished_evt_t
{
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 156
WGM110 API Reference Manual
API Reference
3.9.2.14 evt_sme_scan_sort_result
This event indicates a scan result from the internal scan list.
Table 3.225. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x0c
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x0f
method
4-9
hw_addr
bssid
10
int8
channel
11-12
int16
rssi
The received signal strength indication of the found Access Point
13
int8
snr
The signal to noise ratio of the Access Point
14
uint8
secure
15
uint8array
ssid
Message ID
The BSSID of the Access Point discovered
The channel on which the Access Point was seen
Access Point security status as a bitmask
• bit 0: Access Point supports secure connections
• bit 1: Access Point supports WPS
The SSID of the network the Access Point belongs to
BGScript event
event sme_scan_sort_result(bssid,channel,rssi,snr,secure,ssid_len, ssid_data)
C Functions
/* Event id */
wifi_evt_sme_scan_sort_result_id
/* Event structure */
struct wifi_msg_sme_scan_sort_result_evt_t
{
hw_addr bssid;,
int8 channel;,
int16 rssi;,
int8 snr;,
uint8 secure;,
uint8array ssid;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 157
WGM110 API Reference Manual
API Reference
3.9.2.15 evt_sme_scanned
This event indicates that the scan for Access Points is finished.
Table 3.226. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x04
method
4
int8
status
Message ID
Scan status
• 0: scan finished successfully
• non-zero: scan failed with an error
BGScript event
event sme_scanned(status)
C Functions
/* Event id */
wifi_evt_sme_scanned_id
/* Event structure */
struct wifi_msg_sme_scanned_evt_t
{
int8 status;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 158
WGM110 API Reference Manual
API Reference
3.9.2.16 evt_sme_signal_quality
This event indicates the signal quality (RSSI value) of the connection in dBm units.
Table 3.227. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x16
method
4
int8
rssi
5
uint8
hw_interface
Message ID
The received signal strength indication (RSSI) in dBm units
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_signal_quality(rssi,hw_interface)
C Functions
/* Event id */
wifi_evt_sme_signal_quality_id
/* Event structure */
struct wifi_msg_sme_signal_quality_evt_t
{
int8 rssi;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 159
WGM110 API Reference Manual
API Reference
3.9.2.17 evt_sme_wifi_is_off
This event indicates that the Wi-Fi radio has been powered off.
The event can also indicate that the Wi-Fi radio had an internal error and was shut down, in which case the user application must reinitialize the radio by turning it on.
Table 3.228. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript event
event sme_wifi_is_off(result)
C Functions
/* Event id */
wifi_evt_sme_wifi_is_off_id
/* Event structure */
struct wifi_msg_sme_wifi_is_off_evt_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 160
WGM110 API Reference Manual
API Reference
3.9.2.18 evt_sme_wifi_is_on
This event indicates that the Wi-Fi radio is powered up and ready to receive commands.
Table 3.229. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript event
event sme_wifi_is_on(result)
C Functions
/* Event id */
wifi_evt_sme_wifi_is_on_id
/* Event structure */
struct wifi_msg_sme_wifi_is_on_evt_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 161
WGM110 API Reference Manual
API Reference
3.9.2.19 evt_sme_wps_completed
This event indicates that the Wi-Fi Protected Setup (WPS) session was completed successfully.
Table 3.230. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x12
method
4
uint8
hw_interface
Message ID
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_wps_completed(hw_interface)
C Functions
/* Event id */
wifi_evt_sme_wps_completed_id
/* Event structure */
struct wifi_msg_sme_wps_completed_evt_t
{
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 162
WGM110 API Reference Manual
API Reference
3.9.2.20 evt_sme_wps_credential_password
This event indicates the password of the network in relation to Wi-Fi Protected Setup (WPS) session.
Table 3.231. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x15
method
4
uint8
hw_interface
5
uint8array
password
Message ID
Hardware interface
• 0: Wi-Fi
Password of the network
• WPA/WPA2-PSK is either a hash of 64 hexadecimal characters, or a pass-phrase of 8 to 63 ASCII-encoded characters
• 64-bit WEP key is either 5 ASCII-encoded characters or 10
HEX characters
• 128-bit WEP key is either 13 ASCII-encoded characters or 26
HEX characters
BGScript event
event sme_wps_credential_password(hw_interface,password_len, password_data)
C Functions
/* Event id */
wifi_evt_sme_wps_credential_password_id
/* Event structure */
struct wifi_msg_sme_wps_credential_password_evt_t
{
uint8 hw_interface;,
uint8array password;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 163
WGM110 API Reference Manual
API Reference
3.9.2.21 evt_sme_wps_credential_ssid
This event indicates the SSID of the network in relation to Wi-Fi Protected Setup (WPS) session.
Table 3.232. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x14
method
4
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
5
uint8array
ssid
SSID of the network
Message ID
Length: 1 - 32 bytes
BGScript event
event sme_wps_credential_ssid(hw_interface,ssid_len, ssid_data)
C Functions
/* Event id */
wifi_evt_sme_wps_credential_ssid_id
/* Event structure */
struct wifi_msg_sme_wps_credential_ssid_evt_t
{
uint8 hw_interface;,
uint8array ssid;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 164
WGM110 API Reference Manual
API Reference
3.9.2.22 evt_sme_wps_failed
This event indicates that the Wi-Fi Protected Setup (WPS) session failed.
Table 3.233. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x13
method
Message ID
4-5
uint16
reason
Reason of fail
For values refer to the error codes.
6
uint8
hw_interface
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_wps_failed(reason,hw_interface)
C Functions
/* Event id */
wifi_evt_sme_wps_failed_id
/* Event structure */
struct wifi_msg_sme_wps_failed_evt_t
{
uint16 reason;,
uint8 hw_interface;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 165
WGM110 API Reference Manual
API Reference
3.9.2.23 evt_sme_wps_stopped
This event indicates that the Wi-Fi Protected Setup (WPS) session was stopped.
Table 3.234. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x03
class
Message class: Wi-Fi
3
0x11
method
4
uint8
hw_interface
Message ID
Hardware interface
• 0: Wi-Fi
BGScript event
event sme_wps_stopped(hw_interface)
C Functions
/* Event id */
wifi_evt_sme_wps_stopped_id
/* Event structure */
struct wifi_msg_sme_wps_stopped_evt_t
{
uint8 hw_interface;
};
3.9.3 sme enumerations
3.9.3.1 enum_sme_eap_type
This enumeration defines the EAP types.
Table 3.235. Enumerations
Value
Name
Description
0
sme_eap_type_none
None
1
sme_eap_type_tls
TLS
2
sme_eap_type_peap
PEAP
3
sme_eap_type_mschapv2
MSCHAPv2
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 166
WGM110 API Reference Manual
API Reference
3.10 System Class Commands
The commands in this class are related to general control of the Module.
This class consists of the following items:
• Commands
• cmd_system_hello
• cmd_system_reset
• cmd_system_set_max_power_saving_state
• cmd_system_sync
• Events
• evt_system_boot indicates that the Module has started and is ready to receive commands.
• evt_system_power_saving_state indicates the power saving state the Module has entered into.
• evt_system_sw_exception indicates occurrence of SW exception with Module resetting automatically to normal mode.
• Enumerations
• enum_system_power_saving_state defines the four possible power saving states available for the Module.
The command cmd_system_sync can generate the following events from other classes
• evt_sme_wifi_on
• evt_sme_wifi_off
• evt_sme_scan_result
• evt_sme_connected
• evt_tcpip_endpoint_status
• evt_endpoint_status
• evt_config_mac_address
• evt_tcpip_configuration
• evt_tcpip_dns_configuration
A typical use for the cmd_system_sync command is to get the Module information and status for a GUI program startup.
The command cmd_system_hello can be used to check that the Module is up and running.
The command cmd_system_set_max_power_saving_state is used to set the deepest power saving state into which the Module is allowed to go into. Note that in power save states 0, 1 and 2 the host communication interface is available but in 3 and higher host communication interface is set down. In the case where the Module is in deep sleep (power saving state 3 or 4) an external interrupt is
required to wake up the Module.
Note: After an interrupt signal wakes the Module up, host communication must be initiated within 2 seconds, because otherwise the
Module will return to deep sleep mode.
EXAMPLES
1. Using power savings modes
a. Configure one GPIO pin of the Module as an external interrupt in the project configuration file.
b. Build and load the firmware image file into the Module.
c. With the Module in state where power saving is possible, like connected to a Wi-Fi Access Point, send the cmd_system_set_max_power_saving_state using parameter "4" which defines that the Module is allowed to go into deepest power
saving state. The Module will wake up autonomously to handle internal operations, like TCP keep alive.
d. Wake up the Module using the external interrupt pin configured in Step a.
e. Set the Module maximum power saving state to "0" using the cmd_system_set_max_power_saving_state command.
f. Wait for the evt_system_power_saving_state event.
g. Execute the required communication.
h. Wait until communication is finished.
i. Enable the power saving like in Step c.
Troubleshooting information
Problem
The evt_system_sw_execption event is received .
Possible reasons and solutions
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 167
WGM110 API Reference Manual
API Reference
• Error in BGScript or stack usage of BGScript is too large. Debug the BGScript or try with another script, for example some script
from SDK's example.
• Noise in power supply line. Improve power supply design.
• Firmware bug. Contact Silicon Labs Customer Support.
3.10.1 system commands
3.10.1.1 cmd_system_hello
This command is used to verify that communication works between the external host and the device.
The device sends a response without doing anything else.
Table 3.236. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x02
method
Message ID
Table 3.237. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x00
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x02
method
Message ID
BGScript command
call system_hello()()
BGLIB C API
/* Function */
void wifi_cmd_system_hello();
/* Response id */
wifi_rsp_system_hello_id
/* Response structure */
struct wifi_msg_system_hello_rsp_t
{
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 168
WGM110 API Reference Manual
API Reference
3.10.1.2 cmd_system_reset
This command is used to reset the device.
The command does not have a response, but it triggers a boot event.
Table 3.238. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x01
method
4
uint8
dfu
Message ID
Boot mode
• 0: Boot to normal mode
• 1: Boot to DFU mode
See the DFU class for further details.
BGScript command
call system_reset(dfu)
BGLIB C API
/* Function */
void wifi_cmd_system_reset(uint8 dfu);
/* Command does not have a response */
Table 3.239. Events Generated
Event
Description
system_boot
Sent after the device has booted to normal mode
dfu_boot
Sent after the device has booted to DFU mode
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 169
WGM110 API Reference Manual
API Reference
3.10.1.3 cmd_system_set_max_power_saving_state
This command is used to set the maximum power saving state allowed for the device.
Initial state is power_saving_state_0
Table 3.240. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x03
method
4
uint8
state
Message ID
Power saving state
Range: 0 - 4
Table 3.241. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call system_set_max_power_saving_state(state)(result)
BGLIB C API
/* Function */
void wifi_cmd_system_set_max_power_saving_state(uint8 state);
/* Response id */
wifi_rsp_system_set_max_power_saving_state_id
/* Response structure */
struct wifi_msg_system_set_max_power_saving_state_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 170
WGM110 API Reference Manual
API Reference
3.10.1.4 cmd_system_sync
This command is used to retrieve the device status.
When the sync command is sent, multiple events are output representing the device status.
Table 3.242. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x00
method
Message ID
Table 3.243. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x00
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x00
method
Message ID
BGScript command
call system_sync()()
BGLIB C API
/* Function */
void wifi_cmd_system_sync();
/* Response id */
wifi_rsp_system_sync_id
/* Response structure */
struct wifi_msg_system_sync_rsp_t
{
};
Table 3.244. Events Generated
Event
Description
sme_wifi_is_on
Sent if Wi-Fi has been switched on
sme_wifi_is_off
Sent if Wi-Fi has been switched off
sme_scan_result
Sent for each cached scan result
sme_connected
Device connection status
tcpip_endpoint_status
Sent for each TCP/IP endpoint
endpoint_status
Sent for each endpoint
config_mac_address
Device MAC address
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 171
WGM110 API Reference Manual
API Reference
Event
Description
tcpip_configuration
Device TCP/IP configuration
tcpip_dns_configuration
Device DNS configuration
3.10.2 system events
3.10.2.1 evt_system_boot
This event indicates that the device has started and is ready to receive commands.
Table 3.245. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x0b
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x00
method
4-5
uint16
hw
Hardware version
6-7
uint16
bootloader_version
Bootloader version
8-9
uint16
major
Software major version
10-11
uint16
minor
Software minor version
12-13
uint16
build
Software build number
14
uint8array
revision
Software revision string
Message ID
BGScript event
event system_boot(hw,bootloader_version,major,minor,build,revision_len, revision_data)
C Functions
/* Event id */
wifi_evt_system_boot_id
/* Event structure */
struct wifi_msg_system_boot_evt_t
{
uint16 hw;,
uint16 bootloader_version;,
uint16 major;,
uint16 minor;,
uint16 build;,
uint8array revision;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 172
WGM110 API Reference Manual
API Reference
3.10.2.2 evt_system_power_saving_state
This event indicates the power saving state into which the device has entered.
Table 3.246. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x03
method
4
uint8
state
Message ID
Power saving state
BGScript event
event system_power_saving_state(state)
C Functions
/* Event id */
wifi_evt_system_power_saving_state_id
/* Event structure */
struct wifi_msg_system_power_saving_state_evt_t
{
uint8 state;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 173
WGM110 API Reference Manual
API Reference
3.10.2.3 evt_system_sw_exception
This event indicates that a software exception has occurred.
The device resets automatically to normal mode when an exception occurs.
Table 3.247. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x05
lolen
Minimum payload length
2
0x01
class
Message class: System
3
0x02
method
Message ID
4-7
uint32
address
Address where exception occurred
8
uint8
type
Type of exception
BGScript event
event system_sw_exception(address,type)
C Functions
/* Event id */
wifi_evt_system_sw_exception_id
/* Event structure */
struct wifi_msg_system_sw_exception_evt_t
{
uint32 address;,
uint8 type;
};
3.10.3 system enumerations
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 174
WGM110 API Reference Manual
API Reference
3.10.3.1 enum_system_power_saving_state
This enumeration defines the power saving state of the device.
Table 3.248. Enumerations
Value
Name
Description
0
system_power_saving_state_0
No powersave. MCU in emode EM0, Wi-Fi chip no power save. Only this state can be used in access point
mode
1
system_power_saving_state_1
MCU in emode EM1, Wi-Fi chip in middle power save
mode.
2
system_power_saving_state_2
MCU in emode EM1, Wi-Fi chip in lowest power consumption mode.
3
system_power_saving_state_3
MCU in emode EM2, Wi-Fi chip on lowest power consumption mode. MCU wake in every 2 second for 50
milliseconds. Keeps IP stack timers and soft timers in
time with lower resolution. Wakeup with interrupt pin for
2 seconds
4
system_power_saving_state_4
MCU in emode EM2, Wi-Fi chip on lowest power save
mode. IP stack timers and software timers time is lost.
Wakeup with interrupt pin for 2 seconds
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 175
WGM110 API Reference Manual
API Reference
3.11 TCP Stack Command Class
The commands in this class are used to control the TCP/IP stack of the Module.
This class consists of the following items:
IP stack related
• Commands
• cmd_tcpip_configure
• cmd_tcpip_multicast_join
• cmd_tcpip_multicast_leave
• Events
• evt_tcpip_configuration
TCP and UDP related
• Commands
• cmd_tcpip_start_tcp_server
• cmd_tcpip_tcp_connect
• cmd_tcpip_start_udp_server
• cmd_tcpip_udp_connect
• cmd_tcpip_udp_bind
• Events
• evt_tcpip_endpoint_status
• evt_udp_data
DNS, MSDN and DNS-SD related
• Commands
• cmd_tcpip_dns_configure
• cmd_tcpip_dns_gethostbyname
• cmd_tcpip_mdns_set_hostname
• cmd_tcpip_mdns_stop
• cmd_tcpip_dnssd_add_service
• cmd_tcpip_dnssd_add_service_instance
• cmd_tcpip_dnssd_add_service_attribute
• cmd_tcpip_dnssd_remove_service
• cmd_tcpip_dnssd_start_service
• cmd_tcpip_dnssd_stop_service
• Events
• evt_tcpip_dns_configuration
• evt_tcpip_dns_gethostbyname_result
• evt_tcpip_mdns_started
• evt_tcpip_mdns_stopped
• evt_tcpip_mdns_failed
• evt_tcpip_dnssd_service_started
• evt_tcpip_dnssd_service_failed
• evt_tcpip_dnssd_service_stopped
DHCP related
• Commands
• cmd_tcpip_dhcp_set_hostname
• cmd_tcpip_dhcp_enable_routing
• Events
TLS/SSL related
• Commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 176
WGM110 API Reference Manual
API Reference
• cmd_tcpip_tls_connect
• cmd_tcpip_tls_set_authmode
• cmd_tcpip_tls_set_user_certificate
• Events
• evt_tcpip_tls_verify_result
3.11.1 tcpip commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 177
WGM110 API Reference Manual
API Reference
3.11.1.1 cmd_tcpip_configure
This command is used to configure IP settings of the device.
When enabling DHCP, the IP settings will be stored, but they will be overridden as soon as IP configuration is received from the remote
DHCP server.
Table 3.249. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x0d
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x04
method
Message ID
4-7
ipv4
address
Local IP address of the device
8-11
ipv4
netmask
Netmask of the device
12-15
ipv4
gateway
Gateway used by the device
16
uint8
use_dhcp
Defines whether DHCP is used to retrieve IP settings
• 0: DHCP disabled
• 1: DHCP enabled
This setting is only applicable in client mode.
Table 3.250. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x04
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_configure(address,netmask,gateway,use_dhcp)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_configure(ipv4 address, ipv4 netmask, ipv4 gateway, uint8 use_dhcp);
/* Response id */
wifi_rsp_tcpip_configure_id
/* Response structure */
struct wifi_msg_tcpip_configure_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 178
WGM110 API Reference Manual
API Reference
Table 3.251. Events Generated
Event
Description
tcpip_configuration
Sent when TCP/IP configuration changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 179
WGM110 API Reference Manual
API Reference
3.11.1.2 cmd_tcpip_dhcp_enable_routing
This command is used to set whether the built-in DHCP server responses include gateway and DNS server information.
Gateway and DNS information is included by default.
Table 3.252. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0b
method
Message ID
4
uint8
enable
Routing options
• 0: disabled
• 1: enabled
Table 3.253. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0b
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dhcp_enable_routing(enable)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dhcp_enable_routing(uint8 enable);
/* Response id */
wifi_rsp_tcpip_dhcp_enable_routing_id
/* Response structure */
struct wifi_msg_tcpip_dhcp_enable_routing_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 180
WGM110 API Reference Manual
API Reference
3.11.1.3 cmd_tcpip_dhcp_set_hostname
This command is used to set the DHCP host name parameter (option 12) used in client DHCPDISCOVER and DHCPREQUEST messages.
Table 3.254. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x08
method
4
uint8array
hostname
Message ID
Host name to use
Table 3.255. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x08
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dhcp_set_hostname(hostname_len, hostname_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dhcp_set_hostname(uint8array hostname);
/* Response id */
wifi_rsp_tcpip_dhcp_set_hostname_id
/* Response structure */
struct wifi_msg_tcpip_dhcp_set_hostname_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 181
WGM110 API Reference Manual
API Reference
3.11.1.4 cmd_tcpip_dns_configure
This command is used to configure DNS settings of the device.
The primary DNS server is set to 208.67.222.222 (resolver1.opendns.com) by default, the secondary DNS server is zero.
Table 3.256. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x05
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x05
method
4
uint8
index
Index of the DNS server
• 0: primary DNS server
• 1: secondary DNS server
5-8
ipv4
address
IP address of the DNS server
Message ID
Table 3.257. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x05
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dns_configure(index,address)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dns_configure(uint8 index, ipv4 address);
/* Response id */
wifi_rsp_tcpip_dns_configure_id
/* Response structure */
struct wifi_msg_tcpip_dns_configure_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 182
WGM110 API Reference Manual
API Reference
Table 3.258. Events Generated
Event
Description
tcpip_dns_configuration
Sent when DNS configuration changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 183
WGM110 API Reference Manual
API Reference
3.11.1.5 cmd_tcpip_dns_gethostbyname
This command is used to resolve the IP address of a domain name using the configured DNS servers.
Table 3.259. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x06
method
4
uint8array
name
Message ID
The fully qualified domain name to resolve
Table 3.260. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x06
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dns_gethostbyname(name_len, name_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dns_gethostbyname(uint8array name);
/* Response id */
wifi_rsp_tcpip_dns_gethostbyname_id
/* Response structure */
struct wifi_msg_tcpip_dns_gethostbyname_rsp_t
{
uint16 result;
};
Table 3.261. Events Generated
Event
Description
tcpip_dns_gethostbyname_result
Sent when DNS resolver query completes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 184
WGM110 API Reference Manual
API Reference
3.11.1.6 cmd_tcpip_dnssd_add_service
This command is used to add a new DNS-SD service.
The maximum amount of DNS-SD services is 3.
Table 3.262. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x04
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0f
method
Message ID
4-5
uint16
port
Service port
Range: 1 - 65535
6
uint8
protocol
Service protocol
• 0: TCP
• 1: UDP
7
uint8array
service
Service name
Length: 1 - 15 bytes
Table 3.263. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0f
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
index
Index of the DNS-SD service
BGScript command
call tcpip_dnssd_add_service(port,protocol,service_len, service_data)(result,index)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dnssd_add_service(uint16 port, uint8 protocol, uint8array service);
/* Response id */
wifi_rsp_tcpip_dnssd_add_service_id
/* Response structure */
struct wifi_msg_tcpip_dnssd_add_service_rsp_t
{
uint16 result;,
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 185
WGM110 API Reference Manual
API Reference
uint8 index;
};
3.11.1.7 cmd_tcpip_dnssd_add_service_attribute
This command is used to add a service attribute to a DNS-SD service.
One DNS-SD service can contain multiple service attributes. The maximum combined length of service attributes is 64 bytes.
Table 3.264. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x11
method
4
uint8
index
5
uint8array
attribute
Message ID
Index of the DNS-SD service
Service attribute
Length: 1 - 64 bytes
Table 3.265. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x11
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dnssd_add_service_attribute(index,attribute_len, attribute_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dnssd_add_service_attribute(uint8 index, uint8array attribute);
/* Response id */
wifi_rsp_tcpip_dnssd_add_service_attribute_id
/* Response structure */
struct wifi_msg_tcpip_dnssd_add_service_attribute_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 186
WGM110 API Reference Manual
API Reference
3.11.1.8 cmd_tcpip_dnssd_add_service_instance
This command is used to set the instance name of a DNS-SD service.
Table 3.266. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x10
method
4
uint8
index
5
uint8array
instance
Message ID
Index of the DNS-SD service
Service instance name
Length: 1 - 63 bytes
Table 3.267. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x10
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dnssd_add_service_instance(index,instance_len, instance_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dnssd_add_service_instance(uint8 index, uint8array instance);
/* Response id */
wifi_rsp_tcpip_dnssd_add_service_instance_id
/* Response structure */
struct wifi_msg_tcpip_dnssd_add_service_instance_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 187
WGM110 API Reference Manual
API Reference
3.11.1.9 cmd_tcpip_dnssd_remove_service
This command is used to remove a DNS-SD service.
Table 3.268. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x12
method
4
uint8
index
Message ID
Index of the DNS-SD service
Table 3.269. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x12
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dnssd_remove_service(index)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dnssd_remove_service(uint8 index);
/* Response id */
wifi_rsp_tcpip_dnssd_remove_service_id
/* Response structure */
struct wifi_msg_tcpip_dnssd_remove_service_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 188
WGM110 API Reference Manual
API Reference
3.11.1.10 cmd_tcpip_dnssd_start_service
This command is used to start a DNS-SD service.
The DNS-SD service cannot be started until the instance name has been set using the tcpip_dnssd_add_service_instance command.
Table 3.270. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x13
method
4
uint8
index
Message ID
Index of the DNS-SD service
Table 3.271. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x13
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dnssd_start_service(index)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dnssd_start_service(uint8 index);
/* Response id */
wifi_rsp_tcpip_dnssd_start_service_id
/* Response structure */
struct wifi_msg_tcpip_dnssd_start_service_rsp_t
{
uint16 result;
};
Table 3.272. Events Generated
Event
Description
tcpip_dnssd_service_started
Sent when the DNS-SD service has been successfully started
tcpip_dnssd_service_failed
Sent when the DNS-SD service startup fails
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 189
WGM110 API Reference Manual
API Reference
3.11.1.11 cmd_tcpip_dnssd_stop_service
This command is used to stop a DNS-SD service.
Table 3.273. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x14
method
4
uint8
index
Message ID
Index of the DNS-SD service
Table 3.274. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x14
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_dnssd_stop_service(index)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_dnssd_stop_service(uint8 index);
/* Response id */
wifi_rsp_tcpip_dnssd_stop_service_id
/* Response structure */
struct wifi_msg_tcpip_dnssd_stop_service_rsp_t
{
uint16 result;
};
Table 3.275. Events Generated
Event
Description
tcpip_dnssd_service_stopped
Sent when the DNS-SD service has been stopped
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 190
WGM110 API Reference Manual
API Reference
3.11.1.12 cmd_tcpip_mdns_set_hostname
This command is used to set the mDNS host name.
Table 3.276. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0c
method
4
uint8array
hostname
Message ID
The mDNS host name
Length: 1 - 63 bytes
The top-level domain .local is added automatically.
Table 3.277. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0c
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_mdns_set_hostname(hostname_len, hostname_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_mdns_set_hostname(uint8array hostname);
/* Response id */
wifi_rsp_tcpip_mdns_set_hostname_id
/* Response structure */
struct wifi_msg_tcpip_mdns_set_hostname_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 191
WGM110 API Reference Manual
API Reference
3.11.1.13 cmd_tcpip_mdns_start
This command is used to start the mDNS service.
The mDNS service cannot be started until the host name has been set using the tcpip_mdns_set_hostname command.
Table 3.278. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0d
method
Message ID
Table 3.279. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0d
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_mdns_start()(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_mdns_start();
/* Response id */
wifi_rsp_tcpip_mdns_start_id
/* Response structure */
struct wifi_msg_tcpip_mdns_start_rsp_t
{
uint16 result;
};
Table 3.280. Events Generated
Event
Description
tcpip_mdns_started
Sent when the mDNS service has been successfully started
tcpip_mdns_failed
Sent when the mDNS service startup fails
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 192
WGM110 API Reference Manual
API Reference
3.11.1.14 cmd_tcpip_mdns_stop
This command is used to stop the mDNS service.
Table 3.281. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0e
method
Message ID
Table 3.282. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0e
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_mdns_stop()(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_mdns_stop();
/* Response id */
wifi_rsp_tcpip_mdns_stop_id
/* Response structure */
struct wifi_msg_tcpip_mdns_stop_rsp_t
{
uint16 result;
};
Table 3.283. Events Generated
Event
Description
tcpip_mdns_stopped
Sent when the mDNS service has been stopped
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 193
WGM110 API Reference Manual
API Reference
3.11.1.15 cmd_tcpip_multicast_join
This command is used to join a multicast group.
Maximum number of multicast groups that can be joined is 4. Use 224.0.0.2 - 224.0.0.254 as address range. Note that 224.0.0.1 is
automatically joined.
Table 3.284. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x04
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x15
method
Message ID
4-7
ipv4
address
IP address of the multicast group
Table 3.285. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x15
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_multicast_join(address)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_multicast_join(ipv4 address);
/* Response id */
wifi_rsp_tcpip_multicast_join_id
/* Response structure */
struct wifi_msg_tcpip_multicast_join_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 194
WGM110 API Reference Manual
API Reference
3.11.1.16 cmd_tcpip_multicast_leave
This command is used to leave a multicast group.
Table 3.286. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x04
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x16
method
Message ID
4-7
ipv4
address
IP address of the multicast group
Table 3.287. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x16
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_multicast_leave(address)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_multicast_leave(ipv4 address);
/* Response id */
wifi_rsp_tcpip_multicast_leave_id
/* Response structure */
struct wifi_msg_tcpip_multicast_leave_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 195
WGM110 API Reference Manual
API Reference
3.11.1.17 cmd_tcpip_start_tcp_server
This command is used to start a TCP server.
Table 3.288. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x00
method
4-5
uint16
port
6
int8
default_destination
Message ID
Local TCP port that the server listens to
The endpoint where the received data will be routed to
• -1: route to all BGAPI/BGScript endpoints
• 0 - 30: route to a specific endpoint
• 31: discard the received data
Table 3.289. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the TCP server endpoint
BGScript command
call tcpip_start_tcp_server(port,default_destination)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_start_tcp_server(uint16 port, int8 default_destination);
/* Response id */
wifi_rsp_tcpip_start_tcp_server_id
/* Response structure */
struct wifi_msg_tcpip_start_tcp_server_rsp_t
{
uint16 result;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 196
WGM110 API Reference Manual
API Reference
Table 3.290. Events Generated
Event
Description
tcpip_endpoint_status
Sent when TCP/IP endpoint status changes
endpoint_status
Sent when the endpoint status changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 197
WGM110 API Reference Manual
API Reference
3.11.1.18 cmd_tcpip_start_udp_server
This command is used to start an UDP server.
Table 3.291. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x02
method
4-5
uint16
port
6
int8
default_destination
Message ID
Local UDP port that the server listens to
Index of the endpoint where the received data will be routed to
• -1: route to all BGAPI/BGScript endpoints
• 0 - 30: route to a specific endpoint
• 31: discard the received data
Table 3.292. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the UDP server endpoint
BGScript command
call tcpip_start_udp_server(port,default_destination)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_start_udp_server(uint16 port, int8 default_destination);
/* Response id */
wifi_rsp_tcpip_start_udp_server_id
/* Response structure */
struct wifi_msg_tcpip_start_udp_server_rsp_t
{
uint16 result;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 198
WGM110 API Reference Manual
API Reference
Table 3.293. Events Generated
Event
Description
tcpip_endpoint_status
Sent when TCP/IP endpoint status changes
endpoint_status
Sent when the endpoint status changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 199
WGM110 API Reference Manual
API Reference
3.11.1.19 cmd_tcpip_tcp_connect
This command is used to create a new TCP connection to a TCP server.
Table 3.294. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x07
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x01
method
Message ID
4-7
ipv4
address
IP address of the remote server
8-9
uint16
port
10
int8
routing
TCP port of the remote server
Index of the endpoint where the received data will be routed to
• -1: route to all BGAPI/BGScript endpoints
• 0 - 30: route to a specific endpoint
• 31: discard the received data
Table 3.295. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the TCP connection endpoint
BGScript command
call tcpip_tcp_connect(address,port,routing)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_tcp_connect(ipv4 address, uint16 port, int8 routing);
/* Response id */
wifi_rsp_tcpip_tcp_connect_id
/* Response structure */
struct wifi_msg_tcpip_tcp_connect_rsp_t
{
uint16 result;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 200
WGM110 API Reference Manual
API Reference
Table 3.296. Events Generated
Event
Description
tcpip_endpoint_status
Sent when TCP/IP endpoint status changes
endpoint_status
Sent when the endpoint status changes
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 201
WGM110 API Reference Manual
API Reference
3.11.1.20 cmd_tcpip_tls_connect
This command is used to create a new TLS connection to a TLS server.
Table 3.297. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x07
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x09
method
Message ID
4-7
ipv4
address
IP address of the remote server
8-9
uint16
port
10
int8
routing
TLS port of the remote server
Index of the endpoint where the received data will be routed to
• -1: route to all BGAPI/BGScript endpoints
• 0 - 30: route to a specific endpoint
• 31: discard the received data
Table 3.298. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x09
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the TLS connection endpoint
BGScript command
call tcpip_tls_connect(address,port,routing)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_tls_connect(ipv4 address, uint16 port, int8 routing);
/* Response id */
wifi_rsp_tcpip_tls_connect_id
/* Response structure */
struct wifi_msg_tcpip_tls_connect_rsp_t
{
uint16 result;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 202
WGM110 API Reference Manual
API Reference
Table 3.299. Events Generated
Event
Description
tcpip_endpoint_status
Sent when TCP/IP endpoint status changes
endpoint_status
Sent when the endpoint status changes
tcpip_tls_verify_result
Sent during TLS handshake if the verification mode enabled
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 203
WGM110 API Reference Manual
API Reference
3.11.1.21 cmd_tcpip_tls_set_authmode
This command is used to set the TLS certificate verification mode.
The mode must be set before calling the tcpip_tls_connect command. If the verification mode has been set to optional or mandatory,
the server certificate is verified against a root certificate from the built-in certificate store during TLS connection setup. The verification
result is indicated with the evt_tcpip_tls_verify_result event.
The verification mode is set to mandatory by default.
Table 3.300. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0a
method
4
uint8
auth_mode
Message ID
Verification mode
• 0: no verification
• 1: optional verification, verification failure is ignored
• 2: mandatory verification, verification failure causes connection
to fail
Table 3.301. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x00
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0a
method
Message ID
BGScript command
call tcpip_tls_set_authmode(auth_mode)()
BGLIB C API
/* Function */
void wifi_cmd_tcpip_tls_set_authmode(uint8 auth_mode);
/* Response id */
wifi_rsp_tcpip_tls_set_authmode_id
/* Response structure */
struct wifi_msg_tcpip_tls_set_authmode_rsp_t
{
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 204
WGM110 API Reference Manual
API Reference
3.11.1.22 cmd_tcpip_tls_set_user_certificate
This command is used to set the client certificate for a TLS connection.
If set, the certificate will be sent to the TLS server if requested by the server during authentication.
Table 3.302. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x17
method
4
uint8array
fingerprint
Message ID
Fingerprint of the client certificate
Length: 16 bytes
Table 3.303. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x17
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_tls_set_user_certificate(fingerprint_len, fingerprint_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_tls_set_user_certificate(uint8array fingerprint);
/* Response id */
wifi_rsp_tcpip_tls_set_user_certificate_id
/* Response structure */
struct wifi_msg_tcpip_tls_set_user_certificate_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 205
WGM110 API Reference Manual
API Reference
3.11.1.23 cmd_tcpip_udp_bind
This command is used to change the source port of an existing UDP endpoint.
Table 3.304. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x07
method
Message ID
4
uint8
endpoint
Index of the UDP endpoint to change
5-6
uint16
port
New UDP source port
Table 3.305. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x07
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call tcpip_udp_bind(endpoint,port)(result)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_udp_bind(uint8 endpoint, uint16 port);
/* Response id */
wifi_rsp_tcpip_udp_bind_id
/* Response structure */
struct wifi_msg_tcpip_udp_bind_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 206
WGM110 API Reference Manual
API Reference
3.11.1.24 cmd_tcpip_udp_connect
This command is used to create a new UDP connection.
Table 3.306. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x07
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x03
method
Message ID
4-7
ipv4
address
IP address of the remote server to which the packets will be sent
8-9
uint16
port
10
int8
routing
UDP port of the remote server
Index of the endpoint where the received data will be routed to.
Due to the unidirectional nature of UDP endpoints, this parameter
has no effect on this command. Set to zero.
Table 3.307. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8
endpoint
Index of the UDP connection endpoint
BGScript command
call tcpip_udp_connect(address,port,routing)(result,endpoint)
BGLIB C API
/* Function */
void wifi_cmd_tcpip_udp_connect(ipv4 address, uint16 port, int8 routing);
/* Response id */
wifi_rsp_tcpip_udp_connect_id
/* Response structure */
struct wifi_msg_tcpip_udp_connect_rsp_t
{
uint16 result;,
uint8 endpoint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 207
WGM110 API Reference Manual
API Reference
Table 3.308. Events Generated
Event
Description
tcpip_endpoint_status
Sent when TCP/IP endpoint status changes
endpoint_status
Sent when the endpoint status changes
3.11.2 tcpip events
3.11.2.1 evt_tcpip_configuration
This event indicates TCP/IP configuration status.
Table 3.309. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x0d
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x00
method
Message ID
4-7
ipv4
address
Local IP address of the device
8-11
ipv4
netmask
Netmask of the device
12-15
ipv4
gateway
Gateway of the device
16
uint8
use_dhcp
Defines whether DHCP is used to retrieve IP settings
• 0: DHCP disabled
• 1: DHCP enabled
BGScript event
event tcpip_configuration(address,netmask,gateway,use_dhcp)
C Functions
/* Event id */
wifi_evt_tcpip_configuration_id
/* Event structure */
struct wifi_msg_tcpip_configuration_evt_t
{
ipv4 address;,
ipv4 netmask;,
ipv4 gateway;,
uint8 use_dhcp;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 208
WGM110 API Reference Manual
API Reference
3.11.2.2 evt_tcpip_dns_configuration
This event indicates DNS configuration status.
Table 3.310. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x05
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x01
method
4
uint8
index
Index of the DNS server
• 0: primary DNS server
• 1: secondary DNS server
5-8
ipv4
address
IP address of the DNS server
Message ID
BGScript event
event tcpip_dns_configuration(index,address)
C Functions
/* Event id */
wifi_evt_tcpip_dns_configuration_id
/* Event structure */
struct wifi_msg_tcpip_dns_configuration_evt_t
{
uint8 index;,
ipv4 address;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 209
WGM110 API Reference Manual
API Reference
3.11.2.3 evt_tcpip_dns_gethostbyname_result
This event indicates that DNS resolver query has been completed.
If successful, the address field contains the corresponding IP address.
Table 3.311. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x07
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6-9
ipv4
address
10
uint8array
name
The resolved IP address of the domain name
The domain name that was resolved
BGScript event
event tcpip_dns_gethostbyname_result(result,address,name_len, name_data)
C Functions
/* Event id */
wifi_evt_tcpip_dns_gethostbyname_result_id
/* Event structure */
struct wifi_msg_tcpip_dns_gethostbyname_result_evt_t
{
uint16 result;,
ipv4 address;,
uint8array name;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 210
WGM110 API Reference Manual
API Reference
3.11.2.4 evt_tcpip_dnssd_service_failed
This event indicates that a DNS-SD service has failed.
Table 3.312. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0a
method
Message ID
4-5
uint16
reason
Reason of fail
For values refer to the error codes.
6
uint8
index
Index of the DNS-SD service
BGScript event
event tcpip_dnssd_service_failed(reason,index)
C Functions
/* Event id */
wifi_evt_tcpip_dnssd_service_failed_id
/* Event structure */
struct wifi_msg_tcpip_dnssd_service_failed_evt_t
{
uint16 reason;,
uint8 index;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 211
WGM110 API Reference Manual
API Reference
3.11.2.5 evt_tcpip_dnssd_service_started
This event indicates that a DNS-SD service has been successfully started.
Table 3.313. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x01
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x09
method
4
uint8
index
Message ID
Index of the DNS-SD service
BGScript event
event tcpip_dnssd_service_started(index)
C Functions
/* Event id */
wifi_evt_tcpip_dnssd_service_started_id
/* Event structure */
struct wifi_msg_tcpip_dnssd_service_started_evt_t
{
uint8 index;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 212
WGM110 API Reference Manual
API Reference
3.11.2.6 evt_tcpip_dnssd_service_stopped
This event indicates that a DNS-SD service has been stopped.
Table 3.314. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x0b
method
Message ID
4-5
uint16
reason
Reason of service stop
For values refer to the error codes.
6
uint8
index
Index of the DNS-SD service
BGScript event
event tcpip_dnssd_service_stopped(reason,index)
C Functions
/* Event id */
wifi_evt_tcpip_dnssd_service_stopped_id
/* Event structure */
struct wifi_msg_tcpip_dnssd_service_stopped_evt_t
{
uint16 reason;,
uint8 index;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 213
WGM110 API Reference Manual
API Reference
3.11.2.7 evt_tcpip_endpoint_status
This event indicates the current status of a TCP/IP endpoint.
Table 3.315. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x0d
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x02
method
Message ID
4
uint8
endpoint
Index of the endpoint
Range: 0 - 30
5-8
ipv4
local_ip
Local IP address of the endpoint
9-10
uint16
local_port
Local port of the endpoint
11-14
ipv4
remote_ip
Remote IP address of the endpoint
15-16
uint16
remote_port
Remote port of the endpoint
BGScript event
event tcpip_endpoint_status(endpoint,local_ip,local_port,remote_ip,remote_port)
C Functions
/* Event id */
wifi_evt_tcpip_endpoint_status_id
/* Event structure */
struct wifi_msg_tcpip_endpoint_status_evt_t
{
uint8 endpoint;,
ipv4 local_ip;,
uint16 local_port;,
ipv4 remote_ip;,
uint16 remote_port;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 214
WGM110 API Reference Manual
API Reference
3.11.2.8 evt_tcpip_mdns_failed
This event indicates that the mDNS service has failed.
Table 3.316. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x07
method
Message ID
4-5
uint16
reason
Reason of fail
For values refer to the error codes.
BGScript event
event tcpip_mdns_failed(reason)
C Functions
/* Event id */
wifi_evt_tcpip_mdns_failed_id
/* Event structure */
struct wifi_msg_tcpip_mdns_failed_evt_t
{
uint16 reason;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 215
WGM110 API Reference Manual
API Reference
3.11.2.9 evt_tcpip_mdns_started
This event indicates that the mDNS service has been successfully started.
Table 3.317. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x00
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x06
method
Message ID
BGScript event
event tcpip_mdns_started()
C Functions
/* Event id */
wifi_evt_tcpip_mdns_started_id
/* Event structure */
struct wifi_msg_tcpip_mdns_started_evt_t
{
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 216
WGM110 API Reference Manual
API Reference
3.11.2.10 evt_tcpip_mdns_stopped
This event indicates that the mDNS service has been stopped.
Table 3.318. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x08
method
Message ID
4-5
uint16
reason
Reason of service stop
For values refer to the error codes.
BGScript event
event tcpip_mdns_stopped(reason)
C Functions
/* Event id */
wifi_evt_tcpip_mdns_stopped_id
/* Event structure */
struct wifi_msg_tcpip_mdns_stopped_evt_t
{
uint16 reason;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 217
WGM110 API Reference Manual
API Reference
3.11.2.11 evt_tcpip_tls_verify_result
This event indicates the result of a TLS certificate verification.
Table 3.319. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x03
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x05
method
4
uint8
depth
Message ID
Position of the certificate in the certificate chain.
Server certificate is always at position 0. Certificate that signed
the server certificate is at position 1. Certificate that signed the
certificate at position 1 is at position 2 and so on.
5-6
uint16
flags
Verification result
• 0: verification success
• non-zero: verification failure
BGScript event
event tcpip_tls_verify_result(depth,flags)
C Functions
/* Event id */
wifi_evt_tcpip_tls_verify_result_id
/* Event structure */
struct wifi_msg_tcpip_tls_verify_result_evt_t
{
uint8 depth;,
uint16 flags;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 218
WGM110 API Reference Manual
API Reference
3.11.2.12 evt_tcpip_udp_data
This event contains received data from an UDP endpoint.
Table 3.320. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x09
lolen
Minimum payload length
2
0x04
class
Message class: TCP stack
3
0x04
method
Message ID
4
uint8
endpoint
Index of the endpoint which received the data
Range: 0 - 30
5-8
ipv4
source_address
9-10
uint16
source_port
11-12
uint16array
data
IP address that sent the data
UDP port where the data was sent from
The received data
BGScript event
event tcpip_udp_data(endpoint,source_address,source_port,data_len, data_data)
C Functions
/* Event id */
wifi_evt_tcpip_udp_data_id
/* Event structure */
struct wifi_msg_tcpip_udp_data_evt_t
{
uint8 endpoint;,
ipv4 source_address;,
uint16 source_port;,
uint16array data;
};
3.12 Utilities for BGScript Command Class
The commands in this class are helper functions called from BGScript.
This class consists of the following items:
• Commands
• cmd_util_atoi converts an ASCII string into an integer value.
• cmd_util itoa converts an integer value into an ASCII string value.
3.12.1 util commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 219
WGM110 API Reference Manual
API Reference
3.12.1.1 cmd_util_atoi
This command is used to convert a decimal value from an ASCII string format into a signed 32-bit integer format.
Table 3.321. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0d
class
Message class: Utilities for BGScript
3
0x00
method
4
uint8array
string
Message ID
String to convert
Table 3.322. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x04
lolen
Minimum payload length
2
0x0d
class
Message class: Utilities for BGScript
3
0x00
method
4-7
int32
value
Message ID
32-bit integer value
BGScript command
call util_atoi(string_len, string_data)(value)
BGLIB C API
/* Function */
void wifi_cmd_util_atoi(uint8array string);
/* Response id */
wifi_rsp_util_atoi_id
/* Response structure */
struct wifi_msg_util_atoi_rsp_t
{
int32 value;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 220
WGM110 API Reference Manual
API Reference
3.12.1.2 cmd_util_itoa
This command is used to convert an integer from a signed 32-bit integer format into decimal ASCII value format.
Table 3.323. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x04
lolen
Minimum payload length
2
0x0d
class
Message class: Utilities for BGScript
3
0x01
method
4-7
int32
value
Message ID
32-bit integer value to convert
Table 3.324. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x01
lolen
Minimum payload length
2
0x0d
class
Message class: Utilities for BGScript
3
0x01
method
4
uint8array
string
Message ID
Converted ASCII string
BGScript command
call util_itoa(value)(string_len, string_data)
BGLIB C API
/* Function */
void wifi_cmd_util_itoa(int32 value);
/* Response id */
wifi_rsp_util_itoa_id
/* Response structure */
struct wifi_msg_util_itoa_rsp_t
{
uint8array string;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 221
WGM110 API Reference Manual
API Reference
3.13 X.509 Command Class
The commands in this class are used to manage X.509 (ITU-T Standard for a Public Key Infrastucture and Privilege Management Infrastucture) cryptography certificates and to the related keys.
This class consists of the following items:
Certificate store related
• Commands
• cmd_x509_reset_store
• cmd_x509_list_certificates
• Events
• evt_x509_certificates_listed
• evt_x509_certificate
• evt_x509_certificate_subject
Certificate processing related
• Commands
• cmd_x509_add_certificate
• cmd_x509_add_certificate_data
• cmd_x509_certificate_finish
• cmd_x509_delete_certificate
• Events
• evt_x509_certificates_listed
Private key operation related
• Commands
• cmd_x509_add_private_key
• cmd_x509_add_private_key_data
• cmd_x509_add_private_key_finish
• Events
Examples
1. Adding a certificate into certificate store
a. Reserve space for the certificate in the certificate store using the cmd_x509_add_certificate command.
b. Load the certificate by repeating the cmd_x509_add_certificate_data command until the whole certificate is loaded.
Note: The size of the loaded data must not exceed the size of the data space reserved for the certificate with
cmd_x509_add_certificate command
c. Finish the loading process by using the cmd_x509_add_certificate_finish command.
3.13.1 x509 commands
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 222
WGM110 API Reference Manual
API Reference
3.13.1.1 cmd_x509_add_certificate
This command is used to add a certificate to a certificate store.
Table 3.325. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x01
method
Message ID
4
uint8
store
Store used
5-6
uint16
size
Size of certificate data
Table 3.326. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x01
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call x509_add_certificate(store,size)(result)
BGLIB C API
/* Function */
void wifi_cmd_x509_add_certificate(uint8 store, uint16 size);
/* Response id */
wifi_rsp_x509_add_certificate_id
/* Response structure */
struct wifi_msg_x509_add_certificate_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 223
WGM110 API Reference Manual
API Reference
3.13.1.2 cmd_x509_add_certificate_data
This command is used to upload a block of certificate data.
Table 3.327. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x02
method
4
uint8array
data
Message ID
Certificate data to store
Table 3.328. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x02
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call x509_add_certificate_data(data_len, data_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_x509_add_certificate_data(uint8array data);
/* Response id */
wifi_rsp_x509_add_certificate_data_id
/* Response structure */
struct wifi_msg_x509_add_certificate_data_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 224
WGM110 API Reference Manual
API Reference
3.13.1.3 cmd_x509_add_certificate_finish
This command is used to finish adding a certificate.
The command must be called once all the certificate data has been uploaded.
Table 3.329. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x03
method
Message ID
Table 3.330. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x03
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8array
fingerprint
Certificate fingerprint
Length: 16 bytes
BGScript command
call x509_add_certificate_finish()(result,fingerprint_len, fingerprint_data)
BGLIB C API
/* Function */
void wifi_cmd_x509_add_certificate_finish();
/* Response id */
wifi_rsp_x509_add_certificate_finish_id
/* Response structure */
struct wifi_msg_x509_add_certificate_finish_rsp_t
{
uint16 result;,
uint8array fingerprint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 225
WGM110 API Reference Manual
API Reference
3.13.1.4 cmd_x509_add_private_key
This command is used to add a private key to the RAM certificate store.
Table 3.331. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x03
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x04
method
4-5
uint16
size
6
uint8array
fingerprint
Message ID
Size of private key data
Fingerprint of the corresponding user certificate
Length: 16 bytes
Table 3.332. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x04
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call x509_add_private_key(size,fingerprint_len, fingerprint_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_x509_add_private_key(uint16 size, uint8array fingerprint);
/* Response id */
wifi_rsp_x509_add_private_key_id
/* Response structure */
struct wifi_msg_x509_add_private_key_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 226
WGM110 API Reference Manual
API Reference
3.13.1.5 cmd_x509_add_private_key_data
This command is used to upload a block of private key data.
Table 3.333. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x05
method
4
uint8array
data
Message ID
Private key data to store
Table 3.334. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x05
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call x509_add_private_key_data(data_len, data_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_x509_add_private_key_data(uint8array data);
/* Response id */
wifi_rsp_x509_add_private_key_data_id
/* Response structure */
struct wifi_msg_x509_add_private_key_data_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 227
WGM110 API Reference Manual
API Reference
3.13.1.6 cmd_x509_add_private_key_finish
This command is used to finish adding a private key.
The command must be called once all the private key data has been uploaded.
Table 3.335. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x06
method
4
uint8array
password
Message ID
Password used to encrypt the private key data
Length: 0 - 64 bytes
Table 3.336. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x03
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x06
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
6
uint8array
fingerprint
Private key fingerprint
Length: 16 bytes
BGScript command
call x509_add_private_key_finish(password_len, password_data)(result,fingerprint_len, fingerprint_data)
BGLIB C API
/* Function */
void wifi_cmd_x509_add_private_key_finish(uint8array password);
/* Response id */
wifi_rsp_x509_add_private_key_finish_id
/* Response structure */
struct wifi_msg_x509_add_private_key_finish_rsp_t
{
uint16 result;,
uint8array fingerprint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 228
WGM110 API Reference Manual
API Reference
3.13.1.7 cmd_x509_delete_certificate
This command is used to delete a certificate from the certificate store.
Table 3.337. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x01
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x07
method
4
uint8array
fingerprint
Message ID
Certificate fingerprint
Length: 16 bytes
Table 3.338. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x07
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call x509_delete_certificate(fingerprint_len, fingerprint_data)(result)
BGLIB C API
/* Function */
void wifi_cmd_x509_delete_certificate(uint8array fingerprint);
/* Response id */
wifi_rsp_x509_delete_certificate_id
/* Response structure */
struct wifi_msg_x509_delete_certificate_rsp_t
{
uint16 result;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 229
WGM110 API Reference Manual
API Reference
3.13.1.8 cmd_x509_list_certificates
This command is used to retrieve information about added certificates.
Table 3.339. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x08
method
Message ID
Table 3.340. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x08
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call x509_list_certificates()(result)
BGLIB C API
/* Function */
void wifi_cmd_x509_list_certificates();
/* Response id */
wifi_rsp_x509_list_certificates_id
/* Response structure */
struct wifi_msg_x509_list_certificates_rsp_t
{
uint16 result;
};
Table 3.341. Events Generated
Event
Description
x509_certificate
Sent for each certificate
x509_certificate_subject
Sent for each certificate subject
x509_certificates_listed
Sent after all the certificates have been listed
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 230
WGM110 API Reference Manual
API Reference
3.13.1.9 cmd_x509_reset_store
This command is used to reset the certificate stores.
Flash and RAM stores are erased and the modifications to the compile-time store are reset.
Table 3.342. Command
Byte
Type
Name
Description
0
0x08
hilen
Message type: Command
1
0x00
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x00
method
Message ID
Table 3.343. Response
Byte
Type
Name
Description
0
0x08
hilen
Message type: Response
1
0x02
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x00
method
4-5
uint16
result
Message ID
Result code, unsigned 16-bit integer in little endian format
• 0: success
• non-zero: an error occurred
For other values refer to the Error codes.
BGScript command
call x509_reset_store()(result)
BGLIB C API
/* Function */
void wifi_cmd_x509_reset_store();
/* Response id */
wifi_rsp_x509_reset_store_id
/* Response structure */
struct wifi_msg_x509_reset_store_rsp_t
{
uint16 result;
};
3.13.2 x509 events
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 231
WGM110 API Reference Manual
API Reference
3.13.2.1 evt_x509_certificate
This event contains information about a certificate.
Table 3.344. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x04
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x00
method
4
uint8
index
Unique certificate listing index
5
uint8
type
Certificate type
6
uint8
store
Store certificate is in
7
uint8array
fingerprint
Certificate fingerprint
Message ID
Length: 16 bytes
BGScript event
event x509_certificate(index,type,store,fingerprint_len, fingerprint_data)
C Functions
/* Event id */
wifi_evt_x509_certificate_id
/* Event structure */
struct wifi_msg_x509_certificate_evt_t
{
uint8 index;,
uint8 type;,
uint8 store;,
uint8array fingerprint;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 232
WGM110 API Reference Manual
API Reference
3.13.2.2 evt_x509_certificate_subject
This event contains the subject field of a certificate.
Table 3.345. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x02
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x01
method
4
uint8
index
5
uint8array
subject
Message ID
Unique certificate listing index
Certificate subject
BGScript event
event x509_certificate_subject(index,subject_len, subject_data)
C Functions
/* Event id */
wifi_evt_x509_certificate_subject_id
/* Event structure */
struct wifi_msg_x509_certificate_subject_evt_t
{
uint8 index;,
uint8array subject;
};
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 233
WGM110 API Reference Manual
API Reference
3.13.2.3 evt_x509_certificates_listed
This event indicates all the certificates have been listed.
Table 3.346. Event
Byte
Type
Name
Description
0
0x88
hilen
Message type: Event
1
0x00
lolen
Minimum payload length
2
0x0b
class
Message class: X.509
3
0x02
method
Message ID
BGScript event
event x509_certificates_listed()
C Functions
/* Event id */
wifi_evt_x509_certificates_listed_id
/* Event structure */
struct wifi_msg_x509_certificates_listed_evt_t
{
};
3.13.3 x509 enumerations
3.13.3.1 enum_x509_store
This enumeration defines certificate stores.
Table 3.347. Enumerations
Value
Name
Description
0
x509_store_flash
Flash
1
x509_store_ram
RAM
3.13.3.2 enum_x509_type
This enumeration defines certificate types.
Table 3.348. Enumerations
Value
Name
Description
0
x509_type_ca
CA certificate
1
x509_type_user
User/client certificate
3.14 Error codes
This chapter describes all BGAPI error codes.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 234
WGM110 API Reference Manual
API Reference
■
Hardware Error Codes indicate errors related to the hardware, such as failure of the microSD memory card, I2C interface,
etc.
Code
Name
Description
0x0301
ps_store_full
Flash reserved for Persistent Store is full
0x0302
ps_key_not_found
Persistent Store key not found
0x0303
i2c_write_already_started
Tried to start an I2C write transaction, but it is already in
progress
0x0304
i2c_ack_missing
Acknowledge for an I2C operation was not received
0x0308
flash_failed
Writing to flash failed
0x0305
sdhc_not_opened
Tried to access an unopened file
0x0306
sdhc_not_found
File not in SD card
0x0307
sdhc_disk_error
Disk error or disk full
■
BGAPI Error Codes are common error codes. Typical examples are an error code indicating an invalid command or parameter, or that the module is in a wrong state for the sent command.
Code
Name
Description
0x0180
invalid_param
Command contained an invalid parameter
0x0181
wrong_state
Device is in wrong state to accept command
0x0182
out_of_memory
Device has run out of memory
0x0183
not_implemented
Feature is not implemented
0x0184
invalid_command
Command was not recognized
0x0185
timeout
Command or procedure failed due to timeout
0x0186
unspecified
Unspecified error
0x0187
hardware
Hardware failure
0x0188
buffers_full
Command not accepted, because internal buffers are
full
0x0189
disconnected
Command or procedure failed due to disconnection
0x018a
too_many_requests
Too many simultaneous requests
0x018b
ap_not_in_scanlist
Access Point not found from scanlist
0x018c
invalid_password
Password is invalid or missing
0x018d
authentication_failure
WPA/WPA2 authentication has failed
0x018e
overflow
Overflow detected
0x018f
multiple_pbc_sessions
Multiple PBC sessions detected
0x0192
wrong_operating_mode
Wrong operating mode for this command
0x0193
not_found
Requested resource not found
0x0194
already_exists
Requested resource already exists
0x0195
invalid_configuration
Current configuration is invalid
0x0196
ap_lost
Connection to Access Point lost
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 235
WGM110 API Reference Manual
API Reference
■
TCP/IP Error Codes indicate errors related to the internal TCP/IP stack, such as a closed connection, host name not set,
etc.
Code
Name
Description
0x0200
success
No error
0x0201
out_of_memory
Out of memory
0x0202
buffer
Buffer handling failed
0x0203
timeout
Timeout
0x0204
routing
Could not find route
0x0205
in_progress
Operation in progress
0x0206
illegal_value
Illegal value
0x0207
would_block
Operation would block
0x0208
in_use
Address in use
0x0209
already_connected
Already connected
0x020a
abort
Connection aborted
0x020b
reset
Connection reset
0x020c
closed
Connection closed
0x020d
not_connected
Not connected
0x020e
illegal_argument
Illegal argument
0x020f
interface
Interface error
0x0210
service_not_running
Service not running
0x0211
service_running
Service already running
0x0212
hostname_not_set
Hostname not set
0x0213
hostname_conflict
Hostname conflict detected
0x0280
unknown_host
Unknown host
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 236
WGM110 API Reference Manual
Document Revision History
4. Document Revision History
Table 4.1. Document Revision History
Revision Number
Effective Date
Change Description
1.1
May 18th, 2016
Added commands
• cmd_tcpip_multicast_join
• cmd_tcpip_multicast_leave
• cmd_hardware_spi_transfer
• cmd_tcpip_tls_set_user_certificate
Renamed commands
• cmd_tcpip_ssl_connect has been renamed to cmd_tcpip_tls_connect
• cmd_tcpip_ssl_set_authmode has been renamed to cmd_tcpip_tls_set_authmode
Renamed events
• evt_tcpip_ssl_verify_result has been renamed to evt_tcpip_tls_verify_result
Updated command descriptions
• cmd_endpoint_set_streaming
• cmd_sme_get_signal_quality
Updated event descriptions
• evt_endpoint_closing
• evt_endpoint_error
Updated command class descriptions
• sme class
• tcpip class
• hardware
1.0
February 22nd, 2016 Initial release.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 1.1 | 237
Smart.
Connected.
Energy-Friendly.
Products
Quality
www.silabs.com/products
www.silabs.com/quality
Support and Community
community.silabs.com
Disclaimer
Silicon Laboratories intends to provide customers with the latest, accurate, and in-depth documentation of all peripherals and modules available for system and software implementers using
or intending to use the Silicon Laboratories products. Characterization data, available modules and peripherals, memory sizes and memory addresses refer to each specific device, and
"Typical" parameters provided can and do vary in different applications. Application examples described herein are for illustrative purposes only. Silicon Laboratories reserves the right to
make changes without further notice and limitation to product information, specifications, and descriptions herein, and does not give warranties as to the accuracy or completeness of the
included information. Silicon Laboratories shall have no liability for the consequences of use of the information supplied herein. This document does not imply or express copyright licenses
granted hereunder to design or fabricate any integrated circuits. The products are not designed or authorized to be used within any Life Support System without the specific written consent
of Silicon Laboratories. A "Life Support System" is any product or system intended to support or sustain life and/or health, which, if it fails, can be reasonably expected to result in significant
personal injury or death. Silicon Laboratories products are not designed or authorized for military applications. Silicon Laboratories products shall under no circumstances be used in
weapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, or missiles capable of delivering such weapons.
Trademark Information
Silicon Laboratories Inc.® , Silicon Laboratories®, Silicon Labs®, SiLabs® and the Silicon Labs logo®, Bluegiga®, Bluegiga Logo®, Clockbuilder®, CMEMS®, DSPLL®, EFM®, EFM32®,
EFR, Ember®, Energy Micro, Energy Micro logo and combinations thereof, "the world’s most energy friendly microcontrollers", Ember®, EZLink®, EZRadio®, EZRadioPRO®, Gecko®,
ISOmodem®, Precision32®, ProSLIC®, Simplicity Studio®, SiPHY®, Telegesis, the Telegesis Logo®, USBXpress® and others are trademarks or registered trademarks of Silicon Laboratories Inc. ARM, CORTEX, Cortex-M3 and THUMB are trademarks or registered trademarks of ARM Holdings. Keil is a registered trademark of ARM Limited. All other products or brand
names mentioned herein are trademarks of their respective holders.
Silicon Laboratories Inc.
400 West Cesar Chavez
Austin, TX 78701
USA
http://www.silabs.com