This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ble data transfer

Hi,

I am using the following statements for send a string data over BLE.

static uint8_t Name3[BLE_NUS_MAX_DATA_LEN]= "xxxxxxxx";
	err_code = ble_nus_string_send(&m_nus, Name3, 20);	
	if (err_code != NRF_ERROR_INVALID_STATE)
	{
		APP_ERROR_CHECK(err_code);
	}	

But I am unable to send integers and floating values. Is there a function where I can send non-string data variables via BLE.

Regards Siva

Parents
  • Hi,

    Fist we must distinguish BLE and the Nordic UART Service (NUS).

    NUS is only a service, which provides UART over BLE. Since it works as UART, it can be used as UART. Basically you send and receive a series of bytes.

    There are several other BLE services. Some are specified by the Bluetooth SIG, others are custom made. So in theory you could make your own service, or select an existing one, that fits with your use case. See BLE Services, a beginner's tutorial for an introduction to services.

    If you want to use the Nordic UART Service, i.e. UART communication, you must decide how to encode your numbers. You may send integers and floats by just using their binary values, splitting them up into a series of bytes as suggested by RichieJH. Another solution is to use sprintf() to create a string from the numeral value and transmit that string.

    Regards, Terje

Reply
  • Hi,

    Fist we must distinguish BLE and the Nordic UART Service (NUS).

    NUS is only a service, which provides UART over BLE. Since it works as UART, it can be used as UART. Basically you send and receive a series of bytes.

    There are several other BLE services. Some are specified by the Bluetooth SIG, others are custom made. So in theory you could make your own service, or select an existing one, that fits with your use case. See BLE Services, a beginner's tutorial for an introduction to services.

    If you want to use the Nordic UART Service, i.e. UART communication, you must decide how to encode your numbers. You may send integers and floats by just using their binary values, splitting them up into a series of bytes as suggested by RichieJH. Another solution is to use sprintf() to create a string from the numeral value and transmit that string.

    Regards, Terje

Children
No Data
Related