somewhat working config
This commit is contained in:
parent
7c63c76e7a
commit
3f7e695a70
4 changed files with 161 additions and 6 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "lib/TinyGSM"]
|
||||||
|
path = lib/TinyGSM
|
||||||
|
url = git@github.com:lewisxhe/TinyGSM-fork.git
|
||||||
1
lib/TinyGSM
Submodule
1
lib/TinyGSM
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 2aadd8611f0e22d8ba8b8091a1ce6f908ca17425
|
||||||
|
|
@ -8,9 +8,16 @@
|
||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[platformio]
|
||||||
|
default_envs = esp32s3box
|
||||||
|
|
||||||
[env:esp32s3box]
|
[env:esp32s3box]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32s3box
|
board = esp32s3box
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
monitor_speed=115200
|
build_unflags = -DBOARD_HAS_PSRAM
|
||||||
|
board_build.psram_type = disabled
|
||||||
|
lib_deps =
|
||||||
|
vshymanskyy/StreamDebugger@^1.0.1
|
||||||
|
arduino-libraries/ArduinoHttpClient@^0.6.1
|
||||||
|
|
|
||||||
150
src/main.cpp
150
src/main.cpp
|
|
@ -1,11 +1,155 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
void setup() {
|
#define SerialMon Serial0
|
||||||
// put your setup code here, to run once:
|
#define SerialAT Serial1
|
||||||
|
|
||||||
|
#define MODEM_DEBUG
|
||||||
|
|
||||||
|
#ifdef MODEM_DEBUG
|
||||||
|
#define TINY_GSM_DEBUG SerialMon
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TINY_GSM_MODEM_SIM7600
|
||||||
|
#define TINY_GSM_USE_GPRS true
|
||||||
|
#define TINY_GSM_USE_WIFI false
|
||||||
|
#include <TinyGsmClient.h>
|
||||||
|
|
||||||
|
#define MODEM_RX 17
|
||||||
|
#define MODEM_TX 18
|
||||||
|
#define MODEM_BAUD 115200
|
||||||
|
|
||||||
|
const char apn[] = "pwg";
|
||||||
|
|
||||||
|
#ifdef MODEM_DEBUG
|
||||||
|
#include <StreamDebugger.h>
|
||||||
|
StreamDebugger debugger(SerialAT, SerialMon);
|
||||||
|
TinyGsm modem(debugger);
|
||||||
|
#else
|
||||||
|
TinyGsm modem(SerialAT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TinyGsmClient client(modem);
|
||||||
|
|
||||||
|
|
||||||
|
void checkConnection() {
|
||||||
|
SerialMon.println("Pinging httpbin.org...");
|
||||||
|
|
||||||
|
String resolved_ip_addr;
|
||||||
|
uint32_t rep_data_packet_size;
|
||||||
|
uint32_t tripTime;
|
||||||
|
uint8_t TTL;
|
||||||
|
|
||||||
|
int pingResult = modem.ping("httpbin.org", resolved_ip_addr, rep_data_packet_size, tripTime, TTL);
|
||||||
|
if (pingResult == 1) {
|
||||||
|
SerialMon.println("Ping successful!");
|
||||||
|
SerialMon.print("Resolved IP: ");
|
||||||
|
SerialMon.println(resolved_ip_addr);
|
||||||
|
SerialMon.print("Reply Data Packet Size: ");
|
||||||
|
SerialMon.println(rep_data_packet_size);
|
||||||
|
SerialMon.print("Round Trip Time (ms): ");
|
||||||
|
SerialMon.println(tripTime);
|
||||||
|
SerialMon.print("TTL: ");
|
||||||
|
SerialMon.println(TTL);
|
||||||
|
} else {
|
||||||
|
SerialMon.print("Ping failed with result code: ");
|
||||||
|
SerialMon.println(pingResult);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
SerialMon.begin(115200);
|
||||||
|
SerialMon.println("Init...");
|
||||||
|
|
||||||
|
SerialAT.begin(MODEM_BAUD, SERIAL_8N1, MODEM_RX, MODEM_TX);
|
||||||
|
|
||||||
|
delay(3000);
|
||||||
|
|
||||||
|
SerialMon.println("Serial initialized. Now restarting modem...");
|
||||||
|
modem.restart();
|
||||||
|
|
||||||
|
SerialMon.println("Modem restarted. Initializing modem...");
|
||||||
|
|
||||||
|
modem.init();
|
||||||
|
SerialMon.println("Modem initialized.... Modem info:");
|
||||||
|
|
||||||
|
String info = modem.getModemInfo();
|
||||||
|
SerialMon.println(info);
|
||||||
|
|
||||||
|
|
||||||
|
SerialMon.println("Getting SIM status...");
|
||||||
|
|
||||||
|
if (modem.getSimStatus() != SIM_READY) {
|
||||||
|
SerialMon.println("SIM not ready!");
|
||||||
|
while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
SerialMon.println("SIM ready. Setting Network mode...");
|
||||||
|
|
||||||
|
if (!modem.setNetworkMode(MODEM_NETWORK_AUTO)) {
|
||||||
|
Serial.println("Set network mode failed!");
|
||||||
|
}
|
||||||
|
String mode = modem.getNetworkModeString();
|
||||||
|
SerialMon.print("Current network mode : ");
|
||||||
|
SerialMon.println(mode);
|
||||||
|
|
||||||
|
SerialMon.println("Setting APN...");
|
||||||
|
|
||||||
|
if (!modem.setNetworkAPN(apn)) {
|
||||||
|
SerialMon.println("Setting APN failed!");
|
||||||
|
while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
SerialMon.println("APN Set. Waiting for registration...");
|
||||||
|
|
||||||
|
int16_t sq;
|
||||||
|
RegStatus status = REG_NO_RESULT;
|
||||||
|
while (status == REG_NO_RESULT || status == REG_SEARCHING || status == REG_UNREGISTERED) {
|
||||||
|
status = modem.getRegistrationStatus();
|
||||||
|
switch (status) {
|
||||||
|
case REG_UNREGISTERED:
|
||||||
|
case REG_SEARCHING:
|
||||||
|
sq = modem.getSignalQuality();
|
||||||
|
SerialMon.printf("[%lu] Signal Quality:%d\n", millis() / 1000, sq);
|
||||||
|
delay(1000);
|
||||||
|
break;
|
||||||
|
case REG_DENIED:
|
||||||
|
SerialMon.println("Network registration was rejected, please check if the APN is correct");
|
||||||
|
return ;
|
||||||
|
case REG_OK_HOME:
|
||||||
|
SerialMon.println("Online registration successful");
|
||||||
|
break;
|
||||||
|
case REG_OK_ROAMING:
|
||||||
|
SerialMon.println("Network registration successful, currently in roaming mode");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SerialMon.printf("Registration Status:%d\n", status);
|
||||||
|
delay(1000);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String ueInfo;
|
||||||
|
if (modem.getSystemInformation(ueInfo)) {
|
||||||
|
SerialMon.print("Inquiring UE system information:");
|
||||||
|
SerialMon.println(ueInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!modem.setNetworkActive()) {
|
||||||
|
SerialMon.println("Enable network failed!");
|
||||||
|
}
|
||||||
|
delay(5000);
|
||||||
|
|
||||||
|
String ipAddress = modem.getLocalIP();
|
||||||
|
SerialMon.print("Network IP:");
|
||||||
|
SerialMon.println(ipAddress);
|
||||||
|
|
||||||
|
checkConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue