64bit double float to byteArray ?

Hi there,

I've started developing a widget to remote control via BLE the Insta360 One R action camera.

https://apps.garmin.com/us-US/apps/bb53f4bb-6c8c-4369-bca9-84cc09b25526

I've already implement basic remote control functionality and now I'm in the phase of sending GPS Telemetry to the camera.

However the camera only wants 64bit double float GPS coordinates , speed, altitude, etc, values sent in HEX format that I handle through byteArrays, but the encodeNumber method only supports 32bit encoding.

Is there a way around this ?

Thanks for your help.

Greg

  • I have implemented a library for converting doubles to byte arrays in https://github.com/mannyray/GarminBytePacking which adds the encoding to doubles

    var someLong = 123l;
    var byteArray = BytePacking.BPLong.longToByteArray(someLong);
    Test.assert(byteArray.equals([0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7B]b));
    Test.assert(BytePacking.BPLong.byteArrayToLong(byteArray) == someLong);
    
    var someFloat = 123.34f;
    byteArray = BytePacking.BPFloat.floatToByteArray(someFloat);
    Test.assert(byteArray.equals([0x42,0xF6,0xAE,0x14]b));
    Test.assert(BytePacking.BPFloat.byteArrayToFloat(byteArray) == someFloat);
    
    var someDouble = 1234578.65432d;
    byteArray = BytePacking.BPDouble.doubleToByteArray(someDouble);
    Test.assert(byteArray.equals([0x41,0x32,0xD6,0x92,0xA7,0x81,0x83,0xF9]b));
    Test.assert(BytePacking.BPDouble.byteArrayToDouble(byteArray) == someDouble);