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

Using ble_template example to transfer data

I am using nrf52832, SDK 15.2, Softdevice 6.1, Embedded Studio to program a custom PCB device. My aim is to eventually send data I have from a peripheral device (through SPI) via ble to any mobile app. As of now, for starters, I am trying the send the nrf_gpio_pin_read () data or just random values/strings. I started with the BLE_TEMPLATE example. 

The ble_template example runs (i.e it advertises) on my PCB custom device when I flash it. But when I edit it to incorporate the nus service to send data using nus_data_send() function, the device does not advertise anymore. My code builds and flashes just fine, but there is no data coming from it and it's stops advertising, I am not sure why (I didn't edit the ble_template example much just added a couple NUS things  here and there and add a data_send() function of my own)  

1. I don't get what I am doing wrong in my use of NUS functions that it stops advertising and doesn't send the sample string the way it's supposed to?

2. Is there another way I could go about to transfer a simple string/ int array wirelessly? Without using the NUS service or ble_data_send() function.

I do not use the nus_data_handler() or initialize it in the code because according to my understanding the handler is for data send TO the nrf via ble. 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* Copyright (c) 2014 - 2018, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I do not start with the BLE_UART example because the example does not run on my PCB (PCB does not advertise with it) for some reason (I am guessing the uart pins are connected to other things on the custom board). 

Thanks.