I have the following node:
[{"id":"f7844f50.7553c","type":"function","z":"11942aca.455835","name":"","func":"var lookup = {\n 73 : \"lemon\",\n 75 : \"pear\",\n 0 : \"apple\",\n 2 : \"orange\",\n 57 : \"kiwi\",\n 42 : \"grapefruit\",\n 1 : \"bad apple\",\n 255 : \"coconut\"\n \n}\n\nvar result = {};\nfor (let i = 0; i < msg.payload.length - 1; i=i+4) {\n let i1 = msg.payload[i];\n let i2 = msg.payload[i+2];\n let name = lookup[i1] || \"Unknown\" + i1;\n result[name] = {\n id: i1,\n value: i2\n }\n}\n\nmsg.payload = result;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":200,"wires":[["ad3a363a.68ba28"]]}]
In which i sent byte objects from my python application in this form to node-red [0,0,213,2,1,0,96,0,2,0,1,0]. The first 4 bytes are referred to a particular object (here apples) i have stored in a JSON file. More specifically the first byte in order 0 shows my class id of apples, second byte is an extension of first after uint16 conversion.
Now here is the purpose of this post, byte 3 here with a value of 213 is my object counting for apples, when this value gets beyond 255+1 and overflows it resets to 0. Forth byte here with a value of 2 is showing that iterated 2 times(counted already 2 full bytes) by 256+256. My question is how am i possible whenever i reach a point of overflow to add these values to the position of byte 3 and get the accurate count of my particular object.
Bear in mind that i inject this to TTN [ 0 725 1 96 2 1] in a byte array. As you will see my first object has 725 counts 256+256+213. The same goes from byte 5 and byte 9.
Original post is the following, but until that time i had objects up until 200 so i had to do a modification in my python code to facilitate more