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

what to do next for sending somthing like string?

hi in nrf51422 till now this is my code now how can i send or recieve information . or tell me for sending information what to read next?

#include <stdint.h>
#include <string.h>
#include "nordic_common.h"
#include "nrf.h"
#include "app_error.h"
#include "nrf_gpio.h"
#include "ble.h"
#include "ble_hci.h"
#include "ble_srv_common.h"
#include "ble_advdata.h"
#include "ble_advertising.h"
#include "softdevice_handler.h"
#include "app_timer.h"
#include "pstorage.h"
#include "app_trace.h"

#define APP_ADV_INTERVAL                40                                         /**< The advertising interval (in units of 0.625 ms. This value corresponds to 25 ms). */
#define APP_ADV_TIMEOUT_IN_SECONDS      180                                        /**< The advertising timeout in units of seconds. */


static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_BLOOD_PRESSURE_SERVICE,     BLE_UUID_TYPE_BLE},
                                   {BLE_UUID_BATTERY_SERVICE,            BLE_UUID_TYPE_BLE},
                                   {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}}; /**< Universally unique service identifiers. */

																	 
static void advertising_init(void)
{
    uint32_t      err_code;
    ble_advdata_t advdata;

    // Build and set advertising data
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance      = true;
    advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids  = m_adv_uuids;

    ble_adv_modes_config_t options = {0};
    options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = ble_advertising_init(&advdata, NULL, &options, NULL, NULL);
    APP_ERROR_CHECK(err_code);
}



int main()
{
	advertising_init();
	while(1)
	{
		
	}

}
Parents
  • I would recommend using the example ble_app_uart that can be found ounder ble_peripheral in the SDK. The Nordic UART Service (NUS) Application is an example that emulates a serial port over BLE. Information regarding this example can be found here.

    The function ble_nus_string_send send a string over BLE and it can be received with the nRF UART App.

    You can see how the function uart_event_handle in the example use this function to send data. A simple example will be to initialize some data array and sending this

    uint8_t sendbuff[2];
    sendbuff[0] ='a';
    sendbuff[1] = 'b';
    ble_nus_string_send(&m_nus, sendbuff, 3);
    
Reply
  • I would recommend using the example ble_app_uart that can be found ounder ble_peripheral in the SDK. The Nordic UART Service (NUS) Application is an example that emulates a serial port over BLE. Information regarding this example can be found here.

    The function ble_nus_string_send send a string over BLE and it can be received with the nRF UART App.

    You can see how the function uart_event_handle in the example use this function to send data. A simple example will be to initialize some data array and sending this

    uint8_t sendbuff[2];
    sendbuff[0] ='a';
    sendbuff[1] = 'b';
    ble_nus_string_send(&m_nus, sendbuff, 3);
    
Children
No Data
Related