7 years, 5 months ago.

BLE only sends/app receives first 16 bytes for each call nRF51, evothings

Hi, I'm trying to send sensor signals from a log on a SD card to a phone. '

I know that it reads from SD card correctly.

It's not looping in the while(update) because the code still runs and I tested to look at the return value and it's always 0.

An Evothings app is running on an Android with onNotification callback.

It works better(more then the first packet is received) if there is some delay in the code like printf(); (for some reason wait_ms() is buggy and locks the code)

Tested with different connection intervals and it's still the same problem. Connection interval is set to 20-30 ms now.

void myService::sendLog(const void* _buffer, uint16_t length)
{
	//uint16_t origLength     = length;
    const uint8_t *buffer = static_cast<const uint8_t *>(_buffer);
	uint8_t bufferIndex = 0;
	for (int i = 0; (i << 3) < length; i++) // 2 signals per packet, 4 packet in the inner loop = 8 signals 
	{
		for (int j = 0; j < 4; j++) 
		{
			memcpy(logBuffer, &buffer[bufferIndex], BLE_LOG_PAYLOAD_SIZE);
			while(ble.updateCharacteristicValue(logChar->getValueAttribute().getHandle(), static_cast<const uint8_t *>(logBuffer), BLE_LOG_PAYLOAD_SIZE))		
			bufferIndex += BLE_LOG_PAYLOAD_SIZE;
		}
	}
}

This is what the Evothings app spits out: LOG: Signals: 20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0 LOG: Total rx: 6 LOG: Signals: 20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0 LOG: Total rx: 7 And nRF51 says a lot more TX.

posted by Johan Westlund 12 Jul 2017
Be the first to answer this question.