Changes the order of the blob’s bytes
Device + Agent
This method changes the order of the contents of the target blob by reversing the order of every group of four bytes: bytes 0, 1, 2 and 3 become bytes 3, 2, 1 and 0, bytes 4, 5, 6 and 7 become bytes 7, 6, 5 and 4, and so on:
If each four of bytes forms a 32-bit integer value, swap4() allows you change the ‘endian’ nature of this value: ie. whether its most-significant byte comes first or last. The imp is little-endian, but not all devices are, and this method allows you to interpret readings from them correctly, or to ensure that data sent to them is correctly formatted.