*/
errcode_t ppp_api_update_imei(void)
{
+ // 检查是否在AT模式
+ if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) {
+ PPP_DEBUG_WARN("Cannot update IMEI: not in AT mode (current mode: %d)", ppp_serial_get_mode());
+ return ERRCODE_FAIL;
+ }
+
char *response = (char *)malloc(512); // 动态分配内存
if (response == NULL) {
PPP_DEBUG_ERROR("Failed to allocate memory for AT response");
*/
errcode_t ppp_api_update_signal(void)
{
+ // 检查是否在AT模式
+ if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) {
+ PPP_DEBUG_WARN("Cannot update signal: not in AT mode (current mode: %d)", ppp_serial_get_mode());
+ return ERRCODE_FAIL;
+ }
+
char *response = (char *)malloc(512); // 动态分配内存
if (response == NULL) {
PPP_DEBUG_ERROR("Failed to allocate memory for AT response");
*/
errcode_t ppp_api_update_operator(void)
{
+ // 检查是否在AT模式
+ if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) {
+ PPP_DEBUG_WARN("Cannot update operator: not in AT mode (current mode: %d)", ppp_serial_get_mode());
+ return ERRCODE_FAIL;
+ }
+
char *response = (char *)malloc(512); // 动态分配内存
if (response == NULL) {
PPP_DEBUG_ERROR("Failed to allocate memory for AT response");
*/
errcode_t ppp_api_update_iccid(void)
{
+ // 检查是否在AT模式
+ if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) {
+ PPP_DEBUG_WARN("Cannot update ICCID: not in AT mode (current mode: %d)", ppp_serial_get_mode());
+ return ERRCODE_FAIL;
+ }
+
char *response = (char *)malloc(512); // 动态分配内存
if (response == NULL) {
PPP_DEBUG_ERROR("Failed to allocate memory for AT response");
*/
errcode_t ppp_api_update_version(void)
{
+ // 检查是否在AT模式
+ if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) {
+ PPP_DEBUG_WARN("Cannot update version: not in AT mode (current mode: %d)", ppp_serial_get_mode());
+ return ERRCODE_FAIL;
+ }
+
char *response = (char *)malloc(512); // 动态分配内存
if (response == NULL) {
PPP_DEBUG_ERROR("Failed to allocate memory for AT response");
*/
errcode_t ppp_api_update_network_status(void)
{
+ // 检查是否在AT模式
+ if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) {
+ PPP_DEBUG_WARN("Cannot update network status: not in AT mode (current mode: %d)", ppp_serial_get_mode());
+ return ERRCODE_FAIL;
+ }
+
char *response = (char *)malloc(512); // 动态分配内存
if (response == NULL) {
PPP_DEBUG_ERROR("Failed to allocate memory for AT response");
*/
errcode_t ppp_api_update_sim_status(void)
{
+ // 检查是否在AT模式
+ if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) {
+ PPP_DEBUG_WARN("Cannot update SIM status: not in AT mode (current mode: %d)", ppp_serial_get_mode());
+ return ERRCODE_FAIL;
+ }
+
char *response = (char *)malloc(512); // 动态分配内存
if (response == NULL) {
PPP_DEBUG_ERROR("Failed to allocate memory for AT response");
return ERRCODE_FAIL;
}
+ // 检查是否在AT模式
+ if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) {
+ PPP_DEBUG_WARN("Cannot get network signal info: not in AT mode (current mode: %d)", ppp_serial_get_mode());
+ return ERRCODE_FAIL;
+ }
+
PPP_DEBUG_INFO("Getting network signal information...");
ppp_network_signal_info_t signal_info;
processed_frames++;
processed_bytes += frame->length;
- // 更新处理统计
+ // 更新处理统计(统计实际传递给lwIP的字节数,但排除我们添加的0x7E)
g_ppp_discard_stats.total_frames_processed++;
- g_ppp_discard_stats.total_bytes_processed += frame->length;
+ // 减去我们添加的额外0x7E标志(每帧最多添加1个)
+ uint32_t original_bytes = frame->length;
+ if (frame->length > 0 && frame->data[frame->length-1] == 0x7E) {
+ original_bytes--; // 减去结束时添加的0x7E
+ }
+ g_ppp_discard_stats.total_bytes_processed += original_bytes;
// 释放帧内存
free(frame->data);