nRF51 SDK - S110 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
BLE S110 GATTS Functions

0xA0 - sd_ble_gatts_service_add

Function packet format

Frame format encoding of the sd_ble_gatts_service_add packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA0, see BLE_GATTS_SVCS
1 byte Service Type see GATT Server Service Types
1 byte UUID Present 0x00 Field not present, 0x01 Field present
3 bytesUUID see ble_uuid_t
1 byte 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:

Length Parameter Value
2 bytesUUID see ble_uuid_t::uuid
1 byte UUID Type see ble_uuid_t::type


service_add_packet.png
Figure 1: Packet format for sd_ble_gatts_service_add function.


Response packet format

In case of a successful command, i.e. 'nRF Error Code' = NRF_SUCCESS nRF Error Code is followed by conditional data.

Frame format encoding of the sd_ble_gatts_service_add response packet:

Length Parameter Value
1 byte Operation Code 0xA0, see BLE_GATTS_SVCS
4 bytesnRF Error Code see sd_ble_gatts_service_add
2 bytesConditional: Handle Value see sd_ble_gatts_service_add


service_add_resp_packet.png
Figure 2: Packet format sd_ble_gatts_service_add response packet.


0xA1 - sd_ble_gatts_include_add

Function packet format

Frame format encoding of the sd_ble_gatts_include_add packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA1, see BLE_GATTS_SVCS
2 bytesService Handle see sd_ble_gatts_include_add
2 bytesInclude Service Handle see sd_ble_gatts_include_add
1 byte Include Handle Present 0x00 Field not present, 0x01 Field present


ble_gatts_include_add_packet.png
Figure 1: Packet format for sd_ble_gatts_include_add function.


Response packet format

In case of a successful command, i.e. 'nRF Error Code' = NRF_SUCCESS nRF Error Code is followed by conditional data.

Frame format encoding of the sd_ble_gatts_include_add response packet:

Length Parameter Value
1 byte Operation Code 0xA1, see BLE_GATTS_SVCS
4 bytesnRF Error Code see sd_ble_gatts_include_add
2 bytesConditional: Handle Value see sd_ble_gatts_include_add


service_add_resp_packet.png
Figure 2: Packet format sd_ble_gatts_include_add response packet.


0xA2 - sd_ble_gatts_characteristic_add

Function packet format

Frame format encoding of the sd_ble_gatts_characteristic_add packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA2, see BLE_GATTS_SVCS
2 bytes Service Handle Service handle
1 byte Metadata Present 0x00 - Not Present, 0x01 - Present
11..539 bytesConditional: Characteristic Metadata see ble_gatts_char_md_t
1 byte Characteristic Attribute Present 0x00 - Not Present, 0x01 - Present
9..527 bytes Conditional: Characteristic Attributesee ble_gatts_attr_t
1 byte Handles Present 0x00 - Not Present, 0x01 - Present on Application Chip


gatts_characteristic_add.png
Figure 1: Packet format for sd_ble_gatts_characteristic_add function.


Encoding of Characteristic Metadata

Length Parameter Value
1 byte Characteristic Properties see ble_gatt_char_props_t
1 byte Characteristic Extended Properties see ble_gatt_char_ext_props_t
2 bytes User Descriptor Maximum Size see ble_gatts_char_md_t::char_user_desc_max_size
2 bytes User Descriptor Size see ble_gatts_char_md_t::char_user_desc_size
1 byte User Descriptor Present 0x00 - Not Present, 0x01 - Present
0..512 bytes User Descriptor see ble_gatts_char_md_t::p_char_user_desc
1 byte Presentation Format Structure Present 0x00 - Not Present, 0x01 - Present
7 bytes Presentation Format Structure see ble_gatts_char_pf_t
1 byte Attribute Metadata User Description Present 0x00 - Not Present, 0x01 - Present
3 bytes Attribute Metadata User Description see ble_gatts_attr_md_t
1 byte Attribute metadata for the Client Characteristic Configuration Present 0x00 - Not Present, 0x01 - Present
3 bytes Attribute metadata for the Client Characteristic Configuration see ble_gatts_attr_md_t
1 byte Attribute metadata for the Server Characteristic Configuration Present 0x00 - Not Present, 0x01 - Present
3 bytes Attribute metadata for the Server Characteristic Configuration Descriptionsee ble_gatts_attr_md_t


