Hello everyone, i am developing a board based on the nRF52832 microcontroller SDK v16.0.0 and sd132 for sending data of a sensor over BLE to a mobile APP. For this i am using the Nordic Uart Service but i am getting bad performance for it.
I started from the ble_peripheral_app and then added Nus service, i run a simple test to know the maximun message rate that i can have that work like this:
In main:
uint8_t message = 1;
uint16_t message_lenght = 1;
while(true){
if(ble_nus_tx_is_ready()){}
send_nus_data(&message, message_lenght);
message++;
}
}
In the ble file (i separate the ble module from main) i have this function:
void send_nus_data(uint8_t *buf, uint16_t size)
{
tx_char_bussy = true;
ble_nus_data_send(&m_nus, buf, &size, m_conn_handle);
}
And the next line on the nus event handler to update the bussy flag of the nus TX char:
static void nus_evt_handler(ble_nus_evt *p_evt)
{
if(p_evt->type == BLE_NUS_EVT_TX_RDY){
tx_char_bussy = false;
}
}Of course i have more code but i just show you the important parts so you can understand how the test work. So is run this test for 4 Seconds (I use an App timer of 4000 milliseconds to stop the test) and i only get in average 15 messages per second wich i think is very low, if i send messages of 20 bytes lenght i will get 300bps, i dont understand what is wrong because i was specting a lot more messages. Here are some important parameters that i am using for the BLE instance:
#define APP_ADV_INTERVAL 300 /**< The advertising interval (in units of 0.625 ms. This value corresponds to 187.5 ms). */
#define APP_ADV_DURATION 18000
#define APP_BLE_OBSERVER_PRIO 3
#define APP_BLE_CONN_CFG_TAG 1
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS)
#define SLAVE_LATENCY 0
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)
#define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000)
#define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000)
#define MAX_CONN_PARAMS_UPDATE_COUNT 3
_____________________________________________________
/* SDK config related: */
#define NRF_SDH_BLE_GAP_DATA_LENGTH 27
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23
_____________________________________________________
/* Clock: */
#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \
.rc_ctiv = 0, \
.rc_temp_ctiv = 0, \
.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM}I hope the information provided is enough to see the problem, if more information is needed please tell me.