D.J.Peters wrote:...
For example If you would accept 1K of data you can set maxSize=1024 and the default chunk size of 8K are ignored in this case.
...
This device sends a response typically in the range of ~10 to ~1000 bytes. If a lot of timers are set in the device, the 'get_sysinfo' reply can exceed a 1000 bytes, but not very likely.
Just tested: The maxSize parameter does speed up the GetData() call, but
only is maxSize is
smaller then the data reply size. So think that 'maxSize' should be called 'minSize'. This call:
Code: Select all
dim as integer nBytes = pConnection->GetData(pBuffer, 1) 'expect at least 1 byte
Returns (after a 'putData('get_sysinfo'):
Code: Select all
Received bytes = 610
{"system":{"get_sysinfo":{"sw_ver":"1.5.4 Build 180815 Rel.121440","hw_ver":"2.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(EU)","mac":"68:FF:7B:80:40:DE","dev_name":"Smart Wi-Fi Plug With Energy Monitoring","alias":"StupidPlug","relay_state":1,"on_time":1053,"active_mode":"none","feature":"TIM:ENE","updating":0,"icon_hash":"","rssi":33,"led_off":0,"longitude_i":0,"latitude_i":0,"hwId":"044A516EE63C875F9458DA25C2CCC5A0","fwId":"00000000000000000000000000000000","deviceId":"80061065B3D2BD6C2803CB3B3C8DB09C1B62B107","oemId":"1998A14DAA86E4E001FD7CAF42868B5E","next_action":{"type":-1},"err_code":0}}}
Within 200 ms (from connection setup to end (buffer deallocation).
This call:
Code: Select all
dim as integer nBytes = pConnection->GetData(pBuffer, 1024) 'expect at least 1024 bytes
Gives the same result, but takes 2.15 second.
Leaving maxSize out (or setting it to 0) also results in ~2 seconds.
So my noWait parameter addition is not needed, but I think that 'maxSize' should be called 'minSize'. Post in SNC topic adjusted accordingly.