亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gsm_at.c

?? Gsm手機(短信息,電話簿)開發庫C++源代碼
?? C
字號:
// *************************************************************************
// * GSM TA/ME library
// *
// * File:    gsm_at.cc
// *
// * Purpose: Utility classes for AT command sequence handling
// *
// * Author:  Peter Hofmann (software@pxh.de)
// *
// * Created: 3.5.1999
// *************************************************************************

#ifdef HAVE_CONFIG_H
#include <gsm_config.h>
#endif
#include <gsmlib/gsm_at.h>
#include <gsmlib/gsm_nls.h>
#include <gsmlib/gsm_util.h>
#include <gsmlib/gsm_error.h>
#include <gsmlib/gsm_event.h>
#include <gsmlib/gsm_me_ta.h>
#include <ctype.h>
#include <strstream>

using namespace std;
using namespace gsmlib;

// GsmAt members

bool GsmAt::matchResponse(string answer, string responseToMatch)
{
  if (answer.substr(0, responseToMatch.length()) == responseToMatch)
    return true;
  else
    // some TAs omit the ':' at the end of the response
    if (_meTa.getCapabilities()._omitsColon &&
        responseToMatch[responseToMatch.length() - 1] == ':' &&
        answer.substr(0, responseToMatch.length() - 1) == 
        responseToMatch.substr(0, responseToMatch.length() - 1))
      return true;
  return false;
}

string GsmAt::cutResponse(string answer, string responseToMatch)
{
  if (answer.substr(0, responseToMatch.length()) == responseToMatch)
    return normalize(answer.substr(responseToMatch.length(),
                                   answer.length() -
                                   responseToMatch.length()));
  else
    // some TAs omit the ':' at the end of the response
    if (_meTa.getCapabilities()._omitsColon &&
        responseToMatch[responseToMatch.length() - 1] == ':' &&
        answer.substr(0, responseToMatch.length() - 1) == 
        responseToMatch.substr(0, responseToMatch.length() - 1))
      return normalize(answer.substr(responseToMatch.length() - 1,
                                     answer.length() -
                                     responseToMatch.length() + 1));
  assert(0);
  return "";
}

void GsmAt::throwCmeException(string s) throw(GsmException)
{
  if (matchResponse(s, "ERROR"))
    throw GsmException(_("unspecified ME/TA error"), ChatError);

  bool meError = matchResponse(s, "+CME ERROR:");
  if (meError)
    s = cutResponse(s, "+CME ERROR:");
  else
    s = cutResponse(s, "+CMS ERROR:");
  istrstream is(s.c_str());
  int error;
  is >> error;
  throw GsmException(_("ME/TA error '") +
                     (meError ? getMEErrorText(error) :
                      getSMSErrorText(error)) +
                     "' " +
                     stringPrintf(_("(code %s)"), s.c_str()),
                     ChatError, error);
}

GsmAt::GsmAt(MeTa &meTa) :
  _meTa(meTa), _port(meTa.getPort()), _eventHandler(NULL)
{
}

string GsmAt::chat(string atCommand, string response,
                   bool ignoreErrors, bool acceptEmptyResponse)
  throw(GsmException)
{
  string dummy;
  return chat(atCommand, response, dummy, ignoreErrors, false,
              acceptEmptyResponse);
}

string GsmAt::chat(string atCommand, string response, string &pdu,
                   bool ignoreErrors, bool expectPdu,
                   bool acceptEmptyResponse) throw(GsmException)
{
  string s;
  bool gotOk = false;           // special handling for empty SMS entries

  // send AT command
  putLine("AT" + atCommand);
  // and gobble up CR/LF (and possibly echoed characters if echo can't be
  // switched off)
  do
  {
    s = normalize(getLine());
  }
  while (s.length() == 0);

  // handle errors
  if (matchResponse(s, "+CME ERROR:") || matchResponse(s, "+CMS ERROR:"))
    if (ignoreErrors)
      return "";
    else
      throwCmeException(s);
  if (matchResponse(s, "ERROR"))
    if (ignoreErrors)
      return "";
    else
      throw GsmException(_("ME/TA error '<unspecified>' (code not known)"), 
                         ChatError, -1);

  // return if response is "OK" and caller says this is OK
  if (acceptEmptyResponse && s == "OK")
    return "";

  // handle PDU if one is expected
  if (expectPdu)
  {
    string ps;
    do
    {
      ps = normalize(getLine());
    }
    while (ps.length() == 0 && ps != "OK");
    if (ps == "OK")
      gotOk = true;
    else
    {
      pdu = ps;
      // remove trailing zero added by some devices (e.g. Falcom A2-1)
      if (pdu.length() > 0 && pdu[pdu.length() - 1] == 0)
        pdu.erase(pdu.length() - 1);
    }
  }

  // handle expected response
  if (response.length() == 0)   // no response expected
  {
    if (s == "OK") return "";
    // else fall through to error
  }
  else
  {
    string result;
    // some TA/TEs don't prefix their response with the response string
    // as proscribed by the standard: just handle either case
    if (matchResponse(s, response))
      result = cutResponse(s, response);
    else
      result = s;

    if (gotOk)
      return result;
    else
    {
      // get the final "OK"
      do
      {
        s = normalize(getLine());
      }
      while (s.length() == 0);

      if (s == "OK") return result;
      // else fall through to error
    }
  }
  throw GsmException(
    stringPrintf(_("unexpected response '%s' when sending 'AT%s'"),
                 s.c_str(), atCommand.c_str()),
    ChatError);
}

