Abdul Wajid
Posts: 41
Joined: Tue Dec 18, 2018 7:20 am

How to add new network to wpa_supplicant from a web page in Raspbian

Fri Mar 15, 2019 7:41 am

Hi,
I have an web page In which I am getting the
network SSID and PASSWORD

Now I want to add a new network to wpa_supplicant by just pressing a button on a web page

It will be very helpful for me in case you guide me in this topic.

Regards,

B.Goode
Posts: 7553
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How to add new network to wpa_supplicant from a web page in Raspbian

Fri Mar 15, 2019 10:30 am

The Raspberry Pi Foundation documentation is here: https://www.raspberrypi.org/documentati ... ess-cli.md

Specifically, see the section headed "Adding the network details to the Raspberry Pi"

You don't have to use the nano editor: any suitable mechanism for updating the configuration file will be acceptable.

As stated, you need to add a new network section -

Code: Select all

network={
    ssid="testing"
    psk="testingPassword"
}
You have said that you have the new ssid and psk ready to substitute into that template.

Abdul Wajid
Posts: 41
Joined: Tue Dec 18, 2018 7:20 am

Re: How to add new network to wpa_supplicant from a web page in Raspbian

Fri Mar 15, 2019 11:01 am

I have a web form in which i can get ssid and password

My question is that how to get the data from web page to raspberry pi?
B.Goode wrote:
Fri Mar 15, 2019 10:30 am
The Raspberry Pi Foundation documentation is here: https://www.raspberrypi.org/documentati ... ess-cli.md

Specifically, see the section headed "Adding the network details to the Raspberry Pi"

You don't have to use the nano editor: any suitable mechanism for updating the configuration file will be acceptable.

As stated, you need to add a new network section -

Code: Select all

network={
    ssid="testing"
    psk="testingPassword"
}
You have said that you have the new ssid and psk ready to substitute into that template.

B.Goode
Posts: 7553
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How to add new network to wpa_supplicant from a web page in Raspbian

Fri Mar 15, 2019 11:13 am

Please, help the volunteer contributors here to help you...
I have a web form in which i can get ssid and password

My question is that how to get the data from web page to raspberry pi?



A clear statement of the problem will lead the way to a clearer solution..


Does that mean the web server hosting that web service is not running on the Raspberry Pi you are using to implement this project? And that you don't have administrative access to it?


If so, perhaps you will need to resort to 'screen scraping' to access the data. The Beautiful Soup python library might be useful in this context.

Abdul Wajid
Posts: 41
Joined: Tue Dec 18, 2018 7:20 am

Re: How to add new network to wpa_supplicant from a web page in Raspbian

Sat Mar 16, 2019 7:06 am

Its running on Rpi and i have no restriction related to it
B.Goode wrote:
Fri Mar 15, 2019 11:13 am
Please, help the volunteer contributors here to help you...
I have a web form in which i can get ssid and password

My question is that how to get the data from web page to raspberry pi?



A clear statement of the problem will lead the way to a clearer solution..


Does that mean the web server hosting that web service is not running on the Raspberry Pi you are using to implement this project? And that you don't have administrative access to it?


If so, perhaps you will need to resort to 'screen scraping' to access the data. The Beautiful Soup python library might be useful in this context.

epoch1970
Posts: 2646
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to add new network to wpa_supplicant from a web page in Raspbian

Sat Mar 16, 2019 9:33 am

Not clear either with the design.

However: wpa_supplicant supports AFAIK the following facilities for dynamic configuration:
- external: modify the config file and restart the daemon or send it a Unix signal, eg USR1 so that it reloads
- built-in: use wpa_cli to define/change a network and then connect to the new network
- third-party: wpa_supplicant publishes to and receives from D-Bus. Should work the same as wpa_cli, I use D-Bus only under extreme duress and have no experience with this update mode.

HTH
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Abdul Wajid
Posts: 41
Joined: Tue Dec 18, 2018 7:20 am

Re: How to add new network to wpa_supplicant from a web page in Raspbian

Sat Mar 16, 2019 11:39 am

Thanks for your response

Would you like to help me with the code?

Regards,
epoch1970 wrote:
Sat Mar 16, 2019 9:33 am
Not clear either with the design.

However: wpa_supplicant supports AFAIK the following facilities for dynamic configuration:
- external: modify the config file and restart the daemon or send it a Unix signal, eg USR1 so that it reloads
- built-in: use wpa_cli to define/change a network and then connect to the new network
- third-party: wpa_supplicant publishes to and receives from D-Bus. Should work the same as wpa_cli, I use D-Bus only under extreme duress and have no experience with this update mode.

HTH

epoch1970
Posts: 2646
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to add new network to wpa_supplicant from a web page in Raspbian

Sat Mar 16, 2019 12:58 pm

Well, no.
I’m sure you can manage yourself. « man wpa_supplicant » should be a good first step.
Then if you need help as you go along, continue posting questions on the forum.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

B.Goode
Posts: 7553
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How to add new network to wpa_supplicant from a web page in Raspbian

Sat Mar 16, 2019 2:17 pm

Thanks for your response

Would you like to help me with the code?


As the other volunteer who has responded in this thread I too decline that invitation.

Before you or anyone else can write code you need to have a clear idea of the problem and of the steps needed to implement a solution. (Of course, in limited circumstances it is also possible to 'hack' a solution by writing small experimental snippets of code that explore and illuminate aspects of the problem.)

In your case, I suggest the 3 following sub-steps:

Acquire and print out the ssid and psk from the web form (thus proving that you can access this data);

Write those 2 text strings to a trivial text file (thus proving that you can write data to a file);

Include those 2 text strings in a network={... } block and append it to your wpa_supplicant.conf file. Job done.

Return to “Raspbian”