how to reverse byte array order?

so if my original array is

{..... , 0x20 ,0xB7 , 0xA2 , 0x22 , .....}

it will change it to

{.... 0x22 , 0xA2, 0xB7 , 0x20....}

Thanks ,

You rarly even need to do that except if you're stuck using some library/function you didn't make.

Otherwise, just reverse the order you loop through it :wink:

OK

I thought there is a reverse function (like in C# for list)

Thanks ,

No, you can make one for sure. But like I said, in most cases that’s just a wast to do.

byte Array[] = {..... , 0x20 ,0xB7 , 0xA2 , 0x22 , .....};
const ArrayLength = sizeof Array / sizeof Array[0];

  for (unsigned i = 0; i < ArrayLength/2; i++)
  {
     byte temp = Array[i];
     Array[i] = Array[ArrayLength - 1 - i];
     Array[ArrayLength - 1 - i] = temp;
  }