Service iqmesh.EnumerateDeviceService wrong parsing of Perifery
It returns:
"peripheralEnumeration": {
"dpaVer": "4.00",
"perNr": 2,
"embPers": [ 254, 2, 0, 0 ],
"hwpId": 15,
"hwpIdVer": 1,
"flags": {
"value": 1,
"rfModeStd": true,
"rfModeLp": false,
"stdAndLpNetwork": false
},
"userPers": [ 0, 0, 0, 0, 0, 8, 0, 64, 0, 0, 0, 0 ]
}
But it's useless copy of returned bytes. Bytes embedPer, userPer shall be parsed as bitmap field as done in JS Driver:
userPer: iqrf.BitmapToIndexes( responseData, 12, responseData.length - 1, 0x20 )
where
/* Function: iqrf.BitmapToIndexes
Returns an array of indexes of set bits in the bitmap.
Parameters:
bitmap - array: Array of bytes.
indexFrom - number: Starting index of the byte in the bitmap.
indexTo - number: Ending index of the byte in the bitmap.
offset - number: [optional] Value to start indexing from. Default value is 0.
Returns:
array: Array of integers specifying the offset indexes of bits set in the bitmap.
*/
iqrf.BitmapToIndexes = function ( bitmap, indexFrom, indexTo, offset )
{
if ( !Array.isArray( bitmap ) )
throw new Error( 'iqrf.BitmapToIndexes: Parameter bitmap is not an array but ' + typeof bitmap );
if ( offset === undefined )
offset = 0;
var result = [];
for ( var index = indexFrom; index <= indexTo; index++ )
{
var bitmapByte = bitmap[index];
if ( bitmapByte === 0 )
offset += 8;
else
for ( var bitMask = 0x01; bitMask !== 0x100; bitMask <<= 1 )
{
if ( ( bitmapByte & bitMask ) !== 0 )
result[result.length] = offset;
offset++;
}
}
return result;
};