GithubHelp home page GithubHelp logo

tommy44458 / rpi4-provisioning-ap-wifi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hbaocr/rpi4-provisioning-ap-wifi

0.0 0.0 0.0 84 KB

License: MIT License

Shell 46.80% JavaScript 35.18% HTML 18.01%

rpi4-provisioning-ap-wifi's Introduction

Raspberry 4 provisioning ap wifi using hostapd and dnsmasq

1. Introduction

  • When power on RPI, if their is no wifi connection, the wifi AP will automatically run.( these ssid and password can be modified in ./config_ap/hostapd.conf)
    • SSID : RPIWifiConfig
    • password : 1234567890
  • When connecting to AP the setup page will automatically show off (only test on iphone and Ipad and some android phone). By using this page you can configure to connect to your own AP.

2. Requisition software

  • Setup wifi country code

    sudo raspi-config
    #------>4. Location Options
    #-------------->I4 Change Wi-fi Country
    #---------------------> US United States
    
  • Libs and software packages

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install -y python curl git  build-essential tmux  nano hostapd dnsmasq
    
    # don't  let it done  auto
    # stop  current running instance
    sudo systemctl stop dnsmasq.service
    # disable restart service
    sudo systemctl disable dnsmasq.service 
    
    sudo systemctl stop hostapd
    sudo systemctl unmask hostapd
    sudo systemctl disable hostapd
  • NodeJS v12:

    # install nvm  and nodejs
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
    
    source ~/.bashrc
    
    nvm install v12
    # The  sudo only recognize the PATH  in secure_path in file in /etc/sudoers
    # To see more details : run cmd :  
    # sudo visudo
    # alias node and npm to  /usr/bin sothat thay can be found  and run in sudo mode
    sudo ln -s "$(which node)" /usr/bin/node
    sudo ln -s "$(which node)" /usr/lib/node
    sudo ln -s "$(which npm)"  /usr/bin/npm

3. Install WIFI AP and captiveportal

cd SoftAP
chmod +x  setup.sh 
sudo ./setup.sh 

After running setup you can have your own AP in next reboot. Or if you want to bring it up now to test:

sudo /usr/bin/autohotspot.sh

or

cd bin
sudo ./check_connect_then_start_soft_ap

The more details about setup, this will bring up 3 service:

  • dnsmasg:
    • DHCP server for wifi AP o wlan0
    • Fake DNS server which ressolve all the DNS queries from connected device of this AP to 10.0.0.1, where the nodejs web captiveportal listen on port 10.0.0.1:80
  • hostapd :
    • Once shoot start when powerup : check if no wifi connection on wlan0 then start AP ( wifi Access Point) depend on hostapd application. If having connection, don't start AP mode.
  • captiveportal.service :
    • This is run nodejs express application as wificonfiguration to let user can config the SSID and password of wifi, they want to connect to.
    • This bind on all interface of RPI ( wlan0 and eth0) at port 80
    • Redirect all unhandle uri to root url "/"
    • Only support http ( https may support in future)

Boot process:

  • ./bin/check_connect_then_start_soft_ap.sh : Check wifi in 90 sec, if no wifi connection then run ./bin/start_ap_fork.sh
    • Start hostapd app with config in ./config_ap/hostapd.conf
    • Wait 60 sec then start fake dns serser and dhcpserver on wlan0by running dnsmasq with config in ./config_ap/dnsmasq.conf
  • Start flashpage nodejs webserver with sudo to listen all and create captive Portal the webserver src in CaptivePortal

4. Reference link

rpi4-provisioning-ap-wifi's People

Contributors

hbaocr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.