gatts_characteristic_add_char_metadata.png
Figure 2: Encoding of Characteristic Metadata.


Encoding of Characteristic Metadata Property field

Length Parameter Value
bit 0 broadcast see ble_gatt_char_props_t::broadcast
bit 1 read see ble_gatt_char_props_t::read
bit 2 write_wo_resp see ble_gatt_char_props_t::write_wo_resp
bit 3 write see ble_gatt_char_props_t::write
bit 4 notify see ble_gatt_char_props_t::notify
bit 5 indicate see ble_gatt_char_props_t::indicate
bit 6 auth_signed_wr see ble_gatt_char_props_t::auth_signed_wr
bit 7 not used not used


gatts_characteristic_add_char_metadata_prop.png
Figure 3: Encoding of Property field inside Characteristic Metadata.


Encoding of Characteristic Metadata Extended Property field

Length Parameter Value
bit 0 reliable_wr see ble_gatt_char_ext_props_t::reliable_wr
bit 1 wr_aux see ble_gatt_char_ext_props_t::wr_aux
bit 2..7 not used not used


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


Encoding of Characteristic Metadata Presentation Format field.

Length Parameter Value
1 byte format see ble_gatts_char_pf_t::format
1 byte exponent see ble_gatts_char_pf_t::exponent
2 bytes unit see ble_gatts_char_pf_t::unit
1 byte name_space see ble_gatts_char_pf_t::name_space
2 bytes desc see ble_gatts_char_pf_t::desc


gatts_characteristic_add_char_metadata_pres_format.png
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:

Length Parameter Value
1 byte read_perm see ble_gatts_attr_md_t::read_perm
1 byte write_perm see ble_gatts_attr_md_t::write_perm
1 byte Bit attributes see ble_gatts_attr_md_t


Read and write permissions are encoded in following order:

Length Parameter Value
bit 0..3 sm see ble_gap_conn_sec_mode_t::sm
bit 4..7 lv see ble_gap_conn_sec_mode_t::lv


Bit attributes are encoded in following order:

Length Parameter Value
bit 0 vlen see ble_gatts_attr_md_t::vlen
bit 1..2 vloc see ble_gatts_attr_md_t::vloc
bit 3 rd_auth see ble_gatts_attr_md_t::rd_auth
bit 4 wr_auth see ble_gatts_attr_md_t::wr_auth
bit 5..7 not used not used


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


Encoding of Characteristic Attributes

Note that ble_gatts_attr_t::init_len is relocated in the serialized structure in order to have length field preceeding data field.

Length Parameter Value
1 byte UUID Present 0x00 - Not Present, 0x01 - Present
3 bytes Conditional: UUID see ble_gatts_attr_t::p_uuid
1 byte Attribute Metadata Present 0x00 - Not Present, 0x01 - Present
3 bytes Conditional: Attribute Metadata see ble_gatts_attr_t::p_attr_md
2 bytes Value offset see ble_gatts_attr_t::init_offs
2 bytes Maximum Value Length see ble_gatts_attr_t::max_len
2 bytes Value Length see ble_gatts_attr_t::init_len
1 byte Attribute Data Present 0x00 - Not Present, 0x01 - Present
n bytes Attribute Data see ble_gatts_attr_t::p_value


gatts_characteristic_add_char_attr.png
Figure 7: Encoding of Characteristic Attributes.


Encoding of Characteristic Attributes UUID field.

Length Parameter Value
2 bytes UUID see ble_uuid_t::uuid
1 byte Type see ble_uuid_t::type


gatts_characteristic_add_char_attr_uuid.png
Figure 8: Encoding of UUID field inside Characteristic Attributes.


Encoding of Characteristic Attributes Metadata field.

Length Parameter Value
1 byte read_perm see ble_gatts_attr_md_t::read_perm
1 byte write_perm see ble_gatts_attr_md_t::write_perm
1 byte Bit attributes see ble_gatts_attr_md_t


Read and write permissions are encoded in following order:

