WiFi Setup
Through the device's API, you can configure the WiFi network for connected WiFi-enabled devices such as P1603 and P1604. However, in practical applications, this is often insufficient as we frequently need to configure WiFi networks for devices that are not yet connected. Hence, the purpose of this guide is to address this requirement.
Methods of WiFi Network Setup
We utilize different methods for WiFi network setup based on WiFi-enabled devices. Broadly, there are two methods: WiFi setup over SmartConfig and WiFi setup over AP. In both cases, it is necessary to put the device into WiFi configuration mode (refer to the device's user manual for specific instructions).
WiFi setup over SmartConfig
The SmartConfig is a provisioning technology developed by TI to connect a new WiFi device to a WiFi network. It uses a mobile app to broadcast the network credentials from a smartphone, or a tablet, to an un-provisioned WiFi device.
The advantage of this technology is that the device does not need to directly know SSID or password of an Access Point (AP). This information is provided using the smartphone. This is particularly important to headless device and systems, due to their lack of a user interface.
Usage
After the device enters the WiFi Configuration Mode, you can send WiFi configuration to the device directly from your phone/tablet via SmartConfig protocol. Here are Android Demo and iOS Demo。
Supported devices
P1603(Ver.0356 and below)
WiFi setup over AP
After the device enters the WiFi configuration mode, it will open a WiFi hotspot (the SSID is YS_XXXXXXXX, where XXXXXX is related to the ID of device) at the same time. After connecting to the hotspot, your client can send WiFi configuration to the device via HTTP protocol.
Usage
- The device enters the WiFi configuration mode.
- The client connects to the WiFi hotspot of the device (no password required).
- Send the network configuration to the device according to the protocol below.
- The device exits the WiFi configuration mode.
Protocol
Note: The Host should be the IP address of the device, usually 192.168.4.1.
Get Network Status
Request:
GET /api/v1/network/state
Response:
Content-Type: application/json
Body:
code: String, The error code; "000000" means success;
data.wifi.ip: String<Optional>, Current IP address of the WiFi, empty means that the WiFi client is not yet connected to any WiFi network;
data.wifi.ssid: String<Optional>, The ssid of current WiFi configuration
data.internet: Bool<Optional>, Whether the device is connected to the Internetï¼›
Scan WiFi Networks
Note:Searching for WiFi networks takes some time, please make the timeout for calling this interface greater than 8 seconds Request:
GET /api/v1/wifi/scan
Response:
Content-Type: application/json
Body:
code: String, The error code; "000000" means success;
data[*].ssid: String, SSID of the WiFi network;
data[*].rssi: Integer, Signal strength of the WiFi network
Setup WiFi
Note:The success of calling this interface only means that the WiFi configuration was sent successfully, please use the Get Network Status interface above to confirm the network status of device.
Request:
POST /api/v1/wifi/sta
Content-Type: application/json
Body:
ssid: String, SSID of target WiFi networkï¼›
pwd: String, Password of target WiFi network;
Response:
Content-Type: application/json
Body:
code: String, The error code; "000000" means success;
Exit WiFi Configuration Mode
Note:Call the interface to take the device out of the wiring state. Ths device will also automatically exit the siring state after 4 minutes
Request:
POST /api/v1/wifi/config/exit
Response:
Content-Type: application/json
Body:
code: String, The error code; "000000" means success;
Supported devices
P1603(Ver.0360 and above),P1604
WiFi setup over AP V2
After the device enters the WiFi configuration mode, it will open a WiFi hotspot (the SSID is YS_XXXXXXXX, where XXXXXX is related to the ID of device) at the same time. After connecting to the hotspot, your client can send WiFi configuration to the device via HTTP protocol.
Usage
- The device enters the WiFi configuration mode.
- The client connects to the WiFi hotspot of the device (no password required).
- Send the network configuration to the device according to the protocol below.
- The device exits the WiFi configuration mode.
Protocol
Note: The Host should be the IP address of the device, usually 192.168.10.1.
Get Network Status
Request:
GET /cgi-bin/api/v1/getNetState
Response:
Content-Type: application/json
Body:
*: Info of ethernet
Scan WiFi Networks
Note:Searching for WiFi networks takes some time, please make the timeout for calling this interface greater than 8 seconds Request:
GET /cgi-bin/api/v1/scan
Response:
Content-Type: application/json
Body:
code: String, The error code; "000000" means success;
data[*].ssid: String, ESSID of the WiFi network;
data[*].bssid: String, BSSID of the WiFi network;
data[*].authType: String, Encryption type of the WiFi network, Please check the Code Map Of WiFi Encryption for detailed info.
data[*].rssi: Integer, Signal strength of the WiFi network
Setup WiFi
Note:The success of calling this interface only means that the WiFi configuration was sent successfully, please use the Get Network Status interface above to confirm the network status of device.
Request:
POST /cgi-bin/api/v1/setWiFiSta
Content-Type: application/json
Body:
ssid: String, ESSID of target WiFi networkï¼›
pwd: String, Password of target WiFi network;
authType: String, Encryption type of the WiFi network;
Response:
Content-Type: application/json
Body:
code: String, The error code; "000000" means success;
Exit AP Mode
The hub will exit AP mode and return to STA mode.
Request:
POST /cgi-bin/api/v1/exitAPMode
Content-Type: application/json
Response:
Content-Type: application/json
Body:
code: String, The error code; "000000" means success;
Supported devices
P1605,P1613