vector<string> GsmAt::chatv(string atCommand, string response,
                            bool ignoreErrors) throw(GsmException)
{
  string s;
  vector<string> result;

  // send AT command
  putLine("AT" + atCommand);
  // and gobble up CR/LF (and possibly echoed characters if echo can't be
  // switched off)
  do
  {
    s = normalize(getLine());
  }
  while (s.length() == 0);

  // handle errors
  if (matchResponse(s, "+CME ERROR:") || matchResponse(s, "+CMS ERROR:"))
    if (ignoreErrors)
      return result;
    else
      throwCmeException(s);
  if (matchResponse(s, "ERROR"))
    if (ignoreErrors)
      return result;
    else
      throw GsmException(_("ME/TA error '<unspecified>' (code not known)"), 
                         ChatError, -1);

  // push all lines that are not empty
  // cut response prefix if it is there
  // stop when an OK line is read
  while (1)
  {
    if (s == "OK")
      return result;
    // some TA/TEs don't prefix their response with the response string
    // as proscribed by the standard: just handle either case
    if (response.length() != 0 && matchResponse(s, response))
      result.push_back(cutResponse(s, response));
    else
      result.push_back(s);
    // get next line
    do
    {
      s = normalize(getLine());
    }
    while (s.length() == 0);
  }

  // never reached
  assert(0);
  return result;
}

string GsmAt::normalize(string s)
{
  size_t start = 0, end = s.length();
  bool changed = true;

  while (start < end && changed)
  {
    changed = false;
    if (isspace(s[start]))
    {
      ++start;
      changed = true;
    }
    else
      if (isspace(s[end - 1]))
      {
        --end;
        changed = true;
      }
  }
  return s.substr(start, end - start);
}

string GsmAt::sendPdu(string atCommand, string response,
                      string pdu) throw(GsmException)
{
  string s;
  bool errorCondition = false;
  bool retry = false;

  int c;
  do
  {
    putLine("AT" + atCommand);
    // read first of two bytes "> "
    c = readByte();
    
    if (c == '+' || c == 'E')   // error or unsolicited result code
    {
      _port->putBack(c);
      s = normalize(getLine());
      errorCondition = (s != "");
      
      retry = ! errorCondition;
      // The following code is for the unlikely case that the TA wants
      // to resume PDU sending after an unsolicited result code.
      // For the time being I have decided that it is better to retry
      // in this case.
//       if (! errorCondition)
//       {
//         // readByte() times out after TIMEOUT_SECS (gsm_port.h) seconds 
//         try
//         {
//           c = readByte();
//           retry = c != '>';     // TA still expects PDU if c == '>'
//           if (retry)
//              _port->putBack(c);
//         }
//         catch (GsmException &e)
//         {
//           retry = true;         // TA does not expect PDU anymore, retry
//         }
//       }
    }
  }
  while (retry);

  if (! errorCondition)
  {
    
    if (c != '>' || readByte() != ' ')
      throw GsmException(_("unexpected character in PDU handshake"),
                         ChatError);
    
    putLine(pdu + "\032", false); // write pdu followed by CTRL-Z
    do
    {
      s = normalize(getLine());
    }
    while (s.length() == 0 || s == pdu);
  }

  // handle errors
  if (matchResponse(s, "+CME ERROR:") || matchResponse(s, "+CMS ERROR:"))
    throwCmeException(s);
  if (matchResponse(s, "ERROR"))
    throw GsmException(_("ME/TA error '<unspecified>' (code not known)"), 
                       ChatError, -1);

  if (matchResponse(s, response))
  {
    string result = cutResponse(s, response);
    // get the final "OK"
    do
    {
      s = normalize(getLine());
    }
    while (s.length() == 0);

    if (s == "OK") return result;
    // else fall through to error
  }
  throw GsmException(
    stringPrintf(_("unexpected response '%s' when sending 'AT%s'"),
                 s.c_str(), atCommand.c_str()),
    ChatError);
}

