nRF51 SDK: BLE S110 Functions

| nRF51 SDK

- Home
- Related Pages
- API Reference
- Data Structures

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
BLE S110 Functions

# 0x54 - sd_ble_uuid_encode

## Function packet format

Frame format encoding of the sd_ble_uuid_encode packet.

Operation Code = 0x54 (84) for sd_ble_uuid_encode, see BLE_COMMON_SVCS.

The parameters provided as input to sd_ble_uuid_encode are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x54 (84)
- 1 byte: |  | UUID present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 3 bytes: | ble_uuid_t | Conditional: UUID
- 1 byte: |  | Length present
|  | 0x00 Field not present
|  | 0x01 Field present
- 1 byte: |  | UUID result buffer present
|  | 0x00 Field not present
|  | 0x01 Field present

As can also be seen inside Figure 1 the 3 bytes inside ble_uuid_t are encoded as:

- 2 bytes: | ble_uuid_t::uuid | UUID Value
- 1 byte: | ble_uuid_t::type | UUID Type, see BLE_UUID_TYPES

Figure 1: Packet format for sd_ble_uuid_encode function.

## Response packet format

Frame format encoding of the sd_ble_uuid_encode response packet.

The response packet will encode the return value and in case NRF_SUCCESS is returned, the handle value is also encoded.
In case of an error, only the error code is encoded, without additional data.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x54 (84)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_uuid_encode error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x54 (84)
- 4 byte: |  | nRF Error Code
- 1 byte: |  | Length of encoded UUID, if 'nRF Error Code' is NRF_SUCCESS
- 2 or 16 bytes: |  | Encoded UUID, if 'nRF Error Code' is NRF_SUCCESS
|  | Otherwise nothing is encoded.

Figure 3: Packet format sd_ble_uuid_encode response.

# 0x6C - sd_ble_gap_device_name_set

## Function packet format

Frame format encoding of the sd_ble_gap_device_name_set packet.

Operation Code = 0x6C (108) for sd_ble_gap_device_name_set, see BLE_GAP_SVCS.

The parameters provided as input to sd_ble_gap_device_name_set are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x6C (108)
- 1 byte: |  | Write Permissions Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 1 byte: | ble_gap_conn_sec_mode_t | Conditional: Write Permissions
- 2 bytes: |  | Length of Device Name
- 1 byte: |  | Device Name Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 0 ... 20 bytes: |  | Conditional: Device Name
|  | 'Device Name Length' specifies the actual number of bytes encoded.

The bit fields of Write Permissions are encoded as:

- bit 0 to 3: | ble_gap_conn_sec_mode_t::sm | Security Mode
- bit 4 to 7: | ble_gap_conn_sec_mode_t::lv | Security Level

Figure 1: Packet format for sd_ble_gap_device_name_set function.

## Response packet format

Frame format encoding of the sd_ble_gap_device_name_set response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6C (108)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_device_name_set error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6C (108)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gap_device_name_set success response.

# 0x71 - sd_ble_gap_sec_info_reply

## Function packet format

Frame format encoding of the sd_ble_gap_sec_info_reply packet.

Operation Code = 0x71 (113) for sd_ble_gap_sec_info_reply, see BLE_GAP_SVCS.

The parameters provided as input to sd_ble_gap_sec_info_reply are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x71 (113)
- 2 bytes: |  | Connection Handle
- 1 byte: |  | Encryption Information Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 19 bytes: |  | Conditional: Encryption Information
- 1 byte: |  | Signing Information Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 16 bytes: |  | Conditional: Signing Information

Figure 1: Packet format for sd_ble_gap_sec_info_reply function.

The bit fields of Encryption Information are encoded as below and depicted in Figure 2 and Figure 3:

Figure 2: Contents of Encryption information.

- bit 0: | ble_gap_enc_info_t::auth | Authenticated Key
- bit 1 to 7: | ble_gap_enc_info_t::ltk_len | LTK length in octets

Figure 3: Bit Ordering of LTK and Authenticated Key fields.

## Response packet format

Frame format encoding of the sd_ble_gap_sec_info_reply response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x71 (113)
- 4 byte: |  | nRF Error Code

Figure 4: Packet format for sd_ble_gap_sec_info_reply error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x71 (113)
- 4 bytes: |  | nRF Error Code

