nrf52832.
SDK14.2
Segger ES V3.34a
I am using sd_ble_gatts_value_get, in C file named ble_cus.c to retrieve the 'value' of a characteristic as written to by the nrf-connect APP.
The 'value' is a short string, saved into a buffer which can be successfully passed to the NRF_LOG_INFO. "Great!"
How do I pass/share this string buffer so that it an be accessed in the main.c?
I have tried declaring the buffer in the header file ble.cus.h as an extern and then including ble.cus.h in my main.c file.
**********************************************
ble.cus.h
extern char data_buffer[];
**********************************************
**********************************************
ble_cus.c
uint16_t i = 0; //reset the counter
char data_buffer[3];
ble_gatts_value_t rx_data;
// Initialize value struct.
memset(&rx_data, 0, sizeof(rx_data));
rx_data.offset = 0; //reset back to zero
rx_data.len = 3; // I only send 3 chars from nrf connect
//rx_data.p_value = &data_buffer;
rx_data.p_value = (uint8_t*) &data_buffer;
sd_ble_gatts_value_get(p_ble_evt->evt.gatts_evt.conn_handle, p_cus->org_handles.value_handle, &rx_data);
for(i = 0; i < 3; i++)
{
NRF_LOG_INFO("%02x",data_buffer[i]);
}
**********************************************************
**********************************************************
main.c
#include blue_cus.h
uint16_t i = 0;
for(i = 0; i < 3; i++)
{
NRF_LOG_INFO("%02x", &data_buffer[i]);
}
*********************************************************
ERROR on Build
main.c:1459: undefined reference to `data_buffer'
If I comment out NRF_LOG_INFO("%02x", &data_buffer[i]); from my main.c there are no error and the NRF_LOG_INFO("%02x", &data_buffer[i]); in ble_cus.c spits out the data to the Output screen.
How else can i share this data, to my main.c?