string GsmAt::getLine() throw(GsmException)
{
  if (_eventHandler == (GsmEvent*)NULL)
    return _port->getLine();
  else
  {
    bool eventOccurred;
    string result;
    do
    {
      eventOccurred = false;
      result = _port->getLine();
      string s = normalize(result);
      if (matchResponse(s, "+CMT:") ||
          matchResponse(s, "+CBM:") ||
          matchResponse(s, "+CDS:") ||
          matchResponse(s, "+CMTI:") ||
          matchResponse(s, "+CBMI:") ||
          matchResponse(s, "+CDSI:") ||
          matchResponse(s, "RING") ||
          // hack: the +CLIP? sequence returns +CLIP: n,m
          // which is NOT an unsolicited result code
          (matchResponse(s, "+CLIP:") && s.length() > 10))
      {
        _eventHandler->dispatch(s, *this);
        eventOccurred = true;
      }
    }
    while (eventOccurred);
    return result;
  }
}

void GsmAt::putLine(string line,
                    bool carriageReturn) throw(GsmException)
{
  _port->putLine(line, carriageReturn);
  // remove empty echo line
  if (carriageReturn)
    getLine();
}

bool GsmAt::wait(GsmTime timeout) throw(GsmException)
{
  return _port->wait(timeout);
}

int GsmAt::readByte() throw(GsmException)
{
  return _port->readByte();
}

