TCP SoftAP response received in multiple packets #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While setting up a Photon at my office where there are 28 WiFi networks I ran into a bug in softap-setup where the JSON response is assumed to fit in one TCP packet.
I changed the algorithm to try JSON parsing with all the data received so far until it succeeds or there is a timeout.
I also had to bump up the default timeout since the scan takes longer than 2 seconds in my office. I didn't find a place in the
particle-cli
where the SoftAP scan timeout is increased so I bumped it up here.I also removed the check for the object type in
sock.on('data')
since that's a relic of the multi-protocolonData
function and not needed anymore for the TCP only version.I realize @brycekahle that you're in the process of making a bunch of changes to this library and the CLI, and that using
softap-setup-js 4.0.1
in the currentparticle-cli
doesn't work, but I worked around the integration issues in the CLI to make sure this change works.Here's an example of the data I receive (captured by a couple
console.log
inTcpSoftAP.js
):