外观
接收模式
✅ 验证码内容自动识别并显示服务商
✅ 支持接收设备关机期间的短信
✅ 对于长短信内容实现自动组合
✅ 接收显示日期,时间,电话,短信内容自动滚屏播放
转发模式
✅ 支持将接收到的短信内容转发到HTTP网络中,借助API实现微信推送,邮箱推送等(需要网络)
✅ 支持将接收到的短信内容借助SMS转发到另一号码中(无需网络)
其他外设功能
✅ 接收界面可通过按键打断自动滚屏,改为手动滚屏和接收确认
✅ 开机时播放音效,来信时提醒
✅ 收到消息时开启背光,消息已读后关闭
✅ 支持RNDIS网卡,随时4G上网
WEB管理后台
✅ 联网后进入192.168.4.1进入后台管理页
✅ 支持对转发的功能配置
✅ 支持对提示音的功能配置
✅ 支持对背光的功能配置
✅ 支持收件箱功能,显示接收历史消息
软件开发
BSP 模块
本项目采用功能模块化。
- config_manager.h/.cpp: 数据存储器类
- config.h: IO定义及软件配置
- display.h/.cpp: 屏幕显示类
- lte_module.h/.cpp: LTE模组通讯类
- http_client.h/.cpp: HTTP请求类
- sms_types.h: 短信的数据接口定义
- speaker.h/.cpp: 蜂鸣器类
- web_server.h/.cpp: web服务器类
- wifi_manager.h/.cpp: wifi管理类
- main.cpp: 程序主入口
核心模块
config_manager.h
config_manager 存储类
此类用于将配置数据存储进非易失存储器,避免断电后掉电
#ifndef CONFIG_MANAGER_H
#define CONFIG_MANAGER_H
#include <Preferences.h>
#include <Arduino.h>
// 配置管理类
class ConfigManager {
public:
ConfigManager();
// 加载配置
void load();
// 保存配置
void save();
// 检查是否已配置
bool isConfigured() const;
// 设置配置完成标志
void setConfigured(bool configured);
// WiFi配置
String wifiSSID;
String wifiPassword;
// HTTP配置
String httpMethod;
String httpUrl;
bool httpForwardEnabled;
// 短信转发配置
bool smsForwardEnabled;
String smsForwardNumber;
// 显示配置
int backlightBrightness;
int backlightMode; // 0=关闭, 1=常亮, 2=收到消息时开启
private:
Preferences preferences;
};
#endif
config.h
config.h 板级配置文件
板级配置文件,用于配置IO引脚定义及其他自定义配置
#ifndef CONFIG_H
#define CONFIG_H
// 硬件引脚定义
// ST7920显示屏引脚
#define LCD_CLK 4 // IO4 - 时钟
#define LCD_MOSI 6 // IO6 - 数据
#define LCD_CS 7 // IO7 - 片选
// 按键引脚
#define BTN_LEFT 1 // IO1 - 收信模式按键
#define BTN_MID 2 // IO2 - 确定按键
#define BTN_RIGHT 3 // IO3 - 转发模式按键
// 蜂鸣器引脚
#define BTN_SPK 5 // IO5 - 蜂鸣器
// 背光引脚
#define LCD_BACKLIGHT 0 // IO0 - 背光控制
// 背光模式
enum BacklightMode {
BACKLIGHT_OFF = 0, // 关闭
BACKLIGHT_ALWAYS_ON = 1, // 常亮
BACKLIGHT_ON_MESSAGE = 2 // 收到消息时开启
};
// 显示配置
#define MAX_DISPLAY_WIDTH 128
#define SCROLL_DELAY 150
#define SCROLL_STEP 2
// 通信配置
#define SERIAL_BAUD 115200
#define AT_TIMEOUT 2000
// HTTP配置
#define MIN_SEND_INTERVAL 5000 // 最小发送间隔(ms)
// 时间同步配置
#define TIME_SYNC_INTERVAL 60000 // 时间同步间隔(1分钟)
// WiFi配置
#define AP_SSID "EDA-Pager"
#define AP_PASSWORD "12345678"
#define WEB_SERVER_PORT 80
#endif
display.h
display.h 显示类
定义了一些屏幕显示部分的功能
#ifndef DISPLAY_H
#define DISPLAY_H
#include <U8g2lib.h>
#include "sms_types.h"
// 显示管理类
class Display {
public:
Display();
// 初始化显示屏
void begin();
// 显示短信内容(带滚动)
void showSms(const SmsData& sms);
// 手动滚动控制
void scrollLeft(int step = 10); // 向左滚动(文本向左移动)
void scrollRight(int step = 10); // 向右滚动(文本向右移动)
void enableAutoScroll(); // 启用自动滚动
void disableAutoScroll(); // 禁用自动滚动
bool isAutoScrollEnabled(); // 检查是否启用自动滚动
// 显示等待消息
void showWaiting(WorkMode mode, const String& date, const String& time);
// 显示文本消息
void showMessage(const String& line1, const String& line2 = "", const String& line3 = "");
// 显示配置信息
void showConfigInfo(const String& apIP, const String& staIP, bool wifiConnected);
// 显示验证码
void showVerificationCode(const String& code, const String& sender);
// 背光控制
void setBacklightMode(int mode);
void updateBacklight();
void turnOnBacklight();
void turnOffBacklight();
private:
U8G2_ST7920_128X64_F_SW_SPI u8g2;
int scrollOffset;
unsigned long lastScrollTime;
int backlightBrightness;
bool autoScrollEnabled; // 自动滚动开关
int maxScrollOffset; // 最大滚动偏移量
int backlightMode; // 背光模式
unsigned long backlightOnTime; // 背光开启时间
bool backlightOn; // 背光状态
};
#endif
http_client.h / lte_module.h / sms_types.h / speaker.h / web_server.h / wifi_manager.h
其他核心模块
完整源码请在附件查看,包含HTTP客户端、LTE模组通讯、短信类型定义、蜂鸣器控制、Web服务器和WiFi管理等模块的完整实现。
实现原理
本项目基于ESP32C3和ML307C LTE模组,实现了完整的短信接收、显示、转发功能。系统采用模块化设计,各功能模块独立实现,便于维护和扩展。