Figure 5: Packet format for sd_ble_gap_sec_info_reply success response.

# 0xA0 - sd_ble_gatts_service_add

## Function packet format

Frame format encoding of the sd_ble_gatts_service_add packet.

Operation Code = 0xA0 (160) for sd_ble_gatts_service_add, see BLE_GATTS_SVCS.

The parameters provided as input to sd_ble_gatts_service_add are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0xA0 (160)
- 1 byte: | BLE_GATTS_SRVC_TYPES | Service Type
- 1 byte: |  | UUID present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 3 bytes: | ble_uuid_t | Conditional: UUID
- 1 byte: |  | Connection Handle present
|  | 0x00 Field not present
|  | 0x01 Field present

As can also be seen inside Figure 1 the 3 bytes inside ble_uuid_t are encoded as:

- 2 bytes: | ble_uuid_t::uuid | UUID Value
- 1 byte: | ble_uuid_t::type | UUID Type, see BLE_UUID_TYPES

Figure 1: Packet format for sd_ble_gatts_service_add function.

## Response packet format

Frame format encoding of the sd_ble_gatts_service_add response packet.

The response packet will encode the return value and in case NRF_SUCCESS is returned, the handle value is also encoded.
In case of an error, only the error code is encoded, without additional data.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA0 (160)
- 1 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gatts_service_add error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA0 (160)
- 1 byte: |  | nRF Error Code
- 2 bytes: |  | Connection Handle, if 'nRF Error Code' is NRF_SUCCESS

Figure 3: Packet format sd_ble_gatts_service_add response packet.

# 0xA2 - sd_ble_gatts_characteristic_add

## Function packet format

Frame format encoding of the sd_ble_gatts_characteristic_add packet.

Operation Code = 0xA2 (162) for sd_ble_gatts_characteristic_add, see BLE_GATTS_SVCS.

The parameters provided as input to sd_ble_gatts_characteristic_add are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0xA2 (162)
- 2 bytes: |  | Service Handle
- 1 byte: |  | Metadata Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 11..539 bytes: | ble_gatts_char_md_t | Conditional: Characteristic Metadata
- 1 byte: |  | Characteristic Attribute Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 9..527 bytes: | ble_gatts_attr_t | Conditional: Characteristic Attribute
- 1 byte: |  | Handles Present
|  | 0x00 Field not present
|  | 0x01 Field present on Application Chip

Figure 1: Packet format for sd_ble_gatts_characteristic_add function.

## Encoding of Characteristic Metadata

- 1 byte: | ble_gatt_char_props_t | Characteristic Properties
- 1 byte: | ble_gatt_char_ext_props_t | Characteristic Extended Properties
- 2 bytes: |  | ble_gatts_char_md_t::char_user_desc_max_size
- 2 bytes: |  | ble_gatts_char_md_t::char_user_desc_size
- 1 byte: |  | User Descriptor present
- 0..512 bytes: |  | User Descriptor
- 1 byte: |  | Presentation Format Structure present
- 7 bytes: |  | ble_gatts_char_pf_t Presentation Format Structure
- 1 byte: |  | Attribute Metadata User Description Descriptor present
- 3 byte: |  | ble_gatts_attr_md_t Attribute Metadata User Description Descriptor
- 1 byte: |  | Attribute metadata for the Client Characteristic Configuration Descriptor present
- 3 bytes: |  | Attribute metadata for the Client Characteristic Configuration Descriptor
- 1 byte: |  | Attribute metadata for the Server Characteristic Configuration Descriptor present
- 3 bytes: |  | Attribute metadata for the Server Characteristic Configuration Descriptor

Figure 2: Encoding of Characteristic Metadata.

## Encoding of Characteristic Metadata Property field

- 1 byte: | ble_gatt_char_props_t | Characteristic properties
| - bit 0: | ble_gatt_char_props_t::broadcast
| - bit 1: | ble_gatt_char_props_t::read
| - bit 2: | ble_gatt_char_props_t::write_wo_resp
| - bit 3: | ble_gatt_char_props_t::write
| - bit 4: | ble_gatt_char_props_t::notify
| - bit 5: | ble_gatt_char_props_t::indicate
| - bit 6: | ble_gatt_char_props_t::auth_signed_wr
| - bit 7: | Not used

Figure 3: Encoding of Property field inside Characteristic Metadata.

