Hello,
I am developing a project with a host processor and Minew BT module with NRF52811. The module and the host processor are communicating via I2C (TWIS). The host processor is a master and the BT module is a slave.
We have a main application on the BT module (based on NUS example) which connects to an Android application and the Android app and the module are communicating by writing to a characteristic (similar to TX/RX). When the phone has written some specific data to the module, the module sends that data to the host processor (the host processor queries every 2ms whether there is something that the module needs to send) and then a HTTP request by the host processor is made. The response from the HTTP request is stored in the GSM module's RAM and can be retrieved in chunks with RTS hardware flow control signal, because the response can be up to 100KB long.
For now, the logic is as follows:
The module gets the first 244 bytes from the HTTP response and sends a notification to the Android app. After that, the module will get the next chunk of 244 bytes of data whenever the module receives BLE_GATTS_EVT_HVN_TX_COMPLETE event (there is a little delay of ~12ms for the host processor to query information that chunk needs to be sent, and get the next chunk with RTS signal and send it via I2C).
However, the throughput is really slow: ~70KB/37s (depends on the connection interval).
I've done some tests with the code snippet below in the main function for test:
if(s_index>0){
s_index++;
if(s_index==570){
s_index=0;
}
static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
for(int i=0;i<244;i++){
data_array[i]=i;
}
do
{
uint16_t length = 244;
err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);
if ((err_code != NRF_ERROR_INVALID_STATE) &&
(err_code != NRF_ERROR_RESOURCES) &&
(err_code != NRF_ERROR_NOT_FOUND))
{
APP_ERROR_CHECK(err_code);
}
} while (err_code == NRF_ERROR_RESOURCES);
} and the results are pretty good.