Example #1
0
CAResult_t CAEDRSendData(int serverFD, const void *data, uint32_t dataLength,
                         uint32_t *sentDataLen)
{
    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");

    VERIFY_NON_NULL(data, EDR_ADAPTER_TAG, "Data is null");
    VERIFY_NON_NULL(sentDataLen, EDR_ADAPTER_TAG, "Sent data length holder is null");

    if (0 > serverFD)
    {
        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: Negative socket id");
        return CA_STATUS_INVALID_PARAM;
    }

    int dataLen = bt_socket_send_data(serverFD, (const char *)data, dataLength);
    if (dataLen == -1)
    {
        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "sending data failed!, soketid [%d]", serverFD);
        *sentDataLen = 0;
        return CA_STATUS_FAILED;
    }

    *sentDataLen = dataLen;
    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
    return CA_STATUS_OK;
}
int rhtf_send_data_bluetooth(void* data){
	int ret, len;
	const char* buf = (char*) data;

	len = strlen(buf);
	// Send data to connected socket
	ret = bt_socket_send_data(gSocketFd, buf, len);
	if(ret < 0)
	{
		MIN_LOG("[%s] bt_socket_send_data failed.", __FUNCTION__);
	}
	return ret;
}