## Encoding of Characteristic Metadata Extended Property field

- 1 byte: | ble_gatt_char_ext_props_t | Characteristic Extended Properties
| - bit 0: | ble_gatt_char_ext_props_t::reliable_wr
| - bit 1: | ble_gatt_char_ext_props_t::wr_aux
| - bit 2..7: | Not used

Figure 4: Encoding of Extended Property field inside Characteristic Metadata.

## Encoding of Characteristic Metadata Presentation Format field.

- 7 bytes: | ble_gatts_char_pf_t | Presentation Format
- 1 byte: |  | Format
- 1 bytes: |  | Exponent
- 2 bytes: |  | Unit
- 1 byte: |  | Namespace
- 2 bytes: |  | Description

Figure 5: Encoding of Presentation Format field inside Characteristic Metadata.

## Encoding of User Descriptor, CCCD, and SCCD Descriptor Metadata fields.

For User Descriptor, CCCD, and SCCD descriptor the Metadata field is encoded in the following order:

- 1 byte: | ble_gatts_attr_md_t::read_perm | Read Permission
| - bit 0..3: | sm
| - bit 4..7: | lv
- 1 byte: | ble_gatts_attr_md_t::write_perm | Write Permission
| - bit 0..3: | sm
| - bit 4..7: | lv
- 1 byte: | ble_gatts_attr_md_t | Length Location and Authorization
| - bit 0: | vlen
| - bit 1-2: | vloc
| - bit 3: | rd_auth
| - bit 4: | wr_auth

Figure 6: Encoding of User Descriptor, CCCD, and SCCD Descriptor Metadata fields inside Characteristic Metadata.

## Encoding of Characteristic Attributes

- 1 byte: |  | UUID Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 3 bytes: | ble_uuid_t | Conditional: UUID
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 1 byte: |  | Attribute Metadata Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 3 bytes: | ble_gatts_attr_md_t | Conditional: Attribute Metadata
- 2 bytes: |  | Value length
- 2 bytes: |  | Value offset
- 2 bytes: |  | Maximum value length
- 1 byte: |  | Attribute Data Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 0..512 bytes: | ble_gatts_attr_md_t | Conditional: Attribute Data

Figure 7: Encoding of Characteristic Attributes.

## Encoding of Characteristic Attributes UUID field.

- 2 bytes: | ble_uuid_t::uuid | UUID Value
- 1 byte: | ble_uuid_t::type | UUID Type, see BLE_UUID_TYPES

Figure 8: Encoding of UUID field inside Characteristic Attributes.

## Encoding of Characteristic Attributes Metadata field.

- 1 byte: | ble_gatts_attr_md_t::read_perm | Read Permission
| - bit 0..3: | sm
| - bit 4..7: | lv
- 1 byte: | ble_gatts_attr_md_t::write_perm | Write Permission
| - bit 0..3: | sm
| - bit 4..7: | lv
- 1 byte: | ble_gatts_attr_md_t | Length Location and Authorization
| - bit 0: | vlen
| - bit 1-2: | vloc
| - bit 3: | rd_auth
| - bit 4: | wr_auth

Figure 9: Encoding of Metadata field inside Characteristic Attributes.