GsmEvent *GsmAt::setEventHandler(GsmEvent *newHandler)
{
  GsmEvent *result = _eventHandler;
  _eventHandler = newHandler;
  return result;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人精品免费看| 欧美一区二区视频在线观看2022| jizzjizzjizz欧美| 7799精品视频| 亚洲美女偷拍久久| 国产九色sp调教91| 欧美肥妇free| 一区二区三区四区不卡在线 | 日韩一区二区三区高清免费看看| 国产精品国产a级| 狠狠色丁香婷婷综合| 欧美性受xxxx| 一二三四社区欧美黄| 成人黄色av电影| 久久久久国产精品麻豆ai换脸 | 中文字幕一区二区三| 美日韩一区二区三区| 在线一区二区视频| 成人欧美一区二区三区小说 | 欧美在线视频日韩| **性色生活片久久毛片| 国产精品综合二区| 2欧美一区二区三区在线观看视频| 爽爽淫人综合网网站| 欧美四级电影在线观看| 亚洲精品视频一区| 色综合天天在线| 亚洲欧洲国产日韩| 成人av电影在线| 国产精品人人做人人爽人人添| 美国毛片一区二区| 欧美白人最猛性xxxxx69交| 奇米影视一区二区三区小说| 在线视频一区二区三区| 亚洲夂夂婷婷色拍ww47| 欧美网站一区二区| 亚洲高清视频的网址| 欧美日韩一区三区| 日韩黄色片在线观看| 91精品一区二区三区在线观看| 天天综合网天天综合色| 91精品国产色综合久久不卡电影| 丝瓜av网站精品一区二区| 欧美一级高清片| 久久se这里有精品| 国产亚洲一区二区三区四区| 丁香六月久久综合狠狠色| 国产欧美日韩视频一区二区| caoporm超碰国产精品| 亚洲少妇屁股交4| 在线观看精品一区| 麻豆精品一二三| 国产清纯白嫩初高生在线观看91 | 蜜桃一区二区三区在线| 国产午夜亚洲精品羞羞网站| 99r精品视频| 亚洲综合色区另类av| 777午夜精品视频在线播放| 久久成人久久鬼色| 国产精品美女久久久久久久网站| 91色在线porny| 天堂资源在线中文精品| 欧美精品一区视频| 99久久精品国产导航| 日韩在线a电影| 久久久精品黄色| 色噜噜夜夜夜综合网| 免费观看一级欧美片| 国产偷v国产偷v亚洲高清| 色婷婷综合久久久中文字幕| 老司机一区二区| 亚洲色图欧美在线| 91精品国产91热久久久做人人| 国产成人精品一区二区三区四区 | 色综合一区二区三区| 视频一区视频二区中文| 国产欧美综合在线| 欧美日韩大陆一区二区| 国产精品一二三在| 无码av中文一区二区三区桃花岛| 中文一区二区在线观看 | 色婷婷久久99综合精品jk白丝| 蜜臀a∨国产成人精品| 综合久久综合久久| 久久久亚洲高清| 欧美三级视频在线| 成人黄动漫网站免费app| 喷水一区二区三区| 一区二区三区精品| 国产欧美一区二区三区在线看蜜臀| 欧美三级蜜桃2在线观看| 成人一区二区在线观看| 蜜臀va亚洲va欧美va天堂 | 日韩高清不卡一区| 亚洲人快播电影网| 中文字幕欧美国产| 亚洲精品在线观| 日韩欧美国产三级电影视频| 在线观看视频91| 99精品欧美一区二区三区小说| 老汉av免费一区二区三区| 亚洲一级片在线观看| 亚洲少妇最新在线视频| 欧美国产精品中文字幕| 久久色中文字幕| 精品三级av在线| 欧美成人国产一区二区| 日韩欧美综合在线| 91精品国产综合久久久久久久| 欧美日韩一区二区三区高清| 在线免费观看不卡av| 色久综合一二码| 91女神在线视频| 99视频有精品| 99riav久久精品riav| 99久久精品国产网站| 成人av先锋影音| 成人av网站免费观看| 成人av资源下载| 91视视频在线直接观看在线看网页在线看 | 91福利在线看| 欧美图区在线视频| 欧美三级欧美一级| 7878成人国产在线观看| 日韩欧美的一区| 26uuu精品一区二区三区四区在线| 久久色.com| 欧美高清在线视频| 亚洲欧美偷拍另类a∨色屁股| 亚洲欧美国产高清| 亚洲第一久久影院| 久久国产精品99久久人人澡| 国产米奇在线777精品观看| 国产经典欧美精品| www.亚洲免费av| 欧美在线观看一二区| 宅男噜噜噜66一区二区66| 精品国产亚洲一区二区三区在线观看 | 看电视剧不卡顿的网站| 激情综合色综合久久| 国产精品123区| bt欧美亚洲午夜电影天堂| 欧美制服丝袜第一页| 91精品国产一区二区三区香蕉| 欧美一区二区三区视频免费播放| 精品动漫一区二区三区在线观看| 久久色成人在线| 一区二区三区四区亚洲| 捆绑变态av一区二区三区| 成人手机在线视频| 欧美色综合网站| 亚洲精品在线三区| 亚洲美女视频在线观看| 久久国产视频网| 99视频精品在线| 日韩欧美国产高清| 国产精品欧美久久久久一区二区| 亚洲一二三区不卡| 国产一区二区三区久久久| 色综合久久88色综合天天6| 欧美精品vⅰdeose4hd| 天天av天天翘天天综合网| 高清在线观看日韩| 欧美理论在线播放| 国产精品系列在线| 日韩福利电影在线观看| 97久久久精品综合88久久| 欧美一区二区三区日韩视频| 中文字幕亚洲一区二区av在线 | 狠狠色狠狠色合久久伊人| 色狠狠色狠狠综合| 国产人成亚洲第一网站在线播放| 日韩中文字幕1| 99久久er热在这里只有精品15| 日韩精品一区二区三区四区视频 | 国产一区在线看| 91精品久久久久久久久99蜜臂| 亚洲国产高清在线| 精品一区二区三区香蕉蜜桃| 欧美人与禽zozo性伦| 亚洲日本一区二区| 成人性生交大片免费看中文网站| 91精品国产综合久久久久| 亚洲电影你懂得| 欧美午夜一区二区三区| 国产精品国产三级国产| 国产.欧美.日韩| 欧美国产欧美综合| 国产乱码精品一区二区三区av| 8v天堂国产在线一区二区| 亚洲一区二区三区四区在线免费观看 | 国产91清纯白嫩初高中在线观看| 这里只有精品视频在线观看| 一区二区三区美女| 色综合天天综合色综合av| 久久久久久一二三区| 精品一区二区三区不卡| 日韩欧美一二三区| 日韩高清在线观看| 欧美一区二区二区|