Length Parameter Value
bit 0..3 sm see ble_gap_conn_sec_mode_t::sm
bit 4..7 lv see ble_gap_conn_sec_mode_t::lv


Bit attributes are encoded in following order:

Length Parameter Value
bit 0 vlen see ble_gatts_attr_md_t::vlen
bit 1..2 vloc see ble_gatts_attr_md_t::vloc
bit 3 rd_auth see ble_gatts_attr_md_t::rd_auth
bit 4 wr_auth see ble_gatts_attr_md_t::wr_auth
bit 5..7 not used not used


gatts_characteristic_add_char_attr_metadata.png
Figure 9: Encoding of Metadata field inside Characteristic Attributes.


Response packet format

In case of a successful command, i.e. 'nRF Error Code' = NRF_SUCCESS nRF Error Code is followed by conditional data.

Frame format encoding of the sd_ble_gatts_characteristic_add response packet:

Length Parameter Value
1 byte Operation Code 0xA2, see BLE_GATTS_SVCS
4 bytesnRF Error Code see sd_ble_gatts_characteristic_add
1 byte Conditional: Handles Present 0x00 - not present, 0x01 - Handles are present in the packet
8 bytesConditional: Handles see ble_gatts_char_handles_t


ble_gatts_char_handles_t is encoded in following order:

Length Parameter Value
2 bytesValue Handle see ble_gatts_char_handles_t::value_handle
2 bytesUser Desc Handlesee ble_gatts_char_handles_t::user_desc_handle
2 bytesCCCD Handle see ble_gatts_char_handles_t::cccd_handle
2 bytesSCCD Handle see ble_gatts_char_handles_t::sccd_handle


gatts_characteristic_add_response_packet.png
Figure 10: Response Packet format for sd_ble_gatts_characteristic_add response.


0xA3 - sd_ble_gatts_descriptor_add

Function packet format

Frame format encoding of the sd_ble_gatts_descriptor_add packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA3, see BLE_GATTS_SVCS
2 bytes Characteristic Handle Characteristic handle
1 byte Characteristic Attribute Present0x00 - Not Present, 0x01 - Present
11..527 bytessee ble_gatts_attr_t Conditional: Characteristic Attribute
1 byte Handle Present 0x00 - Not Present, 0x01 - Present on Application Chip


gatts_descriptor_add.png
Figure 1: Packet format for sd_ble_gatts_descriptor_add function.


Response packet format

In case of a successful command, i.e. 'nRF Error Code' = NRF_SUCCESS nRF Error Code is followed by conditional data.

Frame format encoding of the sd_ble_gatts_descriptor_add response packet:

Length Parameter Value
1 byte Operation Code 0xA3, see BLE_GATTS_SVCS
4 bytesnRF Error Code see sd_ble_gatts_descriptor_add
2 bytesDescriptor handle Descriptor handle


gatts_descriptor_add_response_packet.png
Figure 2: Response Packet format for sd_ble_gatts_descriptor_add response.


0xA4 - sd_ble_gatts_value_set

Function packet format

Frame format encoding of the sd_ble_gatts_value_set packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA4, see BLE_GATTS_SVCS
2 bytes Attribute Handle sd_ble_gatts_value_set
2 bytes Offset sd_ble_gatts_value_set
1 byte Length Present 0x00 - Not Present, 0x01 - Present
2 bytes Length sd_ble_gatts_value_set
1 byte Attribute Value Present 0x00 - Not Present, 0x01 - Present
2 bytes Attribute Value sd_ble_gatts_value_set


gatts_value_set.png
Figure 1: Packet format for sd_ble_gatts_value_set function.


Response packet format

In case of a successful command, i.e. 'nRF Error Code' = NRF_SUCCESS nRF Error Code is followed by conditional data.

Frame format encoding of the sd_ble_gatts_value_set response packet:

Length Parameter Value
1 byte Operation Code 0xA4, see BLE_GATTS_SVCS
4 bytesnRF Error Code see sd_ble_gatts_value_set
2 bytesConditional: Length of bytes writtensee sd_ble_gatts_value_set


gatts_value_set_response.png
Figure 2: Packet format for sd_ble_gatts_value_set function response.