## Response packet format

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA2 (162)
- 1 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gatts_characteristic_add error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS` , the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA2 (162)
- 4 bytes: |  | nRF Success
- 4 bytes: |  | Length
- 2 bytes: |  | Value Handle
- 2 bytes: |  | User Desc Handle
- 2 bytes: |  | CCCD Handle
- 2 bytes: |  | SCCD Handle

Figure 3: Response Packet format for sd_ble_gatts_characteristic_add function.

# 0x6D - sd_ble_gap_device_name_get

## Function packet format

Frame format encoding of the sd_ble_gap_device_name_get packet.

Operation Code = 0x6D (109) for sd_ble_gap_device_name_get, see BLE_GAP_SVCS.

The parameters provided as input to sd_ble_gap_device_name_get are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x6D (109)
- 1 byte: |  | Device Name length present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 2 bytes: |  | Conditional: Device Name buffer Size
- 1 byte: |  | Device Name result buffer present
|  | 0x00 Field not present
|  | 0x01 Field present

Figure 1: Packet format for sd_ble_gap_device_name_get function.

## Response packet format

Frame format encoding of the sd_ble_gap_device_name_get response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6D (109)
- 1 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_device_name_get error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6D (109)
- 4 bytes: |  | Error code
- 2 bytes: |  | Length of Device Name
- 0 ... 20 bytes: |  | Device Name
|  | 'Device Name Length' specifies the actual number of bytes encoded.

Figure 3: Packet format for sd_ble_gap_device_name_get response.

## Device name data length

The device name length and device name data will not be returned if the device name length in sd_ble_gap_device_name_get is larger than the internal connectivity buffer size. The caller of the function can not indicate larger buffer than what the command decoder can be able to provide to the SoftDevice. An NRF_ERROR_DATA_SIZE will be returned in the error code field of the packet, and no device name length or data will be returned.

# Function packet format

Frame format encoding of the sd_ble_gap_appearance_set packet.

Operation Code = 0x68 (104) for sd_ble_gap_appearance_set, see BLE_GAP_SVCS.

The parameter provided as input to sd_ble_gap_appearance_set is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x68 (104)
- 2 bytes: | BLE_APPEARANCES | Appearance

Figure 1: Packet format for sd_ble_gap_appearance_set function.

## Response packet format

Frame format encoding of the sd_ble_gap_appearance_set response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x68 (104)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_appearance_set error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x68 (104)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gap_appearance_set success response.

# 0x6A - sd_ble_gap_ppcp_set

## Function packet format

Frame format encoding of the sd_ble_gap_ppcp_set packet.

Operation Code = 0x6A (106) for sd_ble_gap_ppcp_set, see BLE_GAP_SVCS.

The parameter provided as input to sd_ble_gap_ppcp_set is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x6A (106)
- 1 byte: |  | GAP Connection Parameters Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 8 bytes: | ble_gap_conn_params_t | GAP Connection Parameters (See Figure 1 for details on encoding)

As shown in Figure 1, each of the 2 byte variable inside ble_gap_conn_params_t are encoded as:

- 2 bytes: | ble_gap_conn_params_t::min_conn_interval | Minimum Connection Interval
- 2 bytes: | ble_gap_conn_params_t::max_conn_interval | Maximum Connection Interval
- 2 bytes: | ble_gap_conn_params_t::slave_latency | Slave Latency
- 2 bytes: | ble_gap_conn_params_t::conn_sup_timeout | Connection Supervision Timeout

Figure 1: Packet format for sd_ble_gap_ppcp_set function.

## Response packet format

Frame format encoding of the sd_ble_gap_ppcp_set response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6A (106)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_ppcp_set error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6A (106)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gap_ppcp_set success response.

# 0x63 - sd_ble_gap_adv_start

## Function packet format

Frame format encoding of the sd_ble_gap_adv_start packet.

Operation Code = 0x63 (99) for sd_ble_gap_adv_start, see BLE_GAP_SVCS.

The parameter provided as input to sd_ble_gap_adv_start is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x63 (99)
- 8 ... 201 bytes: | ble_gap_adv_params_t | GAP Advertising Parameters (See Figure 1 for details on encoding)

As can also be seen in Figure 1 some fields in the encoded data are optional, i.e. ble_gap_adv_params_t::p_peer_addr and ble_gap_adv_params_t::p_whitelist .

The encoded field 'Peer Address Present' identifies if a NULL pointer was provided in ble_gap_adv_params_t::p_peer_addr. If a NULL pointer was provided, the value of 'Peer Address Present' will be set to '0x00' and no data will be encoded. Otherwise it will be set to '0x01, and the encoding of the Peer Address field will follow immediately, as seen in Figure 2.

The encoded field 'GAP Whitelist Present' identifies if a NULL pointer was provided in ble_gap_adv_params_t::p_whitelist. If a NULL pointer was provided, the value of 'GAP Whitelist Present' will be set to '0x00', and no data will be encoded. Otherwise it will be set to '0x01, and the encoding of the GAP Whitelist structure will follow immediately, as seen in Figure 3.

The data inside ble_gap_adv_start_params_t are encoded as:

- 1 byte: |  | GAP Advertising Type
- 1 byte: |  | Peer Address Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 7 bytes: | ble_gap_adv_params_t::p_peer_addr | Conditional: Peer Address
|  | Encoding details can be seen in Figure 2
- 1 byte: | BLE_GAP_ADV_FILTER_POLICIES | Filter Policy
- 1 byte: |  | GAP Whitelist Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 2 ... 186 bytes: | ble_gap_adv_params_t::p_whitelist | Conditional: GAP Whitelist
|  | Encoding details can be seen in Figure 3

Figure 1: Packet format for sd_ble_gap_adv_start function.

## Encoding of Peer Address

If 'Peer Address Present' = 0x01, then the encoding of the 'Peer Address' will follow. 'Peer Address' is a ble_gap_addr_t .

The data inside ble_gap_addr_t are encoded as:

- 1 byte: |  | Address type, see BLE_GAP_ADDR_TYPES
- 6 bytes: |  | Address

If 'Peer Address Present' = 0x00, the encoding of 'Filter Policy' will follow, and hence no 'Peer Address' will be encoded in the packet.

Figure 2: Encoding of peer address if present.

## Encoding of GAP Whitelist

If 'GAP Whitelist Present' = 0x01, then the encoding of the 'GAP Whitelist' will follow.
'GAP Whitelist' is a ble_gap_whitelist_t .

ble_gap_whitelist_t contains two counters, ble_gap_whitelist_t::addr_count and ble_gap_whitelist_t::irk_count, as well as two pointers to arrays. One pointer ble_gap_whitelist_t::pp_addrs pointing to an array of whitelist addresses, and a pointer ble_gap_whitelist_t::pp_irks pointing to an array of IRKs.

The encoded 'GAP whitelist' will first contain the address counter, followed by the encoding of each address. Then the IRK counter, followed by the encoding of each IRK.

The data inside ble_gap_whitelist_t are encoded as:

- 1 byte: |  | Address Counter
- 0 ... 56 bytes: |  | Address list
|  | 'Address Counter' specifies the actual number of addresses encoded.
- 1 byte: |  | IRK Counter
- 0 ... 128 bytes: |  | IRK list
|  | 'IRK Counter' specifies the actual number of IRKs encoded.

If 'GAP Whitelist Present' = 0x00, the encoding of 'Interval' will follow, and hence no 'GAP Whitelist' will be encoded in the packet.

Figure 3: Encoding of GAP Whitelist if present.

## Encoding of GAP Whitelist Addresses Array

The encoding of whitelist addresses start with the 'Whitelist Count' according to the value in ble_gap_whitelist_t::addr_count.
If, the value of 'Whitelist Count' is 0, then no whitelist addresses are encoded, and the 'Whitelist Count' will be followed by the 'IRK Count' as seen in the top of Figure 4.

Otherwise each whitelist address, ble_gap_addr_t , will be encoded as specified by the counter. Each address is 7 bytes, with first byte specifying the address type.

The Whitelist addresses are encoded as:

- 1 byte: |  | Whitelist Address Count

For each address, as defined by 'Whitelist Address Count', the following data are encoded:

- 1 byte: |  | Address Type, see BLE_GAP_ADDR_TYPES
- 6 bytes: |  | Address

Figure 4: Encoding of Whitelist Addresses.

## Encoding of GAP Whitelist IRKs Array

The encoding of whitelist IRKs start with the 'IRK Count' according to the value in ble_gap_whitelist_t::irk_count.
If, the value of 'IRK Count' is 0, then no IRKs are encoded, and the 'IRK Count' will be followed by the 'Interval' field as seen in the top of Figure 5.

Otherwise each IRK, ble_gap_irk_t , will be encoded as specified by the counter. Each IRK is 16 bytes.

The IRKs are encoded as:

- 1 byte: |  | IRK Count

For each IRK, as defined by 'IRK Count', the following data are encoded:

- 16 bytes: |  | IRK

Figure 5: Encoding of Whitelist IRKs.

## Response packet format

Frame format encoding of the sd_ble_gap_adv_start response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x63 (99)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_adv_start error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x63 (99)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gap_adv_start success response.

# 0x62 - sd_ble_gap_adv_data_set

## Function packet format

Frame format encoding of the sd_ble_gap_adv_data_set packet.

Operation Code = 0x62 (98) for sd_ble_gap_adv_data_set, see BLE_GAP_SVCS.

The parameters provided as input to sd_ble_gap_adv_data_set are encoded in the following order:

- 1 byte: | Operation Code, Value = 0x62 (98)
- 1 byte: | Length of Advertising data
- 0 ... 31 bytes: | Advertising Data array
| The number of bytes encoded are specified in the 'Advertising Data Length' field
| If 'Advertising Data Length' = 0, no data are encoded, and the following byte will be the 'Scan Response Data Length' field, see Figure 2
- 1 byte: | Length of Scan Response data
- 0 ... 31 bytes: | Scan Response Data array
| The number of bytes encoded are specified in the 'Scan Response Data Length' field
| If 'Scan Response Data Length' = 0, no data are encoded, and no more bytes are encoded in the packet, see Figure 2

Figure 1: Packet format for sd_ble_gap_adv_set function.

## Encoding of Advertising Packet when data is zero length

Figure 2: Packet format for an empty sd_ble_gap_adv_set function.

## Response packet format

Frame format encoding of the sd_ble_gap_adv_data_set response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x62 (98)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_adv_data_set error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x62 (98)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gap_adv_data_set success response.

# 0x66 - sd_ble_gap_disconnect

## Function packet format

Frame format encoding of the sd_ble_gap_disconnect packet.

Operation Code = 0x66 (102) for sd_ble_gap_disconnect, see BLE_GAP_SVCS.

The parameters provided as input to sd_ble_gap_disconnect is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x66 (102)
- 2 bytes: |  | Connection Handle
- 1 byte: | BLE_HCI_STATUS_CODES | HCI status code

Figure 1: Packet format for sd_ble_gap_disconnect function.

## Response packet format

Frame format encoding of the sd_ble_gap_disconnect response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x66 (102)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_disconnect error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x66 (102)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gap_disconnect success response.

# 0x6F - sd_ble_gap_sec_params_reply

## Function packet format

Frame format encoding of the sd_ble_gap_sec_params_reply packet.

Operation Code = 0x6F (111) for sd_ble_gap_sec_params_reply, see BLE_GAP_SVCS.

The parameters provided as input to sd_ble_gap_sec_params_reply is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x6F (111)
- 2 bytes: |  | Connection Handle
- 1 byte: | BLE_GAP_SEC_STATUS | Security status
- 1 byte: |  | Security Parameters Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 2 bytes: | ble_gap_sec_params_t::timeout | Conditional: Timeout for SMP transactions or Security Request in seconds
- 1 byte: | ble_gap_sec_params_t | Conditional: Bond, MITM, IO capabilites and OOB bitfield
- 1 byte: | ble_gap_sec_params_t::min_key_size | Conditional: Minimum encryption key size in octets
- 1 byte: | ble_gap_sec_params_t::max_key_size | Conditional: Maximum encryption key size in octets

Figure 1: Packet format for sd_ble_gap_sec_params_reply function.

The Bond, MITM, IO Capabilities and OOB fields are all bitfields inside 1 byte as seen in Figure 2.

## Encoding of Bond, MITM, IO Caps and OOB

Figure 2: Encoding of Bond, MITM, IO Caps and OOB inside a sd_ble_gap_sec_params_reply function packet.

## Response packet format

Frame format encoding of the sd_ble_gap_sec_params_reply response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6F (111)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_sec_params_reply error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6F (111)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gap_sec_params_reply success response.

# 0x69 - sd_ble_gap_appearance_get

## Function packet format

Frame format encoding of the sd_ble_gap_appearance_get packet.

Operation Code = 0x69 (105) for sd_ble_gap_appearance_get, see BLE_GAP_SVCS.

The parameter provided as input to sd_ble_gap_appearance_get is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x69 (105)
- 1 byte: |  | Appearance present
|  | 0x00 Field not present
|  | 0x01 Field present

Figure 1: Packet format for sd_ble_gap_appearance_get function.

## Response packet format

Frame format encoding of the sd_ble_gap_appearance_get response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x69 (105)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_appearance_get error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x69 (105)
- 4 bytes: |  | Return Code
- 2 bytes: | BLE_APPEARANCES | Appearance

Figure 3: Packet format for sd_ble_gap_appearance_get function response.

# 0x31 - sd_system_power_off

## Function packet format

Frame format encoding of the Response packet format packet.

Operation Code = 0x31 (49) for sd_power_system_off, see the SoC Library API.

The parameter provided as input to sd_power_system_off is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x31 (49)

Figure 1: Packet format for sd_system_power_off function.

## Response packet format

There is no response for this command.

# 0xA4 - sd_ble_gatts_value_set

## Function packet format

Frame format encoding of the sd_ble_gatts_value_set packet.

Operation Code = 0xA4 (164) for sd_ble_gatts_value_set, see BLE_GATTS_SVCS.

The parameter provided as input to sd_ble_gatts_value_set is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0xA4 (164)
- 2 bytes: |  | Attribute Handle
- 2 bytes: |  | Offset
- 1 byte: |  | Length Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 2 byte: |  | Conditional: Length
- 1 byte: |  | Attribute Value Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 0...Length bytes: |  | Conditional: The number of bytes encoded is specified by the Length field.

Figure 1: Packet format for sd_ble_gatts_value_set function.

## Response packet format

Frame format encoding of the sd_ble_gatts_value_set response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA4 (164)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gatts_value_set error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA4 (164)
- 4 bytes: |  | Return Code
- 2 bytes: |  | Length of bytes written

Figure 3: Packet format for sd_ble_gatts_value_set function response.

# 0xAA - sd_ble_gatts_sys_attr_get

## Function packet format

Frame format encoding of the sd_ble_gatts_sys_attr_get packet.

Operation code = 0xAA (170) for sd_ble_gatts_sys_attr_get, see BLE_GATTS_SVCS.

The parameter provided as input to sd_ble_gatts_sys_attr_get is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x5A (68)
- 2 bytes: |  | Connection Handle
- 1 byte: |  | System Attribute Length Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 2 byte: |  | Conditional: Length
- 1 byte: |  | System Attribute Data Present Length

Figure 1: Packet format for sys_attr_get_packet function.

## Response packet format

Frame format encoding of the sd_ble_gatts_sys_attr_get response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xAA (170)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gatts_sys_attr_get error response.

In case of a successful command, The response packet will encode the return value NRF_SUCCESS. If a valid pointer were provided in the function packet, i.e. `'System Attribute Present' = 0x01`, then the System Attributes from the BLE S110 SoftDevice will be encoded, and the length of the data will be encoded in the length field.
If a NULL pointer where provided in the function packet, i.e. `'System Attribute Present' = 0x00` , then the length of the System Attribute Data will be encoded, but no data will follow.

- 1 byte: |  | Operation Code, Value = 0xAA (170)
- 4 byte: |  | nRF Success
- 2 bytes: |  | System Attributes Length
- 1 byte: |  | System Attributes Present
|  | 0x01 if System Attributes Data are encoded.
|  | 0x00 otherwise
- 0 ... n bytes |  | Conditional: System Attributes Data
|  | The number, `n` , of bytes encoded in the packet is defined in the System Attributes Data Length field.

Figure 3: Packet format for sd_ble_gatts_sys_attr_get function response.

# 0x65 - sd_ble_gap_conn_param_update

## Function packet format

Frame format encoding of the sd_ble_gap_conn_param_update packet.

Operation Code = 0x65 (101) for sd_ble_gap_conn_param_update, see BLE_GAP_SVCS.

The parameter provided as input to sd_ble_gap_conn_param_update is encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x65 (101)
- 2 bytes: |  | Connection Handle
- 1 byte: |  | Connection Parameters Present
|  | 0x00 Field not present
|  | 0x01 Field present and follows immediately in the packet
- 8 bytes: |  | Conditional: Connection Parameters

As can also be seen inside Figure 1 the 8 bytes inside ble_gap_conn_params_t are encoded as:

- 2 bytes: | ble_gap_conn_params_t::min_conn_interval | Minimum Connection Interval
- 2 bytes: | ble_gap_conn_params_t::max_conn_interval | Maximum Connection Interval
- 2 bytes: | ble_gap_conn_params_t::slave_latency | Slave Latency in number of connection events
- 2 bytes: | ble_gap_conn_params_t::conn_sup_timeout | Connection Supervision Timeout

Figure 1: Packet format for sd_ble_gap_conn_param_update function.

## Response packet format

Frame format encoding of the sd_ble_gap_conn_param_update response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x65 (101)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_conn_param_update error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x65 (101)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gap_conn_param_update success response.

# 0x6B - sd_ble_gap_ppcp_get

## Function packet format

Frame format encoding of the sd_ble_gap_ppcp_get packet.

Operation Code = 0x6B (107) for sd_ble_gap_ppcp_get, see BLE_GAP_SVCS.

The parameters provided as input to sd_ble_gap_ppcp_get are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0x6B (107)
- 1 byte: |  | Peripheral Preferred Connection Parameters field present
|  | 0x00 Field not present
|  | 0x01 Field present

Figure 1: Packet format for sd_ble_gap_ppcp_get function.

## Response packet format

Frame format encoding of the sd_ble_gap_ppcp_get response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6B (107)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gap_ppcp_get error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0x6B (107)
- 4 bytes: |  | nRF Error code
- 8 bytes: | ble_gap_conn_params_t | Connection Params

Figure 3: Packet format for sd_ble_gap_ppcp_get response.

# 0xA9 - sd_ble_gatts_sys_attr_set

## Function packet format

Frame format encoding of the sd_ble_gatts_sys_attr_set packet.

Operation Code = 0xA9 (169) for sd_ble_gatts_sys_attr_set, see BLE_GATTS_SVCS.

The parameters provided as input to sd_ble_gatts_sys_attr_set are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0xA9 (169)
- 2 bytes: |  | Connection Handle
- 1 byte: |  | System Attributes Present
|  | 0x00 if System Attributes is a NULL pointer
|  | 0x01 otherwise
- 2 bytes: |  | Conditional: Length of System Attributes Data
- 0 ... n bytes |  | Conditional: System Attributes Data
|  | The number, n, of bytes encoded is defined in the System Attributes Data Length field.

Figure 1: Packet format for sd_ble_gatts_sys_attr_set function.

## Response packet format

Frame format encoding of the sd_ble_gatts_sys_attr_set response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA9 (169)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gatts_sys_attr_set error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA9 (169)
- 4 bytes: |  | nRF Error Code

Figure 3: Packet format for sd_ble_gatts_sys_attr_set success response.

# 0xA6 - sd_ble_gatts_hvx

## Function packet format

Frame format encoding of the sd_ble_gatts_hvx packet.

Operation Code = 0xA6 (166) for sd_ble_gatts_hvx, see BLE_GATTS_SVCS.

The parameters provided as input to sd_ble_gatts_hvx are encoded in the following order:

- 1 byte: |  | Operation Code, Value = 0xA6 (166)
- 2 bytes: |  | Connection Handle
- 1 byte: |  | HVX Parameters Present
|  | 0x00 if p_hvx_params is a NULL pointer
|  | 0x01 otherwise
- 7 ... n bytes: | ble_gatts_hvx_params_t | Conditional: HVX Parameters

As shown in Figure 1, the data inside ble_gatts_hvx_params_t are encoded as:

- 2 bytes: | ble_gatts_hvx_params_t::handle | Characteristic Value Handle
- 1 byte: | ble_gatts_hvx_params_t::type | Indication or Notification, see BLE_GATT_HVX_TYPES
- 2 bytes: | ble_gatts_hvx_params_t::offset | Offset Value
- 1 byte: |  | Data Length Field Present
|  | 0x00 if p_len is a NULL pointer
|  | 0x01 otherwise
- 2 bytes: | ble_gatts_hvx_params_t::p_len | Conditional: Length of Data
- 1 byte: |  | Data Present
|  | 0x00 if p_ is a NULL pointer
|  | 0x01 otherwise
- 0 ... n bytes: | ble_gatts_hvx_params_t::p_data | Conditional: Data Content
|  | The number 'n' of bytes encoded in the packet is defined in the Data Length field.

Figure 1: Packet format for sd_ble_gatts_hvx function.

## Response packet format

Frame format encoding of the sd_ble_gatts_hvx response packet.

In case of an error, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA6 (166)
- 4 byte: |  | nRF Error Code

Figure 2: Packet format for sd_ble_gatts_hvx error response.

In case of a successful command, i.e. `'nRF Error Code' = NRF_SUCCESS`, the following data is encoded:

- 1 byte: |  | Operation Code, Value = 0xA6 (166)
- 4 bytes: |  | nRF Error Code
- 2 bytes: |  | Number of Data written, if 'nRF Error Code' is NRF_SUCCESS
|  | Otherwise nothing is encoded.

Figure 3: Packet format sd_ble_gatts_hvx response packet.