I’d like to get all variables in a single call and not having to do 100 calls to get 100 values back.
I think I’ll just have to serialize in a long train of bytes without the json or XML formating characters and de-serialize on my android app. The only problem is that I have several variables that are bytes and int mixed up and de-serialization will require the length of the variable, which means, I need on byte to indicate size for each variable I’m sending and thus increasing the length of the payload, but I would still be under the 622 bytes.
So, here is how I think I have to do:
Variable 1: 0x40 (byte)
Variable 2: 0x0901 (int)
Variable 3: 0x14A3 (int)
Variable 4: 0xF5 (byte)
…
…
The return value of myvar would be: 01400209010214A301F5
The first byte is the length of the variable (01), so the next byte is the value of the variable (40).
The next byte would be the length of the 2nd variable (02), which is an int size, so the next variable value would be 0901
An so on.
Does it make sense? I’m pretty sure this would work, but is there a better solution?
This is what I’d like to ultimately send to the android app. Don’t get caught too much on the length of the payload right now. It does increase overtime as I add more stuff to the code.
XML formatted:
RA><ID>username</ID><T1>779</T1><T2>773</T2><T3>766</T3><PH>373</PH><R>236</R><RON>0</RON><ROFF>255</ROFF><R1>124</R1><RON1>0</RON1><ROFF1>255</ROFF1><R2>40</R2><RON2>0</RON2><ROFF2>255</ROFF2><R3>0</R3><RON3>0</RON3><ROFF3>255</ROFF3><R4>0</R4><RON4>0</RON4><ROFF4>255</ROFF4><R5>0</R5><RON5>0</RON5><ROFF5>255</ROFF5><R6>0</R6><RON6>0</RON6><ROFF6>255</ROFF6><R7>0</R7><RON7>0</RON7><ROFF7>255</ROFF7><R8>0</R8><RON8>0</RON8><ROFF8>255</ROFF8><ATOLOW>1</ATOLOW><ATOHIGH>0</ATOHIGH><EM>219</EM><EM1>15</EM1><REM>3</REM><BID>1</BID><AF>0</AF><SF>0</SF><PWMA>0</PWMA><PWMD>0</PWMD><PWMAO>255</PWMAO><PWMDO>255</PWMDO><SAL>60</SAL><ORP>0</ORP><PHE>0</PHE><WL>59</WL><WL1>50</WL1><WL2>38</WL2><WL3>200</WL3><WL4>200</WL4><HUM>0</HUM><PAR>0</PAR><DCM>4</DCM><DCS>52</DCS><DCD>50</DCD><C0>0</C0><C1>76</C1><C2>0</C2><C3>0</C3><C4>0</C4><C5>0</C5><C6>0</C6><C7>255</C7><LEAK>0</LEAK><PWME0>71</PWME0><PWME0O>255</PWME0O><PWME1>0</PWME1><PWME1O>255</PWME1O><PWME2>52</PWME2><PWME2O>255</PWME2O><PWME3>1</PWME3><PWME3O>255</PWME3O><PWME4>0</PWME4><PWME4O>255</PWME4O><PWME5>0</PWME5><PWME5O>255</PWME5O><RFM>4</RFM><RFS>60</RFS><RFD>200</RFD><RFW>0</RFW><RFRB>3</RFRB><RFR>0</RFR><RFG>0</RFG><RFB>0</RFB><RFI>0</RFI><RFWO>255</RFWO><RFRBO>255</RFRBO><RFRO>255</RFRO><RFGO>255</RFGO><RFBO>255</RFBO><RFIO>255</RFIO></RA>
JSON formatted:
{"json":{"ID":"username","T1":"779","T2":"775","T3":"766","PH":"371","R":"172","RON":"0","ROFF":"255","R0":"124","RON0":"0","ROFF0":"255","R1":"40","RON1":"0","ROFF1":"255","R2":"0","RON2":"0","ROFF2":"255","R3":"0","RON3":"0","ROFF3":"255","R4":"0","RON4":"0","ROFF4":"255","R5":"0","RON5":"0","ROFF5":"255","R6":"0","RON6":"0","ROFF6":"255","R7":"0","RON7":"0","ROFF7":"255","ATOLOW":"1","ATOHIGH":"0","EM":"219","EM1":"15","REM":"3","BID":"1","AF":"0","SF":"0","PWMA":"0","PWMD":"0","PWMAO":"255","PWMDO":"255","SAL":"60","ORP":"0","PHE":"0","WL":"60","WL1":"48","WL2":"38","WL3":"200","WL4":"200","HUM":"0","PAR":"0","DCM":"4","DCS":"52","DCD":"50","C0":"0","C1":"76","C2":"0","C3":"0","C4":"0","C5":"0","C6":"0","C7":"255","LEAK":"0","PWME0":"71","PWME0O":"255","PWME1":"0","PWME1O":"255","PWME2":"52","PWME2O":"255","PWME3":"1","PWME3O":"255","PWME4":"0","PWME4O":"255","PWME5":"0","PWME5O":"255","RFM":"4","RFS":"60","RFD":"200","RFW":"0","RFRB":"3","RFR":"0","RFG":"0","RFB":"0","RFI":"0","RFWO":"255","RFRBO":"255","RFRO":"255","RFGO":"255","RFBO":"255","RFIO":"255"}}
Anyone with any other thoughts?
Thanks,
RI