I modified the SimpleBLEObserver_addDeviceInfo() function with two more parameters as I want to store the pEvtData related to each device found.
the below function call works ok. The deviceInfo.dataLen is correctly transmitted to the function.
case GAP_DEVICE_INFO_EVENT:
{
SimpleBLEObserver_addDeviceInfo(pEvent->deviceInfo.addr,
pEvent->deviceInfo.addrType, pEvent->deviceInfo.rssi, pEvent->deviceInfo.dataLen, pEvent->deviceInfo.pEvtData);
}
break;
However if I swap the last two parameters like this
case GAP_DEVICE_INFO_EVENT:
{
SimpleBLEObserver_addDeviceInfo(pEvent->deviceInfo.addr,
pEvent->deviceInfo.addrType, pEvent->deviceInfo.rssi, pEvent->deviceInfo.pEvtData, pEvent->deviceInfo.dataLen);
}
break;
then the pEvent->deviceInfo.dataLen does not hold the original value, which is 0x1E for 30 char expected in pEvtData.
here the function I am calling
static void SimpleBLEObserver_addDeviceInfo(uint8 *pAddr, uint8 addrType, int8 addrRssi, uint8 addrDataLen, uint8 * addrData ) // $$ { uint8 i; // If result count not at max if ( scanRes < DEFAULT_MAX_SCAN_RES ) { // Check if device is already in scan results for ( i = 0; i < scanRes; i++ ) { if (memcmp(pAddr, devList[i].addr, B_ADDR_LEN) == 0) { return; } } // Add addr to scan result list memcpy(devList[scanRes].addr, pAddr, B_ADDR_LEN ); devList[scanRes].addrType = addrType; devList[scanRes].addrRssi = addrRssi; // $$ add rssi value to list memcpy( devList[scanRes].addrData, addrData, (addrDataLen > ADDR_RAW_DATA_ARRAY_SIZE ? ADDR_RAW_DATA_ARRAY_SIZE : addrDataLen)); // $$ limit buffer len to array size // Increment scan result count scanRes++; } }
if I swap the last two parameters addrDataLen holds 0x64 instead of 0x1E set at calling time.
Any thoughts ?