Hi everyone,
I want to transmit a HEX array I read from a peripheral using SPI communication (I initialize my RX_BUF in the SPI_EVT_HANDLER() function) via BLE. I am using a mobile app (nrfConnect and nrf Toolbox) to receive data from the device. The device is a custom made PCB using nrf52832. I start with the ble_uart example in SDK 15.2 (Embedded Studio), and add SPI functionality. I think my SPI communication works fine and initializes the data array okay.
I am using the NUS service to transmit data via ble. When I call ble_nus_data_send() outside of the nus_data_handler () function, it does not work. Even though this post (https://devzone.nordicsemi.com/f/nordic-q-a/43576/queries-on-nus_data_send-functionality) says that the function call and data transfer can be done anywhere in the project. I try calling the ble data send function in the main loop, didn't send anything to my NRF_TOOLBOX mobile app. Then I removed it from the main loop and tried calling nus_data_send() in my spi event handler instead, but it wouldn't throw anything to the mobile app there either.
My goal here is to control when the data transfer via ble occurs. I don't want the project to send data whenever the nus_data_handler (i.e. a ble event occurs) is called. I want the transfer to happen when my SPI event is called. Or when I am requesting data from my peripheral. But the nus_data_send() doesn't work that way apparently..?
1. I tried calling the spi_evt_handler inside the nus_evt_handler in an attempt to merge these two events (I want them to happen at the same time), but that didn't work. The program doesn't send anything to the app in that case, and I'm guessing it's because it gets stuck in calling a function from within another.
2. I cannot see my received array on my RTT log. I have disabled all uart use so that my custom device works properly (there was a pin use clash).
Can someone please help me understand this nus_data_send() functionality? And how I can use it to call it in my custom made data call function?