我正在尝试使用 Cavlii C16Qs 进行 ESP32 的 OTA 固件更新。我正在尝试使用 Cavlii C16Qs 将互联网与 ESP32 连接。基本上问题是我无法使用“AT+PPPSTART”和 Cavli C16Qs 调制解调器获得互联网连接。 Cavlii C16Qs 用于提供 LTE 网络。我正在尝试使用“AT+PPPSTART”命令进行互联网连接。 https://cavli.atlassian.net/servicedesk/customer/portal/8/topic/6c7a6bd9-155b-4438-84bb-4807e4f8db19/article/343015460 这是AT命令详细信息文档的链接。那么我应该在下面的代码中更改什么,以便 esp 32 可以通过 Cavlii C16Qs 获得互联网连接?这样我就可以从服务器获取固件文件。
目标:使用外部调制解调器互联网连接、HTTP.h 和 Update.h 库的 ESP32 OTA。
Arduino IDE版本:1.8.19 ESP32 开发板版本:2.0.0
Serial 用于调试,Serial1 用于与 Cavlii C16Qs 进行串行通信。
#include <HTTPClient.h>
#include <update.h>
/* Cavli_C16QS */
String response = "";
const char *ipAddr;
String st1;
int value1, value2;
int clientID;
void setup() {
// Power up the ESP32 by toggling the PWRKEY pin
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
delay(100);
digitalWrite(2, HIGH);
Serial.begin(115200);
Serial1.begin(115200, SERIAL_8N1, 32, 33); // RX, TX
//////////////////////////////////
// Send AT command via Serial to Cavli module
Serial.println("Sending ATI command to Cavli module");
Serial.println("==================================");
Serial1.print("ATI"); // Send command via Serial2
// FeedBack();
delay(1000);
while (Serial1.available()) {
char c = Serial1.read();
Serial.print(c);
}
Serial.println("Sending AT+COPS?");
//////////////////////////////////
// Read and print responses from Cavli module via Serial2
while (!(response.indexOf("+ATREADY") != -1 || response.indexOf("OK") != -1)) {
Serial1.print("AT+COPS?\r\n");
while (Serial1.available()) {
char c = Serial1.read();
response += c;
}
Serial.print("response-->");
Serial.println(response);
}
delay(1000); // Add a delay after sending the command
response = "";
//////////////////////////////////
value1 = value2 = -1;
Serial.println("Sending AT command... +CEREG? Checking network connectivity");
while (!(value1 == 0 && (value2 == 1 || value2 == 5))) {
Serial1.write("AT+CEREG?\r\n");
delay(500);
while (Serial1.available()) {
char c = Serial1.read();
response += c;
}
Serial.print("response-->");
Serial.println(response);
response = "";
}
delay(5000); // Add a delay after sending the command
response = "";
//////////////////////////////////
value1 = value2 = -1;
Serial.println("Sending AT command... +CGACT? Checking internet connectivity");
while (!(value1 == 1 && value2 == 1)) {
Serial1.write("AT+CGACT?\r\n");
delay(500);
while (Serial1.available()) {
char c = Serial1.read();
response += c;
}
Serial.print("response-->");
Serial.println(response);
response = "";
}
//////////////////////////////////
delay(500); // Add a delay after sending the command
response = "";
Serial.println("Sending AT+NETIF?");
Serial1.print("AT+NETIF?\r\n"); // Send command via Serial2
// Read and print responses from Cavli module via Serial2
while (Serial1.available()) {
char c = Serial1.read();
response += c;
}
Serial.print("response-->");
Serial.println(response);
response = "";
Serial.println("Sending AT+PPPSTART");
Serial1.print("AT+PPPSTART=?\r\n"); // Send command via Serial2
// Read and print responses from Cavli module via Serial2
while (Serial1.available()) {
char c = Serial1.read();
response += c;
}
Serial.print("response-->");
Serial.println(response);
response = "";
String _url = url_OTA_code_head + code_ver + url_OTA_code_tail;
delay(2000);
HTTPClient http;
http.begin(_url);
int httpCode = http.GET();
Serial.println(httpCode);
Serial.println("----------------------------End Setup----------------------------");
}
void loop() {
// put your main code here, to run repeatedly:
}
例如,请点击以下链接