BLE receive callback function does not invoke itself upon high load

Using the BLE UART variant to exchange messages with a peripheral (Bluetooth LE | Tutorials | Particle), the peripheral when sending high amounts of data over to the Tracker seems to succeed only in theory. The callback registered in the Particle Tracker with a single byte counter inside (which displays and resets after disconnect callback) yields only random % of success, from 1%, to 10% packets received. BLE does nothing else, when connected to the single peripheral, except receive.

@Colleen - I know there’s been a lot of chatter behind the scenes. Have we looked into this?

My mistake, I conflated this with @Nexusmaster 's other issue.

@Nexusmaster are you getting any errors? Can you share the code that isn’t working?

Still have them. When the peripheral is sending some data continuously. The receive callback does not count all the bytes. If you put a log displaying hex that is coming in, some of the stream will be missing.
The code is abridged to the relevant length that is unconditionally stuttering with BLE packet reception:

#include "Particle.h"
#include "tracker_config.h"
#include "tracker.h"
#include <fcntl.h>
#include "PublishQueuePosixRK.h"
#include <sstream>
#include <string>
#include <algorithm>
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

PRODUCT_ID(TRACKER_PRODUCT_ID);
PRODUCT_VERSION(TRACKER_PRODUCT_VERSION);

const BleUuid serviceUuid("6E400001-B5A3-F393-E0A9-E50E24DCCA9E");
const BleUuid rxUuid("6E400002-B5A3-F393-E0A9-E50E24DCCA9E");
const BleUuid txUuid("6E400003-B5A3-F393-E0A9-E50E24DCCA9E");

const size_t SCAN_RESULT_COUNT = 10;
int byte_number_from_ble = 0;
BleScanResult scanResults[SCAN_RESULT_COUNT];

BleCharacteristic peerTxCharacteristic;
BleCharacteristic peerRxCharacteristic;
BlePeerDevice peer;


SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
    { "app.gps.nmea", LOG_LEVEL_INFO },
    { "app.gps.ubx",  LOG_LEVEL_INFO },
    { "ncp.at", LOG_LEVEL_INFO },
    { "net.ppp.client", LOG_LEVEL_INFO },
});



void onDataReceived(const uint8_t* data, size_t len, const BlePeerDevice& peer_callback, void* context) {
    byte_number_from_ble += len;
}


void disconnectedCallback(const BlePeerDevice& peer_callback, void* context){
    Log.trace("total number of bytes received %d",  byte_number_from_ble);
    byte_number_from_ble = 0;
}



void bluetooth_loop() {
    if (BLE.connected()){
        ;
    }
    else {
    	if (millis() - lastScan >= SCAN_PERIOD_MS) {
    		// Time to scan
    		lastScan = millis();
            Log.trace("Scanning BLE");
    		size_t count = BLE.scan(scanResults, SCAN_RESULT_COUNT);
			if (count > 0) {
				for (uint8_t ii = 0; ii < count; ii++) {
					BleUuid foundServiceUuid;
					size_t svcCount = scanResults[ii].advertisingData().serviceUUID(&foundServiceUuid, 1);
                    if ((scanResults[ii].address().toString().compareTo(mac_filter) == 0) || mac_filter_flag_off)
				    	if (svcCount > 0 && foundServiceUuid == serviceUuid) {
				    	    peer = BLE.connect(scanResults[ii].address());
				    	    if (peer.connected()) {
				    	    	peer.getCharacteristicByUUID(peerTxCharacteristic, txUuid);
				    	    	peer.getCharacteristicByUUID(peerRxCharacteristic, rxUuid);
                            const char* message = "getRecord 38400\n";
                            peerRxCharacteristic.setValue((uint8_t*)message, (size_t)String(message).length());
                        }
	                    break;
					}
				}
			}
    	}
    }
}


void setup()
{

    Serial.begin();
	BLE.on();
    BLE.onDisconnected(disconnectedCallback);

#if SYSTEM_VERSION == SYSTEM_VERSION_v310
	// This is required with 3.1.0 only
	BLE.setScanPhy(BlePhy::BLE_PHYS_AUTO);
#endif

    peerTxCharacteristic.onDataReceived(onDataReceived, &peerTxCharacteristic);
    Tracker::instance().init();
    PublishQueuePosix::instance().setup();
    PublishQueuePosix::instance().withRamQueueSize(40);
    Particle.connect();
}


void loop()
{
    Tracker::instance().loop();
    bluetooth_loop();
    PublishQueuePosix::instance().loop();
}