【问题标题】:Arduino GSM library phonenumber positionArduino GSM库电话号码位置
【发布时间】:2012-05-23 07:27:07
【问题描述】:

使用 Arduino GSM 库获取经过身份验证的呼叫和短信。 我想存储授权电话号码的位置(一个字节)而不是电话号码(很多字节)。

但 GetAuthorizedSms 不给我位置,只给我电话号码

【问题讨论】:

    标签: arduino gsm


    【解决方案1】:

    如果您查看 sms.cpp,您会发现他们使用 gsm.ComparePhoneNumber(i, ph) 将位置 i 上的电话号码与您拥有的电话号码进行比较。

    byte get_phonenr_position(char *ph)
    {
        byte i;
        for(i = 1; i <= 20; i++)
            if (gsm.ComparePhoneNumber(i, ph))
                return i;
        return 0;
    }
    

    应该可以工作,但效率不高,因为您必须通过串行接口询问模块。我在SMSGSM(和CallGSM)类中添加了一个变量last_authorized

    sms.cpp:
                         // phone numbers are identical
                         // authorization is OK
                         // ---------------------------
    +                    last_authorized = i;
                         ret_val = GETSMS_AUTH_SMS;
                         break;  // and finish authorization
                     }
    sms.h:
          char GetAuthorizedSMS(byte position, char *phone_number, char *SMS_text, byte max_SMS_len,
                               byte first_authorized_pos, byte last_authorized_pos);
         char DeleteSMS(byte position);
    +    // set by CallStatusWithAuth
    +    byte last_authorized;
    };
    

    并从我的 SMSGSM 实例中读取该变量。 (对于 CallGSM,我也这样做了)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-09
      相关资源
      最近更新 更多