Hi,
I'm having trouble writing to a characteristic when operating as a central. I'm sure it is just a lack of understanding on my part but neither the SDK documentation nor the examples I have seen are helping resolve this. I have successfully managed to discover services and characteristics on the peripheral but when I attempt to write to the characteristic I get an error 0x3400 which I believe is BLE_ERROR_GATTS_INVALID_ATTR_TYPE.
I've used the same code in another project when sending data from a peripheral back to a central without problems. Is this correct when trying to write from a central or is this totally wrong? Is there something else I'm missing? I have a feeling there is a bit more I need to do after discovering a characteristic before it can be used but I'm struggling to see what that might be.
Thanks for your help!
ret_code_t UpdateCharacteristic(uint16_t connHandle,uint16_t charValueHandle,uint8_t* dataBuffer,uint16_t dataBufferLen)
{
ble_gatts_hvx_params_t hvx_params;
memset(&hvx_params, 0, sizeof(hvx_params));
hvx_params.handle = charValueHandle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = 0;
hvx_params.p_len = &dataBufferLen;
hvx_params.p_data = dataBuffer;
ret_code_t retCode = sd_ble_gatts_hvx(connHandle, &hvx_params);
return retCode;
}