15. 扩展板
15.1 4G扩展板 - Air720/Air724
15.1.1 API介绍
begin() - 确定模块与主板间通信的uart
语法
void begin(HardwareSerial &s_);
参数
传入值 | 说明 | 值范围 |
---|---|---|
s_ | 串口 | 指定为Serial1 |
checkSignalQuality() - 查询信号质量
语法
int checkSignalQuality(void);
返回值
返回值 | 说明 | 值范围 |
---|---|---|
信号质量 | 0:小于等于-115dBm; 1: -111dBm; 2~30: -109~-53dBm: 31: 大于等于-51dBm; 99: 未知或不可测 | int |
attachService() - 使模块附着服务
语法
bool attachService(void);
返回值
返回值 | 说明 | 值范围 |
---|---|---|
模块服务状态 | true 附着成功,有服务,false附着失败,无服务 | true/false |
setBaudRate() - 设置主板与4G模块串口通信的波特率
语法
bool setBaudRate(long rate);
参数
传入值 | 说明 | 值范围 |
---|---|---|
rate | 串口波特率 | 1200、2400、4800、9600、19200、38400、57600、115200、230400、460800、921600、 |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
设置状态 | true 设置成功,false设置失败 | true/false |
checkSIMStatus() - 查询SIMS状态
语法
bool checkSIMStatus(void);
返回值
返回值 | 说明 | 值范围 |
---|---|---|
SIMS状态 | true 表示PIN码锁并未开启,false表示PIN码锁开启 | true/false |
openNetwork() - 建立网络连接
语法
bool openNetwork(Protocol ptl, const char *host, int port);
参数
传入值 | 说明 | 值范围 |
---|---|---|
ptl | 网络连接模式 | TCP\UDP |
host | 远端服务器 | IP 地址 或域名皆可 |
port | 远端服务端口 | int |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
网络连接状态 | true 表示连接成功,false表示连接失败 | true/false |
send() - 发送网络数据
语法
bool send(void *buffer,size_t len);
参数
传入值 | 说明 | 值范围 |
---|---|---|
buffer | 数据 | |
len | 数据长度 |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
发送结果 | true 表示发送成功,false表示发送失败 | true/false |
recv() - 发送网络数据
语法
int recv(char* buf, int maxlen, int timeout);
参数
传入值 | 说明 | 值范围 |
---|---|---|
buf | 接收数据的buffer | |
maxlen | 最大数据长度 | |
timeout | 超时时间 |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
接收的数据长度 | int |
closeNetwork() - 断开网络连接
语法
bool closeNetwork(void);
返回值
返回值 | 说明 | 值范围 |
---|---|---|
网络状态 | true 表示断开成功,false表示断开失败 | bool |
httpInit() - http初始化
语法
bool httpInit();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
http初始化状态 | true 表示初始化成功,false表示初始化失败 | bool |
httpConnect() - 建立http连接
语法
bool httpConnect(const char *Host);
参数
传入值 | 说明 | 值范围 |
---|---|---|
Host | HTTP 或 HTTPS URL |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
http连接状态 | true 表示连接成功,false表示连接失败 | bool |
httpPost() - 上传http信息
语法
bool httpPost(const char *Host , String data);
参数
传入值 | 说明 | 值范围 |
---|---|---|
Host | HTTP 或 HTTPS URL | |
data | 数据 |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
上传数据结果 | 表示post成功,false表示post失败 | bool |
httpGet() - 获取http信息
语法
char * httpGet(const char *Host);
参数
传入值 | 说明 | 值范围 |
---|---|---|
Host | HTTP 或 HTTPS URL |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
获得的数据 | http information |
httpDisconnect() - 断开http连接
语法
void httpDisconnect(void);
mqttDisonnect() - 断开mqtt连接
语法
bool mqttDisonnect();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
mqtt连接状态 | true 表示断开成功,false表示断开失败 | bool |
mqttIPStart() - 建立mqtt的IP连接
语法
bool mqttIPStart(const char *host, int port);
参数
传入值 | 说明 | 值范围 |
---|---|---|
Host | 服务器的ip或者域名 | |
port | 端口号 |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
mqtt IP 连接状态 | 表示连接成功,false表示连接失败 | bool |
mqttIPClose() - 断开mqtt的IP连接
语法
bool mqttIPStart(const char *host, int port);
返回值
返回值 | 说明 | 值范围 |
---|---|---|
mqtt IP 连接状态 | true 表示断开成功,false表示断开失败 | bool |
mqttConnect() - 建立mqtt连接
语法
bool mqttConnect(uint16_t keepalive);
参数
传入值 | 说明 | 值范围 |
---|---|---|
keepalive | 保活时间 时间单位:秒 设备端在保活时间内至少需要发送一次报文,包括PING请求。如果服务器端在保活时间内未接收到任何报文,会断开连接,设备端需要发起重连。建议取值在 300s 以上。 |
<65535 |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
mqtt 连接状态 | true 表示连接成功,false表示连接失败 | bool |
mqttUNSUB() - 取消订阅主题
语法
bool mqttUNSUB(char* iot_topic);
参数
传入值 | 说明 | 值范围 |
---|---|---|
iot_topic | 订阅的主题 | char* |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
取消订阅主题的结果 | true 表示取消成功,false表示取消失败 | bool |
mqttSUB() - 订阅主题
语法
bool mqttSUB(char* iot_topic,int qos);
参数
传入值 | 说明 | 值范围 |
---|---|---|
iot_topic | 订阅的主题 | char* |
qos | 应用程序消息的服务质量 0:at most once delivery for application message 1:at least once delivery for application message 2:exactly once delivery for application message |
0-2 |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
订阅主题的结果 | true 表示订阅成功,false表示订阅失败 | bool |
mqttPUB() - 发布消息
语法
bool mqttPUB(char* iot_topic,int qos,int retain,String str);
参数
传入值 | 说明 | 值范围 |
---|---|---|
iot_topic | 订阅的主题 | char* |
qos | 应用程序消息的服务质量 0:at most once delivery for application message 1:at least once delivery for application message 2:exactly once delivery for application message |
0-2 |
retain | retain flag 0: the server will restore the application meassge and its QoS 1: the server must not restore the application meassge and must not remove or replace any existing retained message |
0-1 |
str | 发布的消息 |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
发布消息的结果 | true 表示发布成功,false表示发布失败 | bool |
mqttConfig() - mqtt通信配置
语法
bool mqttConfig(char* iot_client, char* iot_username, char* iot_key);
参数
传入值 | 说明 | 值范围 |
---|---|---|
iot_client | client identity (最大 256 个字节) | char* |
iot_username | username to login server (最大 256 个字节) | char* |
iot_key | password to login server (最大 256 个字节) | char* |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
发布消息的结果 | true 表示配置成功,false表示配置失败 | bool |
mqttRecv() - mqtt接收订阅主题的消息
语法
bool mqttRecv(char* iot_topic, char* buf,int maxlen);
参数
传入值 | 说明 | 值范围 |
---|---|---|
iot_topic | 主题 | char* |
buf | 接收数据的buffer | char* |
maxlen | 接收最大长度 | int |
返回值
返回值 | 说明 | 值范围 |
---|---|---|
接收消息的结果 | true 表示接收成功,false表示接收失败 | bool |
reset() - 模块重启
语法
bool reset();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
重启命令发送的结果 | true 表示重启命令发送成功,false表示重启命令发送失败 | bool |
factoryDataReset() - 模块回复出厂设置并重启
语法
bool factoryDataReset();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
命令发送的结果 | true 表示命令发送成功,false表示命令发送失败 | bool |
getSIMtype() - 获取 SIM 卡类型
语法
int getSIMtype();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
SIM卡类型 | 0:SIM; 1: USIM。 | 0-1 |
setNTP() - 同步网络时间
语法
int setNTP();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
同步结果 | 1: 网络时间同步成功; 61: 网络错误; 62: DNS 解析错误; 63: 连接错误; 64: 服务响应错误; 65: 服务响应超时; | 0-1 |
getCLK() - 获取时钟
语法
char * getCLK();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
模块系统时间 | char * |
getLocalIP() - 获取本地ip地址
语法
char * getLocalIP();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
IP地址 | char * |
queryModuleModel() - 查询模块型号
语法
char * queryModuleModel();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
模块型号 | char * |
queryModuleVersion() - 查询模块版本信息
语法
char * queryModuleVersion();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
模块版本信息 | char * |
queryIMEI() - 查询 IMEI 号
语法
char * queryIMEI();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
IMEI 号 | char * |
querySIMCardICCID() - 查询 SIM 卡 ICCID 号码
语法
char * querySIMCardICCID();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
ICCID 号码 | char * |
queryFirmWare() - 查询模块 FIRMWARE 版本
语法
char * queryFirmWare();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
FIRMWARE 版本 | char * |
readLBSInformationAndTime() - 读取基站定位(LBS)信息和时间
语法
char * readLBSInformationAndTime();
返回值
返回值 | 说明 | 值范围 |
---|---|---|
基站定位(LBS)信息和时间 | char * |
15.1.2 示例程序
例程1:AT指令透传
/*!
* @file ATTest.ino
* @brief This example use the serial port to send AT command to control the AIR720UH
* With initialization completed, we can enter AT command to AIR720UH directly
* Common AT commands :
* AT+CPIN? : Check SIM card
* AT+CSQ : Check signal quality
* AT+CGATT?: Check net attached state
* AT+CSTT : Start net connect task
* AT+CIFSR : Get local IP
* Get the AT command table in Resource folder :Luat 4G模块AT命令手册V4.3.3.pdf
* Note : The AT command must end with CRLF
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [yangfeng]<feng.yang@dfrobot.com>
* @version V1.0
* @date 2021-08-18
*/
void setup() {
Serial.begin(115200);
while(!Serial);
Serial1.begin(115200);//The 4G module is connected to the Serial1 of the development board
Serial.println("For example, if you type AT\\r\\n, OK\\r\\n will be responsed!");
Serial.println("Enter your AT command :");
}
void loop() {
while(Serial1.available()){
Serial.write(Serial1.read());
}
while(Serial.available()){
Serial1.write(Serial.read());
}
}
例程2: 查询模块基础信息
/*!
* @file basic.ino
* @brief : This example is used to get basic information about the module and SIM card
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [yangfeng]<feng.yang@dfrobot.com>
* @version V1.0
* @date 2021-08-18
*/
#include <DFRobot_AIR720UH.h>
DFRobot_AIR720UH AIR720UH;
void setup(){
int signalStrength,dataNum;
Serial.begin(115200);
Serial1.begin(115200);
while(!Serial);
AIR720UH.begin(Serial1);
char *buff=NULL;
Serial.print("Module Model:");
buff=AIR720UH.queryModuleModel();
if(buff!=NULL){
Serial.println(buff);
}else{
Serial.println("query module model error!");
while(1);
}
Serial.print("Module Version:");
buff=AIR720UH.queryModuleVersion();
if(buff!=NULL){
Serial.println(buff);
}else{
Serial.println("query module version error!");
while(1);
}
Serial.print("IMEI:");
buff=AIR720UH.queryIMEI();
if(buff!=NULL){
Serial.println(buff);
}else{
Serial.println("query IMEI error!");
while(1);
}
Serial.print("Firmware:");
buff=AIR720UH.queryFirmWare();
if(buff!=NULL){
Serial.println(buff);
}else{
Serial.println("query module firmware error!");
while(1);
}
Serial.println("Check SIM card......");
if(AIR720UH.checkSIMStatus()){ //Check SIM card
Serial.println("SIM card READY");
}else{
Serial.println("SIM card ERROR, Check if you have insert SIM card and restart AIR720UH");
while(1);
}
Serial.print("SIM type:");
int data=AIR720UH.getSIMtype();
if(data==1){
Serial.println("USIM");
}else if(data ==0){
Serial.println("SIM");
}else{
Serial.println("get error");
while(1);
}
Serial.print("ICCID:");
buff=AIR720UH.querySIMCardICCID();
if(buff!=NULL){
Serial.println(buff);
}else{
Serial.println("query SIM card ICCID error!");
while(1);
}
Serial.println("Get signal quality......");
delay(500);
signalStrength=AIR720UH.checkSignalQuality(); //Check signal quality
Serial.print("signalStrength =");
Serial.println(signalStrength);
delay(500);
}
void loop(){
}
例程3: http通信
/*!
* @file httpTest.ino
* @brief : This example verify HTTP connection over a HTTP request
* With initialization completed, we connect to server POST data and GET data
* Thus we finished the HTTP POST and GET verification
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [yangfeng]<feng.yang@dfrobot.com>
* @version V1.0
* @date 2021-08-18
*/
#include <DFRobot_AIR720UH.h>
#define POSTURL "https://fanyi.youdao.com/"
#define GETURL "https://fanyi.youdao.com/"
DFRobot_AIR720UH AIR720UH;
void setup(){
int signalStrength,dataNum;
Serial.begin(115200);
while(!Serial);
Serial1.begin(115200);
AIR720UH.begin(Serial1);
Serial.println("Check SIM card......");
if(AIR720UH.checkSIMStatus()){ //Check SIM card
Serial.println("SIM card READY");
}else{
Serial.println("SIM card ERROR, Check if you have insert SIM card and restart AIR720UH");
while(1);
}
Serial.println("Get signal quality......");
signalStrength=AIR720UH.checkSignalQuality(); //Check signal quality
Serial.print("signalStrength =");
Serial.println(signalStrength);
delay(500);
Serial.println("Init http......");
while(1){
if(AIR720UH.httpInit()){ //Init http service
Serial.println("HTTP init !");
break;
}else{
Serial.println("Fail to init http");
}
}
Serial.print("POST to ");
Serial.println(POSTURL);
String httpbuff = "English";
while(1){
if((httpbuff=AIR720UH.httpPost(POSTURL,httpbuff))!=NULL){ //HTTP POST
Serial.println("Post successed");
break;
}else{
Serial.println("Fail to post");
}
}
Serial.print("GET from ");
Serial.println(GETURL);
Serial.println(AIR720UH.httpGet(GETURL)); //HTTP GET
Serial.println("Disconnect");
AIR720UH.httpDisconnect(); //Disconnect
Serial.println("Close net work");
AIR720UH.closeNetwork(); //Close net work
}
void loop() {
}
例程4:TCP通信
/*!
* @file tcpTest.ino
* @brief : This example validates the TCP connection. The module will connect to the TCP server (IP:120.76.100.197 PORT:10002) for data interaction
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [yangfeng]<feng.yang@dfrobot.com>
* @version V1.0
* @date 2021-08-18
*/
#include <Wire.h>
#include <DFRobot_AIR720UH.h>
#define serverIP "120.76.100.197"
#define serverPort 10002
DFRobot_AIR720UH AIR720UH;
char sendData[100];
char buff[100];
void setup(){
int signalStrength,dataNum;
Serial.begin(115200);
Serial1.begin(115200);
while(!Serial);
AIR720UH.begin(Serial1);
Serial.println("Check SIM card......");
if(AIR720UH.checkSIMStatus()){ //Check SIM card
Serial.println("SIM card READY");
}else{
Serial.println("SIM card ERROR, Check if you have insert SIM card and restart AIR720UH");
while(1);
}
Serial.println("Get signal quality......");
delay(500);
signalStrength=AIR720UH.checkSignalQuality(); //Check signal quality
Serial.print("signalStrength =");
Serial.println(signalStrength);
delay(500);
Serial.println("Attaching service......");
while(1){
if(AIR720UH.attachService()){ //Open the connection
Serial.println("Attach service");
Serial.print("Local IP:");
Serial.println(AIR720UH.getLocalIP());
break;
}else{
Serial.println("Fail to Attach service");
delay(1000);
}
}
}
void loop(){
delay(2000);
Serial.println("Connecting......");
if(AIR720UH.openNetwork(TCP,serverIP,serverPort)){ //Start up TCP connection
Serial.println("Connect OK");
}else{
Serial.println("Fail to connect");
return;
}
while(1){
Serial.println("Input data :");
readSerial(sendData);
Serial.println("Send data :");
Serial.println(sendData);
if(AIR720UH.send(sendData,strlen(sendData))){ //Send data to server
Serial.println("Send data, recive :");
AIR720UH.recv(buff,100,5);
Serial.println(buff);
memset(buff,0,100);
}else{
Serial.println("Failed to send");
break;
}
delay(500);
}
Serial.println("Close connection......");
if(AIR720UH.closeNetwork()){ //End the connection
Serial.println("Closed !");
}else{
Serial.println("Fail to close connection");
}
}
int readSerial(char result[]){
int i = 0;
while(1){
while(Serial.available() > 0){
char inChar = Serial.read();
if(inChar == '\n'){
result[i] = '\0';
Serial.flush();
return 0;
}
if(inChar != '\r'){
result[i] = inChar;
i++;
}
}
}
}
例程5:mqtt通信
/*!
* @file mqttTest.ino
* @brief : This example verify MQTT send verification
* With initialization completed, we connect to iot.dfrobot.com.cn
* Then send data to a topic
* Thus we finished the MQTT send verification
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [yangfeng]<feng.yang@dfrobot.com>
* @version V1.0
* @date 2021-08-18
*/
#include <DFRobot_AIR720UH.h>
//Login website (http://iot.dfrobot.com.cn) to register an account ,fill the following information based on your account
#define serverIP "iot.dfrobot.com.cn"
#define IOT_CLIENT "CLIENT_NAME"
#define IOT_USERNAME "YOUR_USERNAME"
#define IOT_KEY "YOUR_KEY"
#define IOT_TOPIC "YOUR_TOPIC"
DFRobot_AIR720UH AIR720UH;
String readSerial(){
int i = 0;
String result;
while(1){
while(Serial.available() > 0){
char inChar = Serial.read();
if(inChar == '\n'){
result += inChar;
while(Serial.read() >= 0);
return result;
}
if(i == 50){
Serial.println("The data is too long");
result += '\0';
while(Serial.read() >= 0);
return result;
}
result += inChar;
i++;
}
}
}
void setup(){
int signalStrength;
Serial.begin(115200);
while(!Serial);
Serial1.begin(115200);
AIR720UH.begin(Serial1);
Serial.println("Check SIM card......");
if(AIR720UH.checkSIMStatus()){ //Check SIM card
Serial.println("SIM card READY");
}else{
Serial.println("SIM card ERROR, Check if you have insert SIM card and restart AIR720UH");
while(1);
}
Serial.println("Get signal quality......");
delay(500);
signalStrength=AIR720UH.checkSignalQuality(); //Check signal quality
Serial.print("signalStrength =");
Serial.println(signalStrength);
delay(500);
Serial.println("Attaching service......");
while(1){
if(AIR720UH.attachService()){ //Open the connection
Serial.println("Attach service");
Serial.print("Local IP:");
Serial.println(AIR720UH.getLocalIP());
break;
}else{
Serial.println("Fail to Attach service");
delay(1000);
}
}
}
void loop(){
if(AIR720UH.mqttConfig(IOT_CLIENT,IOT_USERNAME,IOT_KEY)){
Serial.println("mqttConfig !");
}else{
Serial.println("Failed to mqttConfig");
return;
}
delay(200);
if(AIR720UH.mqttIPStart(serverIP,1883)){ //Config server
Serial.println("mqttIPStart !");
}else{
Serial.println("Failed to mqttIPStart");
AIR720UH.mqttIPClose();
return;
}
Serial.print("Connect to :");
Serial.println(serverIP);
Serial.print("Connect to : ");
Serial.println(IOT_USERNAME);
if(AIR720UH.mqttConnect(60)){ //Connect to server
Serial.println("Connected !");
}else{
Serial.println("Failed to connect");
AIR720UH.mqttDisonnect();
return;
}
if(AIR720UH.mqttSUB(IOT_TOPIC,0)){ //Subscribe to the topic
Serial.println("mqttSUB OK");
}else{
Serial.println("Failed to mqttSUB");
AIR720UH.mqttDisonnect();
return;
}
Serial.println("Input data end with CRLF : ");
String sendData;
sendData= readSerial();
Serial.print("Send data : ");
Serial.print(sendData);
Serial.println(" ......");
if(AIR720UH.mqttPUB(IOT_TOPIC,0,0,sendData)){ //Send data to topic
Serial.println("Send OK");
}else{
Serial.println("Failed to send");
AIR720UH.mqttDisonnect();
return;
}
delay(1000);
char buf[128];
if(AIR720UH.mqttRecv(IOT_TOPIC,buf,128)){
Serial.println("Received a message about the subscription topic:");
Serial.print(buf);
memset(buf,0,sizeof(buf));
}
delay(200);
if(AIR720UH.mqttDisonnect()){ //Close connection
Serial.println("Close connection !");
}else{
Serial.println("Fail to close connection !");
return;
}
delay(2000);
}
例程6:获取基站位置和时间信息
/*!
* @file readLBSInformationAndTime.ino
* @brief : Read base station location (LBS) information and time
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [yangfeng]<feng.yang@dfrobot.com>
* @version V1.0
* @date 2021-08-18
*/
#include <DFRobot_AIR720UH.h>
DFRobot_AIR720UH AIR720UH;
void setup(){
int signalStrength,dataNum;
Serial.begin(115200);
Serial1.begin(115200);
while(!Serial);
AIR720UH.begin(Serial1);
Serial.println("Check SIM card......");
if(AIR720UH.checkSIMStatus()){ //Check SIM card
Serial.println("SIM card READY");
}else{
Serial.println("SIM card ERROR, Check if you have insert SIM card and restart AIR720UH");
while(1);
}
Serial.println("Get signal quality......");
delay(500);
signalStrength=AIR720UH.checkSignalQuality(); //Check signal quality
Serial.print("signalStrength =");
Serial.println(signalStrength);
delay(500);
Serial.println("Base station location (LBS) information and time:");
}
void loop(){
char *buff=AIR720UH.readLBSInformationAndTime();
if(buff!=NULL){
Serial.println(buff);
}
delay(1000);
}
例程7:获取网络时间
/*!
* @file setNTP.ino
* @brief : Synchronizing network Time
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [yangfeng]<feng.yang@dfrobot.com>
* @version V1.0
* @date 2021-08-18
*/
#include <DFRobot_AIR720UH.h>
DFRobot_AIR720UH AIR720UH;
void setup(){
int signalStrength,dataNum;
Serial.begin(115200);
Serial1.begin(115200);
while(!Serial);
AIR720UH.begin(Serial1);
Serial.println("Check SIM card......");
if(AIR720UH.checkSIMStatus()){ //Check SIM card
Serial.println("SIM card READY");
}else{
Serial.println("SIM card ERROR, Check if you have insert SIM card and restart AIR720UH");
while(1);
}
Serial.println("Get signal quality......");
delay(500);
signalStrength=AIR720UH.checkSignalQuality(); //Check signal quality
Serial.print("signalStrength =");
Serial.println(signalStrength);
delay(500);
Serial.println("set NTP ...");
while(1){
int data=AIR720UH.setNTP();
if(data==1){
Serial.println("The network time is synchronized successfully!");
break;
}else if(data ==61){
Serial.println("Network error");
break;
}else if(data ==62){
Serial.println("DNS resolution error");
break;
}else if(data ==63){
Serial.println("Connection error");
break;
}else if(data ==64){
Serial.println("Service response error");
break;
}else if(data ==65){
Serial.println("Service response time out");
break;
}else{
Serial.println("set error");
}
}
}
void loop(){
char *buff = AIR720UH.getCLK();
if(buff!=NULL){
Serial.println(buff);
}
}