Hi I'm new with programming nrf52840 dongle (I'm using Ubuntu),
I try to wrote this code taking inspiration from the nRF5_SDK_15.0.0_a53641a (peripheral/usbd_cdc_acm and peripheral/radio/trasmitter) because I want to capture bluetooth data and send them via serial.
Once I program my dongle, then I use screen to see /dev/ttyACMx but I realized I did not capture all the data.
Can someone help me to understand where I'm wrong?
Thanks in advance.
this is the main function:
int main(void)
{
ret_code_t ret;
ret = nrf_drv_clock_init();
APP_ERROR_CHECK(ret);
nrf_drv_clock_lfclk_request(NULL);
while(!nrf_drv_clock_lfclk_is_running())
{
// Just waiting
}
ret = app_timer_init();
APP_ERROR_CHECK(ret);
ret = nrf_cli_init(&m_cli_cdc_acm, NULL, true, true, NRF_LOG_SEVERITY_INFO);
APP_ERROR_CHECK(ret);
usbd_init();
ret = nrf_cli_start(&m_cli_cdc_acm);
APP_ERROR_CHECK(ret);
int channel = 37;
my_radio_configure(BLE_1MB, channel);
NRF_RADIO->PACKETPTR = (uint32_t) packet;
int last_atts = 0;
while (true)
{
UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
#if CLI_OVER_USB_CDC_ACM && APP_USBD_CONFIG_EVENT_QUEUE_ENABLE
berga
while (app_usbd_event_queue_process())
{
/* Nothing to do */
}
#endif
uint32_t received = read_packet();
if(received == 0) continue;
char m_tx_buffer[2000];
sprintf(m_tx_buffer, "[%d]:packet: ", cnt);
cnt++;
int kk;
for(kk = 0; kk < 20; kk ++) {
sprintf(m_tx_buffer + strlen(m_tx_buffer), "%02X ", packet[kk]);
}
sprintf(m_tx_buffer + strlen(m_tx_buffer), "\r\n");
size_t size = strlen(m_tx_buffer) + 1;
last_atts = 0;
do{ last_atts ++;
ret = app_usbd_cdc_acm_write(&nrf_cli_cdc_acm, m_tx_buffer, size);
//if(ret == NRF_SUCCESS) break;
}while(ret != NRF_SUCCESS);
//nrf_delay_ms(1000);
// nrf_cli_process(&m_cli_cdc_acm);
}
}