Creating an access point


#1

I am looking to rewrite some of the drivers to allow the photon to act as a wireless access point. Can anyone give me a general overview of what level this would need to be written at (WICED, HAL, wiring), as a well as any pointers on how to get started. Thanks!


#2

Are you thinking of getting devices to connect to the Photon and have internet access?


#3

Correct. I would like the photon to connect to a network, and then be able to host a second network. Anything that connects to the photon would then route their packets to the photon which would forward them to the router.


#4

@tgreerboozin, the Photon was not designed to act as an internet access point.


#5

Are you saying it cannot be done because of the hardware or because of the current low level implementation? If it is the latter, then that is what I’m looking to rewrite.


#6

@tgreerboozin, it sounds like you want to use the Photon as a general wireless AP. You will need to go bare metal with the code since this is not the Photon was designed for. I would suggest you dig into the Cypress (formally Broadcom) WICED library which is used for the WiFi stack.

Perhaps I misunderstand but why exactly do you want to do this with a Photon instead of an RPi Zero W?


#7

I’m doing an internship and they want to give us practice with rewriting extremely low level drivers. I don’t actually have any input as to which chip we use.


#8

From the way he described it, it sounds like they picked this one intentionally because there would be so much code reading and rewriting.


#9

@tgreerboozin, makes sense. The Photon uses the WICED stack to do wifi. It works in conjunction with FreeRTOS. Signing up on the Cypress site will give you access to their code and tools. Good luck!


#10

Thank you for your help!


#11

Help them get the photon to act as a soft Access point even without further network access. That’s been a long neglected feature. I have an app that’s been waiting for it a long time.


#12

@Ed_SanDiego That’s available, there’s a tutorial in the docs for code for this.


#13

Could you be a little more specific? I’ve been keeping an eye out for this, but maybe I’ve been missing it entirely. It would be very welcome to be able to do this. I have a Photon if this makes a difference.

I do not see anything under Tutorials. I do see the SoftHTTP pages reference section, however I thought that reference material was for HTTP-based services, e.g. POST, GET, etc.

What I’m trying to do is have a device connect to the Photon through Photon’s Soft AP. The on-Photon app passes its address to the other-device app and the two can then communicate. I’m familiar with TCP/IP-based communications, sockets, etc. The missing link for me is how to use the SoftAP to connect the two.

Am I missing how the Soft HTTP page could make this connection for me?

Ed


#14

I may not be understanding you, but the softap page can be hosted on the photon, and allows you to connect to your wifi from a web page instead of using the app.


#15

Thank you for the pointer to this. I should have looked harder at it earlier. I think I can make it work. The non-Photon device will have to pass wifi and its local IP credentials to the photon app which can then set all of the parameters.

It does appear that when in SoftAP mode the Photon does not allow non-HTTP traffic to connect. I used the telnet echo sample running on the Photon (port 32). When I had my laptop try to telnet to that Photon’s IP address (when in SoftAP mode), the telnet wouldn’t connect. The telnet echo app works find when the Photon is connected to my house’s wifi.


#16

Have you tried this with SYSTEM_THREAD(ENABLED)?

You are also missing services like DNS and routing in SoftAP, you’d have to do all that in your own code.


#17

Added the following two lines to the device code (lines 2 and 3):

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(AUTOMATIC);

No different in behavior. On my laptop, I am using an IP address with the following command “telnet 192.168.0.1”. I would think this connection would work even if no DNS is available. After all, I can ping 192.168.0.1 successfully. I would also think that no special routing is necessary since I am addressing the device itself and not trying to access some other IP address through the Photon’s SoftAP.

So you believe what I’m trying to do should work? I’m starting to believe the Photon won’t even route to itself while in SoftAP. A minimal routing table while in SoftAP doesn’t sound hard, but not even routing to self sounds like a bug.

I added both of the following to the top of the Telnet Echo program, but I still receive the following from my laptop’s telnet program when trying to telnet to Photon:
Trying 192.168.0.1…
telnet: connect to address 192.168.0.1: Connection refused
telnet: Unable to connect to remote host

For reference, I am using the example code from the Particle Reference docs under TCPServer. I did comment out the lines referring to anything “Serial”. Then I added the two lines mentioned above.

Only other thing I can think of is that my Photon does power-up connected to a Wifi Access Point. I press and hold the SETUP to make it temporarily lose connection to other WiFi.

Last comment: I wonder if it is because the call to TCPServer is in the setup() function. Maybe that TCPServer object needs to be initialized and started in loop(). I’ll play with that. Would be helpful to confirm if this is supposed to work or not though.


#18

Almost anything can be done… The question you need to ask is: should I be doing it. Wifi Repeater costs less than a photon and the hardware is build for it. Considering the photon’s hardware it might just be a little much for the device to handle… You would need the device to connect to a wireless network and have it in AP mode at the same time. From my knowledge of linux (wich is rusty for over 10 years now) it would require you to modify the wifi driver itself as I’m almost sure it’s not able to do this by itself, write the firmware that does the routing, create the ap and connects to the ap. Sounds like to much trouble for something you can buy cheaper than the hardware you are using knowing that it performance will never match. Not saying you won’t be able to do it. But you won’t take 5-10 clients as well and still have the same performance.


#19

I’ve been working with using SYSTEM_THREAD(ENABLED); and also trying to create the TCPServer object in the loop code (with protection to make sure it is called only once). Nothing seems to make the TCPServer connect to an incoming client.

I’m going to conclude that the Particle will NOT route to itself unless it has valid credentials to a different Wifi AP.

The point of this development path is to have a device and a second device (with more CPU) communicate together without anything supporting them, like an external Wifi node. I’ve already got this working fine when using my home or other Wifi.