Wifi Listening mode and TCP socket - Particle photon

photon
Tags: #<Tag:0x00007f1ca14be988>

#1

Hi guys,
I am working on particle photon to establish a local TCP socket connection with my laptop. So I can send back and forth some data between the two devices.
Referring through softAP documentations, I decided to put my photon in listening mode, connect my laptop to that AP and use a TCP server-client socket connection. Simple!
But, my client(laptop) is acknowledging it got connected to 192.168.0.1:80 server successfully, although I am unable to send data from photon(server) to laptop!

SoftAP HTTP/HTML example is working fine. (Assuming it is only utilizing the facility to give wifi credentials, which the listening mode is restricted to.?)

Is this TCP issue due to any specific restriction on photon?


#2

@iotbang, in answer to your question, DeviceOS has enough TCP capabilities to work as you wish.

To assist, with the issue

I am unable to send data from photon(server) to laptop!

you will will need to the architecture of the application running on the laptop (TCP Client).

For the TCP server to communicate back to the TCP Client, the socket will need to be open ie the TCP client establishes a connection to the TCP server and keeps the socket open so that the TCP server can send back data.

Does this make sense?


#3

@UMD , Yes I have a client running on my PC.

If I do the reverse, ie., connecting photon as a client to the server running in Laptop everything is okay. The vice versa also.

I was trying a different approach. No common router! Just Photon and PC, like wifi direct.
For that, I tried to connect the laptop to listening Photon(Photon as hotspot). In this local network, I was able to give wifi credentials through port 80 of photon(using softAP http).

Simultaneously I tried running a TCP server in my particle firmware, at a different port. The result was failure. Nothing was going on.

If I make it port 80 and run a server in the photon
(server IP will be given gateway IP eg., xxx.xxx.x.1, the photon IP visible in ip scanners):
TCPServer server = TCPServer(80);
My client running in laptop was atleast acknowledging a connection with server. But nothing else, no further transfer happening.

So I assume eventhough the system thread is enabled SYSTEM_THREAD(ENABLE);
there are some restriction in wifi listening mode.

Or any other viewpoint to the problem?


#4

In the early days I did also try something similar but didn’t succeed and got some Particle statements that it should work but others that it won’t so I just gave up on that :blush:


#5

@ScruffR Oh! Then how did you solve the issue.? Any alternative.? :thinking:


#6

Since I don’t quite understand your needs it’s hard to advise.
However, I decided against using TCP at all but added my own SoftAP HTTP pages.


#7

@ScruffR Ok. I think softAP HTTP is not going to work out for my case.
My use case is to get all the sensor data by wireless to my terminal, this will be a backup if my internet is down(just in case).
Right now I have to connect my photon via USB, then get all the data by accessing serial port.
My current workaround is getting IP through mac id, get the local IP, then establish a TCP connection. It is working out. But the current approach we are discussing will avoid a third part router/hotspot. I can do transfer like WiFi direct.

Finding any resolution through the softAP method.?


#8

Not dismissing your needs but …

… what do you mean by your internet going down.
If your ISP is not reachable your local WiFi would still be available, wouldn’t it?
And even if not, you could still use your mobile hotspot (smart phone) as a secondary WAP for your Photon.


#9

Yes, I can provide internet through a secondary method. But to access it through local network or wifi-direct mode is the more prior use case. A more convenient standalone device.