0xA5 - sd_ble_gatts_value_get

Function packet format

Frame format encoding of the sd_ble_gatts_value_get packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA5, see BLE_GATTS_SVCS
2 bytes Attribute Handle sd_ble_gatts_value_get
2 bytes Offset sd_ble_gatts_value_get
1 byte Length Present 0x00 - Not Present, 0x01 - Present
2 bytes Conditional: Length sd_ble_gatts_value_get
1 byte Value Present 0x00 - Not Present, 0x01 - Present


gatts_value_get_packet.png
Figure 1: Packet format for sd_ble_gatts_value_get function.


Response packet format

In case of a successful command, i.e. 'nRF Error Code' = NRF_SUCCESS nRF Error Code is followed by conditional data.

Frame format encoding of the sd_ble_gatts_value_get response packet:

Length Parameter Value
1 byte Operation Code 0xA5, see BLE_GATTS_SVCS
4 bytesnRF Error Code see sd_ble_gatts_value_get
1 byte Length Present 0x00 - Not Present, 0x01 - Present
2 bytesConditional:Value length in bytes see sd_ble_gatts_value_get
1 byte Value Present 0x00 - Not Present, 0x01 - Present
n bytesConditional:Value see sd_ble_gatts_value_get


gatts_value_get_response_packet.png
Figure 2: Packet format for sd_ble_gatts_value_get function response.


0xA6 - sd_ble_gatts_hvx

Function packet format

Frame format encoding of the sd_ble_gatts_hvx packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA6, see BLE_GATTS_SVCS
2 bytes Connection Handle sd_ble_gatts_hvx
1 byte HVX Parameters Present 0x00 - Not Present, 0x01 - Present
n bytes Conditional:HVX Parameters see sd_ble_gatts_hvx


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

Length Parameter Value
2 bytes handle see ble_gatts_hvx_params_t::handle
1 byte type see ble_gatts_hvx_params_t::type
2 bytes offset see ble_gatts_hvx_params_t::offset
1 byte Length Field Present 0x00 - Not Present, 0x01 - Present
2 bytes Conditional: Length see ble_gatts_hvx_params_t::p_len
1 byte Data Field Present 0x00 - Not Present, 0x01 - Present
n bytes Conditional: Data see ble_gatts_hvx_params_t::p_data


hvx_packet.png
Figure 1: Packet format for sd_ble_gatts_hvx function.


Response packet format

In case of a successful command, i.e. 'nRF Error Code' = NRF_SUCCESS nRF Error Code is followed by conditional data.

Frame format encoding of the sd_ble_gatts_hvx response packet:

Length Parameter Value
1 byte Operation Code 0xA6, see BLE_GATTS_SVCS
4 bytesnRF Error Code see sd_ble_gatts_hvx
1 byte Number of Data Written Present 0x00 - Not Present, 0x01 - Present
2 bytesConditional: Number of Data written see sd_ble_gatts_hvx


hvx_resp_packet.png
Figure 2: Packet format sd_ble_gatts_hvx response packet.


0xA7 - sd_ble_gatts_service_changed

Function packet format

Frame format encoding of the sd_ble_gatts_service_changed packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA7, see BLE_GATTS_SVCS
2 bytes Connection Handle see sd_ble_gatts_service_changed
2 bytes Start Handle see sd_ble_gatts_service_changed
2 bytes End Handle see sd_ble_gatts_service_changed


gatts_service_changed.png
Figure 1: Packet format for sd_ble_gatts_service_changed function.


Response packet format

Frame format encoding of the sd_ble_gatts_service_changed response packet.

Data for the response packet is encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA7, see BLE_GATTS_SVCS
4 bytesnRF Error Code see sd_ble_gatts_service_changed


default_response_packet_generic.png
Figure 2: Response Packet format for sd_ble_gatts_service_changed response.


0xA8 - sd_ble_gatts_rw_authorize_reply

Function packet format

Frame format encoding of the sd_ble_gatts_rw_authorize_reply packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA8, see BLE_GATTS_SVCS
2 bytes Connection Handle see sd_ble_gatts_rw_authorize_reply
1 byte RW Authorize Reply Params Present 0x00 if System Attributes is a NULL pointer, 0x01 otherwise
n bytes Conditional: RW Authorize Reply Params see sd_ble_gatts_rw_authorize_reply


