Hello,
I'm actually working with a custom profile generated with Bluetooth Developer Studio. I'have some difficult to send characteristic with the template.
My setup is :
- NRF52832-DK
- Linux environment
- SEGGER-RTT
The fonction(found on tutorial) to send is like :
int32_t temperature = 0;
sd_temp_get(&temperature);
our_termperature_characteristic_update(&m_our_service, &temperature);
But bluetooth developer studio generate something like (without argument &temperature) :
memset(&ble_temp_service_temp_t, 0, sizeof(ble_temp_service_temp_t));
ble_lamp_service_temp_t.temp=0x00;
err_code = ble_temp_service_temp_set(&ble_temp_service_t ,&ble_temp_service_temp_t);
APP_ERROR_CHECK(err_code);
2 structures : Temp structure and service structure where
/**@brief temp structure. */
typedef struct
{ uint32_t temp;
} ble_temp_service_temp_t;
and
/**@brief temp service Service structure. This contains various status information for the service.*/
struct ble_temp_service_s
{
ble_temp_service_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the temp service Service. */
uint16_t service_handle; /**< Handle of temp service Service (as provided by the BLE stack). */
bool is_temp_read_supported; /**< TRUE if read of temp is supported. */
bool is_temp_write_supported; /**< TRUE if write to temp is supported. */
ble_gatts_char_handles_t temp_handles; /**< Handles related to the temp characteristic. */
uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */
};
When I test with this way it doesn't work. How can I send custom characteristic with those kind of template ?
The following code return error 3002 ERROR_BLE_INVALID_ATTR_HANDLE :
uint8_t encoded_value[MAX_TEMP_LEN];
memset(&gatts_value, 0, sizeof(gatts_value));
gatts_value.len = temp_encode(p_temp, encoded_value);
gatts_value.offset = 0;
gatts_value.p_value = encoded_value;
err_code = sd_ble_gatts_value_set(p_temp_service->conn_handle, p_temp_service->temp_handles.value_handle, &gatts_value);
Thank you very much
Nabil