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

BLE_GATTS_EVT_HVN_TX_COMPLETE is never called

Hello, I have a bit of a weird case. I'm sending data over Bluetooth. In the begging, I wrote whole data handling in the main.c main loop. everything worked nicely, so I have decided to move all data handling to the new c file (MLX.c). Data is handling correctly, I have tested that using nrf_log, however sending it over Bluetooth I have an issue. it sends only 15 samples and stops while through nrf log I can see that data is still being handled.

Data sampling in MLX

      case MLX_step:
        nrf_gpio_pin_clear(LED_1);
          sample = sample + 1;
          data_length = Data_length_setup(sample);
          sprintf(csample1,"s%d, \r",sample);
          BLT_data_send(csample1,data_length);      // Data send over bluetooth

          for (int32_t a = 0; a<10  ;a++)
          {             
            int16_t test = MLX_read();

            if (test < 0)
            {test = test*(-1);}

            data_length = Data_length_setup(test);

            sprintf(mybuf,"%d,  \r",test);
            BLT_data_send(mybuf,data_length);      // Data send over bluetooth                                    
            nrf_delay_ms(10);
          }
         nrf_gpio_pin_set(LED_1);
      break;

BLT_data_send(); function is in the main.c

void BLT_data_send(char *data, int16_t data_l)
{  
  uint32_t err_code = ble_nus_data_send(&m_nus, data,&data_l, m_conn_handle);
  //while (err_code == NRF_ERROR_RESOURCES);
}

I have figured out that I have issues with NRF_ERROR_RESOURCES, so I have added a new case in the "ble_evt_handler", however, I never seen "send" in the terminal. So I guess BLE_GATTS_EVT_HVN_TX_COMPLETE never occurs? 

        case BLE_GATTS_EVT_HVN_TX_COMPLETE:
            NRF_LOG_INFO("send");
            NRF_LOG_FLUSH(); 
            break;

I'm quite new with NRF and software and I can't really figure what's going on, especially then data handling is done in main.c file is all good. I assume some kind of Bluetooth buffer getting full or something. Any help would be appreciated, thanks!

I'm working on a custom-made board with the nrf52 module and Bluetooth is sent to the PCA10056 development kit. 

Regards,
Jonas G

Parents
  • Hi Jonas

    Where are you calling sd_ble_gatts_hvx from in your application? If you are sending this from a SoftDevice interrupt, this will block the TX_COMPLETE event because the application will never leave the SoftDevice interrupt. If so, you can leave the interrupt and set a flag that you can trig the send function from the main IRQ level. 

    Best regards,

    Simon

Reply
  • Hi Jonas

    Where are you calling sd_ble_gatts_hvx from in your application? If you are sending this from a SoftDevice interrupt, this will block the TX_COMPLETE event because the application will never leave the SoftDevice interrupt. If so, you can leave the interrupt and set a flag that you can trig the send function from the main IRQ level. 

    Best regards,

    Simon

Children
No Data
Related