ble_gatts_rw_authorize_reply_params_t is encoded in following order:

Length Parameter Value
1 byte Type see ble_gatts_rw_authorize_reply_params_t::type
n bytes Read or Write Params see ble_gatts_rw_authorize_reply_params_t::read or ble_gatts_rw_authorize_reply_params_t::write
gatts_rw_authorize_reply_packet.png
Figure 1: Packet format for sd_ble_gatts_rw_authorize_reply function.


Read parameters (ble_gatts_read_authorize_params_t) are encoded in the following order (also presented in Figure 2):

Length Parameter Value
2 bytes GATT Status see ble_gatts_read_authorize_params_t::gatt_status
1 byte Update see ble_gatts_read_authorize_params_t::update
2 bytes Offset see ble_gatts_read_authorize_params_t::offset
2 bytes Len see ble_gatts_read_authorize_params_t::len
1 byte Data Present 0x00 if data is a NULL pointer, 0x01 otherwise
n bytes Data see ble_gatts_read_authorize_params_t::p_data


gatts_read_authorize_reply_params.png
Figure 2: Packet format for ble_gatts_read_authorize_params_t struct.


Write parameters (ble_gatts_write_authorize_params_t) are encoded in the following order (also presented in Figure 3):

Length Parameter Value
2 bytes GATT Status see GATT Status Codes


gatts_write_authorize_reply_params.png
Figure 3: Packet format for ble_gatts_write_authorize_params_t struct.


Response packet format

Frame format encoding of the sd_ble_gatts_rw_authorize_reply response packet:

Length Parameter Value
1 byte Operation Code 0xA8, see BLE_GATTS_SVCS
4 bytes nRF Error Code see sd_ble_gatts_rw_authorize_reply


default_response_packet_generic.png
Figure 4: Packet format for sd_ble_gatts_rw_authorize_reply response.


0xA9 - sd_ble_gatts_sys_attr_set

Function packet format

Frame format encoding of the sd_ble_gatts_sys_attr_set packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xA9, see BLE_GATTS_SVCS
2 bytes Connection Handle Handle Value
1 byte System Attributes Present 0x00 if System Attributes is a NULL pointer, 0x01 otherwise
2 bytes Conditional: Length of System Attributes Data n - Number of bytes of System Attributes Data
n bytes Conditional: System Attributes Data Data


sys_attr_set_packet.png
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:

Length Parameter Value
1 byte Operation Code 0xA9, see BLE_GATTS_SVCS
4 bytes nRF Error Code see sd_ble_gatts_sys_attr_set


default_response_packet_generic.png
Figure 2: Packet format for sd_ble_gatts_sys_attr_set response.


0xAA - sd_ble_gatts_sys_attr_get

Function packet format

Frame format encoding of the sd_ble_gatts_sys_attr_get packet.

The parameters are encoded in the following order:

Length Parameter Value
1 byte Operation Code 0xAA, see BLE_GATTS_SVCS
2 bytes Connection Handle Handle Value
1 byte System Attribute Length Present 0x00 if is a NULL pointer, 0x01 otherwise
2 bytes Conditional: System Attribute Length see sd_ble_gatts_sys_attr_get
1 byte System Attribute Data Present 0x00 if is a NULL pointer, 0x01 otherwise


sys_attr_get_packet.png
Figure 1: Packet format for sys_attr_get_packet function.


Response packet format

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.

Frame format encoding of the sd_ble_gatts_sys_attr_get response packet:

Length Parameter Value
1 byte Operation Code 0xAA, see BLE_GATTS_SVCS
4 bytes nRF Error Code see sd_ble_gatts_sys_attr_get
2 bytes Conditional: System Attribute Length see sd_ble_gatts_sys_attr_get
1 byte Conditional: System Attribute Data Present 0x00 if is a NULL pointer, 0x01 otherwise
n bytes Conditional: System Attribute Data see sd_ble_gatts_sys_attr_get


sys_attr_get_resp_packet.png
Figure 2: Packet format for sd_ble_gatts_sys_attr_get function response.