nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
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:GATT Server Service 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 Types of UUID


service_add_packet.png
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


default_error_response_packet.png
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


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