Hello,
I have DA14531 as a BLE chip connected to another host MCU. The only communication between the host MCU and the DA14531 is through the DMA UART used in the SPS example.
I've successfully built and run the SPS example, and it works as expected, sending data to the BLE app and vice versa.
Since the UART is the only communication channel between the host MCU and the DA14531, the host MCU needs to send me commands and data, such as a serial number that needs to be added to the advertising packet, over that same UART. I've managed to capture all data coming to the UART and store it in my RX buffer so I can parse those commands.
The problem I'm facing is responding to the host MCU. What is the easiest way to send a message to the host MCU from the DA14531 using that one DMA UART?Similar thread: https://community.renesas.com/wireles-connectivity/f/bluetooth-low-energy/34664/da14531-sending-bd-address-after-receiving-certain-command-or-custom-string-in-serial-port-service/127211#127211Thank you and best regards
Hi Grginho,Thank you for posting your question online and for creating a new thread.At what point exactly do you sent from the Host MCU to the DA14531 the custom data that you want? (During Boot time, before you start advertising?)
Grginho said:Similar thread: https://community.renesas.com/wireles-connectivity/f/bluetooth-low-energy/34664/da14531-sending-bd-address-after-receiving-certain-command-or-custom-string-in-serial-port-service/127211#127211
On this thread, I did not utilize the DMA UART in order to not affect the SPS mechanisms while checking for Sleep mode. I disabled DMA UART and re-initialized UART1 (without DMA) briefly just to send the BDA to the Host MCU. You can follow the exact implementation to re-configure UART1 and sent the ACK you want on your Host MCU. I called this print_me function just before we start advertising.Best Regards,OV_Renesas
Thank you for the urgent reply.My initial plan was to be able to send data to that UART at any point in time. Is that even possible to do, without breaking the SPS example flow?
Hi Grginho,Thank you for the reply.
Grginho said:My initial plan was to be able to send data to that UART at any point in time. Is that even possible to do, without breaking the SPS example flow?
That would break the SPS flow. Specifically, it will raise the current consumption by a lot and you will need to modify the wake-up callback functions to enable the UART to be active even when we are not connected. By default, UART is enabled only when we establish a BLE Connection.If you do not care about current consumption, you can modify the SPS SDK and enable UART1 all the time. Specifically you should check and might need to modify the following callbacks:
static const struct arch_main_loop_callbacks user_app_main_loop_callbacks = { .app_on_init = user_on_init, // By default the watchdog timer is reloaded and resumed when the system wakes up. // The user has to take into account the watchdog timer handling (keep it running, // freeze it, reload it, resume it, etc), when the app_on_ble_powered() is being // called and may potentially affect the main loop. .app_on_ble_powered = user_on_ble_powered, // By default the watchdog timer is reloaded and resumed when the system wakes up. // The user has to take into account the watchdog timer handling (keep it running, // freeze it, reload it, resume it, etc), when the app_on_system_powered() is being // called and may potentially affect the main loop. .app_on_system_powered = NULL, .app_before_sleep = user_before_sleep, .app_validate_sleep = NULL, .app_going_to_sleep = NULL, .app_resume_from_sleep = NULL, };
Thank you for your reply.OK let's say UART is enabled, can you please share the API I should use to send an array of 20 uint8_t over that UART?My function should be something like this:void send_data_over_uart(uint8_t *data, size_t len){...// send len number of bytes over UART1
...}Thank you
Hi There,Thank you for the reply.
Grginho said:My function should be something like this:void send_data_over_uart(uint8_t *data, size_t len){...// send len number of bytes over UART1 ...}
My function should be something like this:void send_data_over_uart(uint8_t *data, size_t len){...// send len number of bytes over UART1
...}
It should look like this:
void send_data_over_uart(uint8_t *data, size_t len) { uart_send(UART1, data, len, UART_OP_DMA); }
On user_on_init at the end I called:
dma_uart_sps_init(cfg_uart_sps_baudrate, 3); send_data_over_uart(data_over_uart, length);
I appreciate your help. I successfully sent and received data over UART while connected. I've tried modifying the callback functions and disabling sleep mode since I need UART to operate continuously, and power consumption isn't a major concern at the moment, but I haven't been able to get it working.
Could you please provide some quick instructions on what changes I need to make to get UART working all the time?Thank you in advance and best regards
I have completely disabled sleep mode in user_config.h file to app_default_sleep_mode = ARCH_SLEEP_OFF.In the arch_main.c file I called dma_uart_on_connect(); before the while loop.Uart TX is now working even if the device is not connected, so I'm able to send data over SPS UART. But RX doesn't work, and it starts working only if I establish a connection. I've tried finding what else is set in the on_connected callback but have had no luck. Can you please help me figure out what else needs to be set to have UART fully working even if a connection is not established?I really appreciate any help you can provide.
Hello,I'm still stuck with this. Can you please provide some instruction how to enable UART without establishing BLE connection?