Photon softAP usage?

Caveat: it may not be exactly the same server source Particle is using but here is what it likely is:

https://github.com/asmcos/wiced-emw3165/blob/master/libraries/daemons/HTTP_server/http_server.c#L826

4 Likes

Bingo! Safari is posting the data with 2 TCP segments, Chrome is doing it with only one. Very good catch @indraastra!

Iā€™m happy to email the raw packet capture files to anyone who wants to look them over further, just send me your email in a PM.

Note @msolters you can get a copy of the full WICKED SDK just by signing up as a developer with Broadcom.

The question becomes what do we do now? Iā€™m not excited about the idea of waiting on Broadcomā€¦ @mdma Can we just reconfig the sever endpoints to be able to receive credentials via query parameters in a GET?

3 Likes

Sorry for duplicating this link but I have at least posted this as an issue in the firmware repository.

@mebrunet thanks for the info!

At the end of the day though, we need to see the WICED codebase being implemented in the firmware to be patched. We need to update the packet logic to accumulate data until it hits a CRLF line, and then to process that accumulated data.

2 Likes

Nice work people.

Thanks for this, your hard work tracking this down is so much appreciated. :+1: It really narrows down the search.

Iā€™ve been unwell this week but as soon as Iā€™m back Iā€™ll look at fixing this. We are still waiting for a permissive license for WICED SDK 3.3.1 that might have already resolved this issue.

1 Like

I just checked the HTTP server daemon in WICED SDK 3.3.1 and it seems to suffer from the same problem of not really handling HTTP as a stream. Despite it being a blocker for us, Iā€™m not sure itā€™d be a worthy investment on your part to fix their broken HTTP server. In the interim, supporting a GET version of the configure-ap and connect-ap HTTP calls like @mebrunet suggests is a really great idea.

1 Like

I have (started) an android app to control the color of a connected lamp for my family and i just wanted to tell you that the js-solution is also working great inside of a webview control inside the android app - with the HTML and .js files packed locally in the apps assets. that way you donā€™t even have to have internet access prior to connect to the photons AP.

i might change that approach to a native one later on - but i am new to android development and also i dont really know java - the app is created with xamarin in C#.

Anyways, this is really is an awesome community!

1 Like

Thanks for your answer. The photon works well, I have claimed it with my particle account and connected to a WiFi network with the Particle Android App, but not with the meteor page.
I have clear all the stored wifi credentials, put the device on listening mode, connected my laptop to the photon wireless network and to Internet by the Ethernet connection but the page does not find it.

The first time I connected it has automaticaly update the firmware (magenta light during some minutes).

It is neccesary to be claimed before trying?

Sorry, but I do not know what I am doing wrong and it seems it is a foolishness.

Thanks for your support

Thanks anthonywebb. In the step 4 it appears a pop up windows saying ā€œThere was a problem fetching important information from your device. Please verify your connection, then reload the pageā€

You will want to make sure that the photon is running the latest firmware. Install the particle CLI and run ā€œparticle updateā€ from the command line, this will get you all up to date then the browser based config should work, we have been using it a lot (in chrome)

1 Like

I have put the device in dfu mode. Connected by USB cable and particle update says ā€œupdate succesffully completedā€ but the light is still in yellow (no magenta) so I suppose the device is up to date.

After that it still happens the same. With the particle android app I do not have any problem.

When you are saying the latest firmware you are referring to the original firmware (Tinker), arenā€™t you?

Thanks

anthonywebb I have tried with another Photon (which has the same firmware version of the first one I tried) and it works perfectly.

Both have the 0.4.6

The main difference between the two Photon is the first one I tried was a virgin one it was claimed but it has Tinker software and the second one (the one which works) has my software running on it.

I have tried to install my software on the one which doesnā€™t work and now it also works.

So, may be this could be useful for others, it is neccesary to install a different software from the default one to use your web.

Congratulations for your contribution. Thank you very much,

May be you are having my same problem.

Hi guys,

I am working with a SoftAP setup from @mebrunet (thanks!), which works well (on Windows 10, Chrome).

My goal is to get it working with two-legged authentication. Part of it is getting a claim code for customer from Particle Cloud before the claiming process is started (this works). Then, when the browser gets public key from a Photon, browser should send the claim code to it. I was not able to find a documentation for this step, just setClaimCode function in softap-setup-js repository. Knowing this, I am trying to send a POST request to 192.168.0.1:80/set with these data:

var jsonData = {
k:'cc',
v: 'OsPeNYppQPHfatjV5uuCWaJj37lKbOas4R9pAETmhcBfZr1TTQ/4EVweODweYxV'
}; 

The final request looks like this:

Request:

POST /set HTTP/1.1
Host: 192.168.0.1
Connection: keep-alive
Content-Length: 80
Origin: null
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Content-Type: multipart/form-data
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: cs-CZ,cs;q=0.8,en;q=0.6,sk;q=0.4

Request body:

{k: "cc", v: "OsPeNYppQPHfatjV5uuCWaJj37lKbOas4R9oAETmhcBfZr1TTQ/4EVweODweYxV"}

Response:

{"r":0}

From the response, I see that the Photon understands the request (when you try something else than ā€œccā€, it sends r: -1). But in the end, it doesnt claim the device to the user whose claim code was used. I am checking this relation in dashboard/product/customers section.

Does anyone tried to go through the process of claiming a device to existing customer with company (not-particle) account?

Cheers, Dalibor

By the way, on Nokia Lumia 830 in Internet Explorer, the mentioned SoftAP setup doesnt work - the final configuration is sent to Photon, but Photon keeps blinking blue, no changeā€¦

@mebrunet @indraastra @mdma @msolters Commendable work. Sorry I couldnā€™t be of more help - was out of the office for a week. Looks like we have a good handle on this and on the options. Is the GET option the most likely solution, at least for now?

@javier_pelaez @anthonywebb @mars Could you kindly create a separate thread for your conversations? Weā€™re happy to help but I donā€™t want this topic getting cluttered/lost :slight_smile:

Hello everyone,

Iā€™m going to look at this issue tomorrow. If someone has a simple set of instructions for reproducing this that would be great.

If not, I was thinking of simply formulating a sHTTP/1.0 request and sending this in 2 parts using telnet, so that it sends the parts as 2 packets.

Thatā€™s great news! To reproduce this bug ā€œnaturally,ā€ it seems the simplest approach would be just to try HTTP SoftAP setup in Safari on Mac. It should fail at the configure-ap step.

Hereā€™s a simple python test script that you can run to test the responses:

(edited) https://gist.github.com/indraastra/6ba088ef4f7d5b1fb5af

$ python3 client.py 1
sending 1 packet
{'r': -1024}

$ python3 client.py 2
sending 2 packets
{'r': 0}

As a side note: the server returns the response {ā€˜rā€™:0} for an alarming number of invalid cases, which is why testing for a failure is actually more telling.

2 Likes

PR with a fix here! https://github.com/spark/firmware/pull/694

3 Likes