Last Updated on : 2024-06-25 03:48:31download
This topic describes how an IP camera (IPC) is paired by QR code scanning. Pairing with QR code relies on Wi-Fi. The client obtains IPC pairing information from the cloud and creates a QR code that includes details about the IPC pairing and the Wi-Fi network it connects to. The IPC scans the QR code, connects to the Wi-Fi, and communicates with the cloud for activation.
The component app_user_qrcode
is used to start and stop QR code scanning. Steps to process QR code scanning:
event
module of the result to proceed to activate the device and proactively stop QR code scanning.Pairing process on the client:
QR code scanning process
```mermaid
graph TD
b("Start QR code scanning thread") --> x("Get video stream") --> a["Algorithm-based image pre-processing
--> z("Read QR code with ZBar") --> c("Read successfully?") -- --> d("QR code scanning is in progress") -- --> x("Get video stream")
c -- --> y("Send the result to the event module") --> g
d -- --> g("QR code scanning thread ends")
```
The SSID and password of the Wi-Fi network and a token are decoded from the QR code.
{
"p":"hi1234567",
"s":"home_15",
"t":"AYTWEpxSR66CVz"
}
The device connects to the designated Wi-Fi network to access the internet. It then sends the token to the cloud for activation. After successful activation, the device can connect to the MQTT server.
Components
app_sys_msg
: the messaging component.app_sys_net
: used to send the command for pairing with QR code.app_user_event
: used to receive and execute the command for pairing with QR code.app_user_video_capture
: gets the stream and called back in the QR scanning thread.Implement the execution of pairing with QR code in the message receiving thread of the app_user_event
at the application layer.
ty_user_qrcode_start
on receiving E_TY_MSG_SYS_NET_CONFIG_START
to start QR code scanning.ty_user_qrcode_stop
on receiving E_TY_MSG_SYS_NET_CONFIG_STOP
to stop QR code scanning.In the app_sys_net
module at the application layer, implement the callbacks for starting and stopping access point (AP) and then register the callbacks to the Wi-Fi module. This enables you to start and stop pairing with QR code through callbacks.
tkl_wifi_start_ap
callback, configure the AP parameter, start AP, and send E_TY_MSG_SYS_NET_CONFIG_START
to the event
module to start QR code scanning.tkl_wifi_stop_ap
callback, recycle the AP process and send E_TY_MSG_SYS_NET_CONFIG_STOP
to the event
module to stop QR code scanning./**
* @brief Start QR code parsing, which is called during device startup.
*
* @return int
*/
int ty_user_qrcode_start();
/**
* @brief Stop QR code parsing, which is called when parsing is completed.
*
* @return int
*/
int ty_user_qrcode_stop();
Check if:
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback