Skip to content

CircuitHappy/wifi-onboarding

Repository files navigation

Wifi Onboarding

Copyright (C) 2017 Next Thing Co. [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/


SETUP

Clone this repo to your disk.

Install Go if you don't have it

cd in to wifi-onboarding

checkout the 'unstable' branch

Type:

go get github.com/gin-gonic/gin
go get github.com/nextthingco/gonnman
go build

You should now be able to type gadget build and build the wifi-onboarding container

API

Method Path Use
GET /ap/list Returns an array of Service structs.
GET /ap/status Returns a Status struct.
POST /ap/connect Accepts values from a urlencoded form or multipart form. Returns a Status struct.

Example Calls

Request access point list:

curl -H 'Accept: application/json' http://192.168.84.1:8080/ap/list
Protip: You can use any arbitrary address

Example Response:

[
  {
    "Path": "/net/connman/service/<example path>",
    "Name": "<example SSID>",
    "Type": "wifi",
    "State": "idle",
    "Error": "",
    ...
  }
]

Request a connection:

curl -X POST -H 'Accept: application/json' -F 'accessPointPath=<Path here>' -F 'accessPointPassKey=<Password here>' http://192.168.84.1:8080/ap/connect

Example Response:

{
  "has_credentials": true,
  "connecting": true,
  "connected": false,
  "error": nil,
}

Status Struct

  type Status struct {
  HasCredentials bool
  Connecting     bool
  Connected      bool
  Error          error
}

Flow

About

GadgetOS Wifi Onboarding

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published