This document contains the full API reference for the Silicon Labs Bluetooth Smart Software, version
2.6.1.
The Blue Gecko family of the Silicon Labs' Bluetooth Smart chipsets deliver a high performance, low
energy and easy-to-use Bluetooth Smart solution integrated into a small form factor package.
The ultra-low power operating modes and fast wake-up times of the Silicon Labs' energy friendly 32bit MCUs, combined with the low transmit and receive power consumption of the Bluetooth radio,
result in a solution optimized for battery powered applications.
silabs.com | Building a more connected world.Rev. 2.5
• Non-zero: See Bluetooth specification, Host volume, Attribute Protocol, Error Codes
table.
att_opcode1 byteAttribute opcode which informs the procedure from which attribute the value was re-
ceived
uuid_12816 bytes128-bit UUID
aes_key_12816 bytes128-bit AES Key
silabs.com | Building a more connected world.Rev. 2.5 | 4
Bluetooth Smart Software API Reference Manual
API Reference
2. 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.
BGAPI Payload
The parameters of a BGAPI command, response or event are passed between the application and firmware in a payload. For example,
a parameter of uint32 type uses 4 bytes of the payload space. A byte array parameter uses one byte to describe the length of the array
and the actual data in array is copied into the remaining free payload space.
Maximum BGAPI Payload Size
The maximum BGAPI payload size is 256 bytes for both NCP and SoC modes. When an application calls a BGAPI command, BGAPI
checks the payload length and will return error code 0x018a (command_too_long) if the payload will cause an overflow.
Deprecation Notice
Note that some commands, enumerations and events are marked as deprecated. The usage of those commands is not recommended
anymore as they will be removed in the future releases.
silabs.com | Building a more connected world.Rev. 2.5 | 5
2.1 Cooexistence interface (coex)
Bluetooth Smart Software API Reference Manual
API Reference
Coexistence BGAPI
class. Coexistence interface is enabled and initialised with gecko_initCoexHAL() function. Interface is configured
with HAL configurator.
2.1.1 coex commands
2.1.1.1 cmd_coex_get_counters
This command is used to read coexistence statistic counters from the device. Response contains the list of uint32 type counter values.
Counters in the list are in following order: low priority requested, high priority requested, low priority denied, high priority denied, low
priority tx aborted, high priority tx aborted.
Table 2.1. Command
ByteTypeNameDescription
00x20hilenMessage type: Command
10x01lolenMinimum payload length
20x20classMessage class: Cooexistence interface
30x01methodMessage ID
4uint8resetReset counter values
Table 2.2. Response
ByteTypeNameDescription
00x20hilenMessage type: Response
10x03lolenMinimum payload length
20x20classMessage class: Cooexistence interface
30x01methodMessage ID
4-5uint16resultResult code
• 0: success
• Non-zero: an error occurred
For other values refer to the
6uint8arraycountersVariable length byte array. The first byte defines the length of the
data that follows, 0 - 255 bytes.
BGLIB C API
/* Function */
struct gecko_msg_coex_get_counters_rsp_t *gecko_cmd_coex_get_counters(uint8 reset);
silabs.com | Building a more connected world.Rev. 2.5 | 7
Bluetooth Smart Software API Reference Manual
2.1.2.1 enum_coex_option
Coexistence configuration options
Table 2.5. Enumerations
ValueNameDescription
256coex_option_enableEnable coexistence feature
1024coex_option_tx_abortAbort transmission if grant is denied
2048coex_option_high_priorityEnable priority signal
API Reference
silabs.com | Building a more connected world.Rev. 2.5 | 8
2.2 Device Firmware Upgrade (dfu)
Bluetooth Smart Software API Reference Manual
API Reference
These commands
and events are related to controlling firmware update over the configured host interface and are available only when
the device has been booted into DFU mode. The DFU process:
1. Boot device to DFU mode with DFU reset command
2. Wait for DFU boot event
3. Send command Flash Set Address to start the firmware update
4. Upload the firmware with Flash Upload commands until all the data has been uploaded
5. Send when all the data has been uploaded
6. Finalize the DFU firmware update with Reset command.
DFU mode is using UART baudrate from hardware configuration of firmware. Default baudrate 115200 is used if firmware is missing or
firmware content does not match with CRC checksum.
2.2.1 dfu commands
silabs.com | Building a more connected world.Rev. 2.5 | 9
2.2.1.1 cmd_dfu_flash_set_address
Bluetooth Smart Software API Reference Manual
API Reference
After re-booting
the local device into DFU mode, this command can be used to define the starting address on the flash to where the
new firmware will be written in.
ByteTypeNameDescription
00x20hilenMessage type: Command
10x04lolenMinimum payload length
20x00classMessage class: Device Firmware Upgrade
30x01methodMessage ID
4-7uint32addressThe offset in the flash where the new firmware is uploaded to. Al-
ByteTypeNameDescription
00x20hilenMessage type: Response
10x02lolenMinimum payload length
20x00classMessage class: Device Firmware Upgrade
Table 2.6. Command
ways use the value 0x00000000.
Table 2.7. Response
30x01methodMessage ID
4-5uint16resultResult code
• 0: success
• Non-zero: an error occurred
For other values refer to the Error codes
BGLIB C API
/* Function */
struct gecko_msg_dfu_flash_set_address_rsp_t *gecko_cmd_dfu_flash_set_address(uint32 address);
/* Response id */
gecko_rsp_dfu_flash_set_address_id
silabs.com | Building a more connected world.Rev. 2.5 | 10
2.2.1.2 cmd_dfu_flash_upload
Bluetooth Smart Software API Reference Manual
API Reference
This command
can be used to upload the whole firmware image file into the Bluetooth device. The passed data length must be a multiple of 4 bytes. As the BGAPI command payload size is limited, multiple commands need to be issued one after the other until the
whole .bin firmware image file is uploaded to the device. The next address of the flash sector in memory to write to is automatically
updated by the bootloader after each individual command.
Table 2.8. Command
ByteTypeNameDescription
00x20hilenMessage type: Command
10x01lolenMinimum payload length
20x00classMessage class: Device Firmware Upgrade
30x02methodMessage ID
4uint8arraydataAn array of data which will be written onto the flash.
Table 2.9. Response
ByteTypeNameDescription
00x20hilenMessage type: Response
10x02lolenMinimum payload length
20x00classMessage class: Device Firmware Upgrade
30x02methodMessage ID
4-5uint16resultResult code
• 0: success
• Non-zero: an error occurred
For other values refer to the Error codes
BGLIB C API
/* Function */
struct gecko_msg_dfu_flash_upload_rsp_t *gecko_cmd_dfu_flash_upload(uint8 data_len, const uint8 *data_data);
silabs.com | Building a more connected world.Rev. 2.5 | 11
Bluetooth Smart Software API Reference Manual
API Reference
2.2.1.3 cmd_dfu_flash_upload_finish
This command can be used to tell to the device that the DFU file has been fully uploaded. To return the device back to normal mode the
command DFU Reset must be issued next.
Table 2.10. Command
ByteTypeNameDescription
00x20hilenMessage type: Command
10x00lolenMinimum payload length
20x00classMessage class: Device Firmware Upgrade
30x03methodMessage ID
Table 2.11. Response
ByteTypeNameDescription
00x20hilenMessage type: Response
10x02lolenMinimum payload length
20x00classMessage class: Device Firmware Upgrade
30x03methodMessage ID
4-5uint16resultResult code
• 0: success
• Non-zero: an error occurred
For other values refer to the Error codes
BGLIB C API
/* Function */
struct gecko_msg_dfu_flash_upload_finish_rsp_t *gecko_cmd_dfu_flash_upload_finish();
/* Response id */
gecko_rsp_dfu_flash_upload_finish_id
silabs.com | Building a more connected world.Rev. 2.5 | 12
2.2.1.4 cmd_dfu_reset
Bluetooth Smart Software API Reference Manual
API Reference
This command
can be used to reset the system. This command does not have a response, but it triggers one of the boot events (normal reset or boot to DFU mode) after re-boot.
ByteTypeNameDescription
00x20hilenMessage type: Command
10x01lolenMinimum payload length
20x00classMessage class: Device Firmware Upgrade
30x00methodMessage ID
4uint8dfuBoot mode:
BGLIB C API
/* Function */
void *gecko_cmd_dfu_reset(uint8 dfu);
/* Command does not have a response */
Table 2.12. Command
• 0: Normal reset
• 1: Boot to UART DFU mode
• 2: Boot to OTA DFU mode
Table 2.13. Events Generated
EventDescription
system_bootSent after the device has booted into normal mode
dfu_bootSent after the device has booted into UART DFU mode
2.2.2 dfu events
silabs.com | Building a more connected world.Rev. 2.5 | 13
2.2.2.1 evt_dfu_boot
Bluetooth Smart Software API Reference Manual
API Reference
This event
indicates that the device booted into DFU mode, and is now ready to receive commands related to device firmware upgade
le_connection_closedThis event indicates that a connection was closed.
silabs.com | Building a more connected world.Rev. 2.5 | 16
2.4 Persistent Store (flash)
Bluetooth Smart Software API Reference Manual
API Reference
Deprecated. Persistent
Store commands can be used to manage the user data in the flash memory of the Bluetooth device. User data
stored in PS keys within the flash memory is persistent across reset and power cycling of the device. The maximum user data size
associated to a PS key is 56 bytes.
2.4.1 flash commands
2.4.1.1 cmd_flash_ps_dump
Deprecated. This command can be used to retrieve all PS keys and their current values. For each existing PS key a flash_pskey event
will be generated which includes the corresponding PS key value.
Table 2.19. Command
ByteTypeNameDescription
00x20hilenMessage type: Command
10x00lolenMinimum payload length
20x0dclassMessage class: Persistent Store
30x00methodMessage ID
Table 2.20. Response
ByteTypeNameDescription
00x20hilenMessage type: Response
10x02lolenMinimum payload length
20x0dclassMessage class: Persistent Store
30x00methodMessage ID
4-5uint16resultResult code
• 0: success
• Non-zero: an error occurred
For other values refer to the Error codes
BGLIB C API
/* Function */
struct gecko_msg_flash_ps_dump_rsp_t *gecko_cmd_flash_ps_dump();
silabs.com | Building a more connected world.Rev. 2.5 | 20
2.4.1.5 cmd_flash_ps_save
Bluetooth Smart Software API Reference Manual
API Reference
Deprecated. This
command can be used to store a value into the specified PS key. Allowed PS keys are in range from 0x4000 to
0x407F. At most 56 bytes user data can be stored in one PS key. Error code 0x018a (command_too_long) will be returned if more than
56 bytes data is passed in.
Table 2.28. Command
ByteTypeNameDescription
00x20hilenMessage type: Command
10x03lolenMinimum payload length
20x0dclassMessage class: Persistent Store
30x02methodMessage ID
4-5uint16keyPS key
6uint8arrayvalueValue to store into the specified PS key.
silabs.com | Building a more connected world.Rev. 2.5 | 22
Bluetooth Smart Software API Reference Manual
2.5 Generic Attribute Profile (gatt)
The commands and events in this class can be used to browse and manage attributes in a remote GATT server.
2.5.1 gatt commands
API Reference
silabs.com | Building a more connected world.Rev. 2.5 | 23
2.5.1.1 cmd_gatt_discover_characteristics
Bluetooth Smart Software API Reference Manual
API Reference
This command
can be used to discover all characteristics of the defined GATT service from a remote GATT database. This command
generates a unique gatt_characteristic event for every discovered characteristic. Received gatt_procedure_completed event indicates
that this GATT procedure has succesfully completed or failed with error.
gatt_characteristicDiscovered characteristic from remote GATT database.
gatt_procedure_completedProcedure has been successfully completed or failed with error.
silabs.com | Building a more connected world.Rev. 2.5 | 24
2.5.1.2 cmd_gatt_discover_characteristics_by_uuid
Bluetooth Smart Software API Reference Manual
API Reference
This command
can be used to discover all the characteristics of the specified GATT service in a remote GATT database having the
specified UUID. This command generates a unique gatt_characteristic event for every discovered characteristic having the specified
UUID. Received gatt_procedure_completed event indicates that this GATT procedure has successfully completed or failed with error.
gatt_characteristicDiscovered characteristic from remote GATT database.
gatt_procedure_completedProcedure has been successfully completed or failed with error.
silabs.com | Building a more connected world.Rev. 2.5 | 25
2.5.1.3 cmd_gatt_discover_descriptors
Bluetooth Smart Software API Reference Manual
API Reference
This command
can be used to discover all the descriptors of the specified remote GATT characteristics in a remote GATT database.
This command generates a unique gatt_descriptor event for every discovered descriptor. Received gatt_procedure_completed event
indicates that this GATT procedure has succesfully completed or failed with error.
gatt_descriptorDiscovered descriptor from remote GATT database.
gatt_procedure_completedProcedure has been successfully completed or failed with error.
silabs.com | Building a more connected world.Rev. 2.5 | 26
2.5.1.4 cmd_gatt_discover_primary_services
Bluetooth Smart Software API Reference Manual
API Reference
This command
can be used to discover all the primary services of a remote GATT database. This command generates a unique
gatt_service event for every discovered primary service. Received gatt_procedure_completed event indicates that this GATT procedure
has successfully completed or failed with error.
can be used to discover primary services with the specified UUID in a remote GATT database. This command generates unique gatt_service event for every discovered primary service. Received gatt_procedure_completed event indicates that this
GATT procedure has succesfully completed or failed with error.
can be used to commit or cancel previously queued writes to a long characteristic of a remote GATT server. Writes are
sent to queue with prepare_characteristic_value_write command. Content, offset and length of queued values are validated by this procedure. A received gatt_procedure_completed event indicates that all data has been written successfully or that an error response has
been received.
gatt_procedure_completedProcedure has been successfully completed or failed with error.
silabs.com | Building a more connected world.Rev. 2.5 | 29
2.5.1.7 cmd_gatt_find_included_services
Bluetooth Smart Software API Reference Manual
API Reference
This command
can be used to find out if a service of a remote GATT database includes one or more other services. This command
generates a unique gatt_service_completed event for each included service. This command generates a unique gatt_service event for
every discovered service. Received gatt_procedure_completed event indicates that this GATT procedure has successfully completed or
failed with error.