当前位置: 首页>>代码示例>>C++>>正文


C++ GetCommLineStatus函数代码示例

本文整理汇总了C++中GetCommLineStatus函数的典型用法代码示例。如果您正苦于以下问题:C++ GetCommLineStatus函数的具体用法?C++ GetCommLineStatus怎么用?C++ GetCommLineStatus使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetCommLineStatus函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

/**********************************************************
  Sends parameters for initialization of GSM module

  group:  0 - parameters of group 0 - not necessary to be registered in the GSM
          1 - parameters of group 1 - it is necessary to be registered
**********************************************************/
void GSM::InitParam(byte group)
{

  switch (group) {
    case PARAM_SET_0:
      // check comm line
      if (CLS_FREE != GetCommLineStatus()) return;
      SetCommLineStatus(CLS_ATCMD);

      // Reset to the factory settings
      SendATCmdWaitResp("AT&F0", 1000, 20, "OK", 5);      
      // switch off echo
      SendATCmdWaitResp("ATE0", 500, 20, "OK", 5);
      // setup auto baud rate
      SendATCmdWaitResp("AT+IPR=0", 500, 20, "OK", 5);
      SetCommLineStatus(CLS_FREE);
      break;

    case PARAM_SET_1:
      // check comm line
      if (CLS_FREE != GetCommLineStatus()) return;
      SetCommLineStatus(CLS_ATCMD);

      // set the SMS mode to text 
      SendATCmdWaitResp("AT+CMGF=1", 500, 20, "OK", 5);
      // init SMS storage
      InitSMSMemory();
      // select phonebook memory storage
      SendATCmdWaitResp("AT+CPBS=\"SM\"", 1000, 20, "OK", 5);
      break;
  }
  
}
开发者ID:PriyankPa,项目名称:Advanced-GPRS-Shield,代码行数:39,代码来源:GSM.cpp

示例2: SetSpeakerVolume

/**********************************************************
Method sets speaker volume

speaker_volume: volume in range 0..14

return: 
        ERROR ret. val:
        ---------------
        -1 - comm. line to the GSM module is not free
        -2 - GSM module did not answer in timeout
        -3 - GSM module has answered "ERROR" string

        OK ret val:
        -----------
        0..100 current speaker volume 
**********************************************************/
char GSM::SetSpeakerVolume(byte speaker_volume)
{
  
  char ret_val = -1;

  if (CLS_FREE != GetCommLineStatus()) return (ret_val);
  SetCommLineStatus(CLS_ATCMD);
  // remember set value as last value
  if (speaker_volume > 100) speaker_volume = 100;
  // select speaker volume (0 to 100)
  // AT+CLVL=X<CR>   X<0..100>
  Serial.print(F("AT+CLVL="));
  Serial.print((int)speaker_volume);    
  Serial.print(F("\r")); // send <CR>
  // 10 sec. for initial comm tmout
  // 20 msec. for inter character timeout
  if (RX_TMOUT_ERR == WaitResp(10000, 20)) {
    ret_val = -2; // ERROR
  }
  else {
    if(IsStringReceived("OK")) {
      last_speaker_volume = speaker_volume;
      ret_val = last_speaker_volume; // OK
    }
    else ret_val = -3; // ERROR
  }

  SetCommLineStatus(CLS_FREE);
  return (ret_val);
}
开发者ID:PriyankPa,项目名称:Advanced-GPRS-Shield,代码行数:46,代码来源:GSM.cpp

示例3: SendDTMFSignal

/**********************************************************
Method sends DTMF signal
This function only works when call is in progress

dtmf_tone: tone to send 0..15

return: 
        ERROR ret. val:
        ---------------
        -1 - comm. line to the GSM module is not free
        -2 - GSM module didn't answer in timeout
        -3 - GSM module has answered "ERROR" string

        OK ret val:
        -----------
        0.. tone
**********************************************************/
char GSM::SendDTMFSignal(byte dtmf_tone)
{
  char ret_val = -1;

  if (CLS_FREE != GetCommLineStatus()) return (ret_val);
  SetCommLineStatus(CLS_ATCMD);
  // e.g. AT+VTS=5<CR>
  Serial.print(F("AT+VTS="));
  Serial.print((int)dtmf_tone);    
  Serial.print(F("\r"));
  // 1 sec. for initial comm tmout
  // 20 msec. for inter character timeout
  if (RX_TMOUT_ERR == WaitResp(1000, 20)) {
    ret_val = -2; // ERROR
  }
  else {
    if(IsStringReceived("OK")) {
      ret_val = dtmf_tone; // OK
    }
    else ret_val = -3; // ERROR
  }

  SetCommLineStatus(CLS_FREE);
  return (ret_val);
}
开发者ID:PriyankPa,项目名称:Advanced-GPRS-Shield,代码行数:42,代码来源:GSM.cpp

示例4: SetGPIOVal

/**********************************************************
Method sets GPIO pin according required value
it doesn't check if the pin was previously set as OUTPUT
so INPUT pin is automatically switch
as the output pin by using this function 

gpio_pin:   10..13
value:      0 - "0" as LOW
            1 - "1" as HIGH

return: 
        ERROR ret. val:
        ---------------
        -1 - comm. line to the GSM module is not free
        -2 - GSM module didn't answer in timeout
        -3 - GSM module has answered "ERROR" string

        OK ret val:
        -----------
        0 - set to the "0" - LOW
        1 - set to the "1" - HIGH
**********************************************************/
char GSM::SetGPIOVal(byte GPIO_pin, byte value)
{
  char ret_val = -1;

  if (CLS_FREE != GetCommLineStatus()) return (ret_val);
  SetCommLineStatus(CLS_ATCMD);


  // e.g. AT#GPIO=9,0,1 - set to "0" - LOW
  // or   AT#GPIO=9,1,1 - set to "1" - HIGH
  Serial.print("AT#GPIO=");
  // pin number
  Serial.print((int)GPIO_pin);  
  Serial.print(",");
  if (value > 1) value = 1;
  Serial.print((int)value);
  Serial.print(",1\r");  // pin is always set as output

  // 100 msec. for initial comm tmout
  // 20 msec. for inter character timeout
  if (RX_TMOUT_ERR == WaitResp(100, 20)) {
    ret_val = -2; // ERROR
  }
  else {
    if(IsStringReceived("OK")) {
      ret_val = value; // OK
    }
    else ret_val = -3; // ERROR
  }

  SetCommLineStatus(CLS_FREE);
  return (ret_val);
}
开发者ID:dbgrandi,项目名称:gsm_playground,代码行数:55,代码来源:GSM.cpp

示例5: UpdateSignalLevel

/**********************************************************
Method update signal level
return: 
	  
OK ret val:
        -----------
        1 - Signal Level updated
		0 - Signal level not updated
		
ERROR ret. val:
        ---------------
        -1 - comm. line to the GSM module is not free
        -2 - GSM module didn't answer in timeout
**********************************************************/
char GSM::UpdateSignalLevel()
{
 char ret_val = -1;
 char sig=0;
 char *p_char; 
 char *p_char1;
 
 if (CLS_FREE != GetCommLineStatus()) return (ret_val);
 SetCommLineStatus(CLS_ATCMD);
 ret_val = 0; // not found yet
 
 Serial.print(F("AT+CSQ\r"));
 
 switch (WaitResp(1000, 20, "+CSQ")) {
    case RX_TMOUT_ERR:
      // response was not received in specific time
      ret_val = -2;
      break;

    case RX_FINISHED_STR_RECV:
      
      p_char = strchr((char *)(comm_buf),':');
      if (p_char != NULL) {
        p_char++;       // we are on the first battery level character
        // find out ',' as finish character of battery level string
        p_char1 = strchr((char *)(p_char),',');
        if (p_char1 != NULL) {
          *p_char1 = 0; // end of string
          sig= atoi(p_char); //Convert string to integer 0-100%
		}
      }
	  
	  if((sig==0) || (sig==99))
		signalLevel=0;
	  else if((sig>0) && (sig<=5))
		signalLevel=1;
	  else if((sig>5) && (sig<=12))
		signalLevel=2;
	  else if((sig>12) && (sig<=17))
		signalLevel=3;
	  else if((sig>17) && (sig<=22))
		signalLevel=4;
	  else if((sig>22) && (sig<=32))
		signalLevel=5;
	  else
	    signalLevel=0;
	  
	 ret_val =1;
      break;

    case RX_FINISHED_STR_NOT_RECV:
      
	  ret_val = 0; 
      break;
  }

  SetCommLineStatus(CLS_FREE);
  return (ret_val);

}
开发者ID:PriyankPa,项目名称:Advanced-GPRS-Shield,代码行数:74,代码来源:GSM.cpp

示例6: DelPhoneNumber

/**********************************************************
Method del phone number from the specified SIM position

position:     SMS position <1..20>

return: 
        ERROR ret. val:
        ---------------
        -1 - comm. line to the GSM module is not free
        -2 - GSM module didn't answer in timeout
        -3 - position must be > 0

        OK ret val:
        -----------
        0 - phone number was not deleted
        1 - phone number was deleted
**********************************************************/
char GSM::DelPhoneNumber(byte position)
{
  char ret_val = -1;

  if (position == 0) return (-3);
  if (CLS_FREE != GetCommLineStatus()) return (ret_val);
  SetCommLineStatus(CLS_ATCMD);
  ret_val = 0; // phone number was not written yet
  
  //send: AT+CPBW=XY
  // where XY = position
  _cell.print(F("AT+CPBW="));
  _cell.print((int)position);  
  _cell.print(F("\r"));

  // 5000 msec. for initial comm tmout
  // 50 msec. for inter character timeout
  switch (WaitResp(5000, 50, "OK")) {
    case RX_TMOUT_ERR:
      // response was not received in specific time
      break;

    case RX_FINISHED_STR_RECV:
      // response is OK = has been written
      ret_val = 1;
      break;

    case RX_FINISHED_STR_NOT_RECV:
      // other response: e.g. ERROR
      break;
  }

  SetCommLineStatus(CLS_FREE);
  return (ret_val);
}
开发者ID:DwaineGarden,项目名称:Davis-Weather-Station-GSM-Code,代码行数:52,代码来源:SIM900.cpp

示例7: SetGPIODir

/**********************************************************
Method sets direction for GPIO pins GPIO10, GPIO11, GPIO12, GPIO13

gpio_pin:   10..13
direction:  0 - input
            1 - output

return: 
        ERROR ret. val:
        ---------------
        -1 - comm. line to the GSM module is not free
        -2 - GSM module didn't answer in timeout
        -3 - GSM module has answered "ERROR" string

        OK ret val:
        -----------
        0 - set as INPUT
        1 - set as OUTPUT
**********************************************************/
char GSM::SetGPIODir(byte GPIO_pin, byte direction)
{
  char ret_val = -1;

  if (CLS_FREE != GetCommLineStatus()) return (ret_val);
  SetCommLineStatus(CLS_ATCMD);

  // e.g. AT#GPIO=9,0,0 - sets as INPUT
  // e.g. AT#GPIO=9,0,1 - sets as OUTPUT and value is "0" - LOW
  Serial.print("AT#GPIO=");
  // pin number
  Serial.print((int)GPIO_pin);  
  Serial.print(",0,"); // if case pin will be OUTPUT - 
                       // first value after initialization will be 0 
  if (direction > 1) direction = 1;
  Serial.print((int)direction); // 0-INPUT, 1-OUTPUT
  Serial.print("\r");           // finish command = send<CR>

  // 100 msec. for initial comm tmout
  // 20 msec. for inter character timeout
  if (RX_TMOUT_ERR == WaitResp(100, 20)) {
    ret_val = -2; // ERROR
  }
  else {
    if(IsStringReceived("OK")) {
      ret_val = direction;  // OK
    }
    else ret_val = -3;      // ERROR
  }

  SetCommLineStatus(CLS_FREE);
  return (ret_val);
}
开发者ID:dbgrandi,项目名称:gsm_playground,代码行数:52,代码来源:GSM.cpp

示例8: PickUp

/**********************************************************
Method picks up an incoming call

return: 
**********************************************************/
void GSM::PickUp(void)
{
  if (CLS_FREE != GetCommLineStatus()) return;
  SetCommLineStatus(CLS_ATCMD);
  Serial.println("ATA");
  SetCommLineStatus(CLS_FREE);
}
开发者ID:dbgrandi,项目名称:gsm_playground,代码行数:12,代码来源:GSM.cpp

示例9: InitGPRS

/**********************************************************
Method initializes GPRS

apn:      APN string
login:    user id string
password: password string

return: 
        ERROR ret. val:
        ---------------
        -1 - comm. line is not free


        OK ret val:
        -----------
        0 - GPRS was not initialized
        1 - GPRS was initialized


an example of usage:
        APN si called internet
        user id and password are not used

        GSM gsm;
        gsm.InitGPRS("internet", "", ""); 
**********************************************************/
char GSM::InitGPRS(char* apn, char* login, char* password)
{
  char ret_val = -1;
  char cmd[100];

  if (CLS_FREE != GetCommLineStatus()) return (ret_val);
  SetCommLineStatus(CLS_ATCMD);
  // prepare command:  AT+CGDCONT=1,"IP","apn"
  strcpy(cmd, "AT+CGDCONT=1,\"IP\",\"");
  strcat(cmd, apn);
  strcat(cmd, "\""); // add character "
  ret_val = SendATCmdWaitResp(cmd, 1000, 100, "OK", 2);
  if (ret_val == AT_RESP_OK) {
    // prepare command:  AT#USERID="login"
    strcpy(cmd, "AT#USERID=\"");
    strcat(cmd, login);
    strcat(cmd, "\""); // add character "
    ret_val = SendATCmdWaitResp(cmd, 1000, 100, "OK", 2);
    if (ret_val == AT_RESP_OK) {
      // prepare command:  AT#PASSW="password"
      strcpy(cmd, "AT#PASSW=\"");
      strcat(cmd, password);
      strcat(cmd, "\""); // add character "
      ret_val = SendATCmdWaitResp(cmd, 1000, 100, "OK", 2);
      if (ret_val == AT_RESP_OK) ret_val = 1;
      else ret_val = 0;
    }
    else ret_val = 0;
  }
  else ret_val = 0;

  SetCommLineStatus(CLS_FREE);
  return (ret_val);
}
开发者ID:dbgrandi,项目名称:gsm_playground,代码行数:60,代码来源:GSM_GPRS.cpp

示例10: HangUp

/**********************************************************
Method hangs up incoming or active call

return: 
**********************************************************/
void GSM::HangUp(void)
{
  if (CLS_FREE != GetCommLineStatus()) return;
  SetCommLineStatus(CLS_ATCMD);
  Serial.println(F("ATH0\r"));
  SetCommLineStatus(CLS_FREE);
}
开发者ID:PriyankPa,项目名称:Advanced-GPRS-Shield,代码行数:12,代码来源:GSM.cpp

示例11: TurnOffLED

/**********************************************************
Turns off the user LED
**********************************************************/
void GSM::TurnOffLED(void)
{
  if (CLS_FREE != GetCommLineStatus()) return;
  SetCommLineStatus(CLS_ATCMD);
  // response here is not important
  SendATCmdWaitResp("AT#GPIO=8,0,1", 500, 20, "#GPIO:", 1);
  SetCommLineStatus(CLS_FREE);
}
开发者ID:dbgrandi,项目名称:gsm_playground,代码行数:11,代码来源:GSM.cpp

示例12: GetPhoneNumber

char GSM::GetPhoneNumber(byte position, char *phone_number)
{
  char ret_val = -1;

  char *p_char; 
  char *p_char1;

  if (position == 0) return (-3);
  if (CLS_FREE != GetCommLineStatus()) return (ret_val);
  SetCommLineStatus(CLS_ATCMD);
  ret_val = 0; // not found yet
  phone_number[0] = 0; // phone number not found yet => empty string
  
  //send "AT+CPBR=XY" - where XY = position
  _cell.print(F("AT+CPBR="));
  _cell.print((int)position);  
  _cell.print("\r");

  // 5000 msec. for initial comm tmout
  // 50 msec. for inter character timeout
  switch (WaitResp(5000, 50, "+CPBR")) {
    case RX_TMOUT_ERR:
      // response was not received in specific time
      ret_val = -2;
      break;

    case RX_FINISHED_STR_RECV:
      // response in case valid phone number stored:
      // <CR><LF>+CPBR: <index>,<number>,<type>,<text><CR><LF>
      // <CR><LF>OK<CR><LF>

      // response in case there is not phone number:
      // <CR><LF>OK<CR><LF>
      p_char = strstr((char *)(comm_buf),",\"");
      if (p_char != NULL) {
		p_char++;
        p_char++;       // we are on the first phone number character
        // find out '"' as finish character of phone number string
        p_char1 = strchr((char *)(p_char),'"');
        if (p_char1 != NULL) {
          *p_char1 = 0; // end of string
        }
        // extract phone number string
        strcpy(phone_number, (char *)(p_char));
        // output value = we have found out phone number string
        ret_val = 1;
      }
      break;

    case RX_FINISHED_STR_NOT_RECV:
      // only OK or ERROR => no phone number
      ret_val = 0; 
      break;
  }

  SetCommLineStatus(CLS_FREE);
  return (ret_val);
}
开发者ID:DwaineGarden,项目名称:Davis-Weather-Station-GSM-Code,代码行数:58,代码来源:SIM900.cpp

示例13: EnableGPRS

/**********************************************************
Method enables GPRS context

open_mode:
        0 (= CHECK_AND_OPEN) - checks the current state of context
                               and in case context has been already activated
                               nothing else in made

        1 (= CLOSE_AND_REOPEN) - context is deactivated anyway and then activated again
                               it was found during testing, that you may need to reset the module etc.,
                               and in these cases, you may not be able to activate the GPRS context
                               unless you deactivate it first

return:
        ERROR ret. val:
        ---------------
        -1 - comm. line is not free

        OK ret val:
        -----------
        0 - GPRS context was disabled
        1 - GPRS context was enabled


an example of usage:

        GSM gsm;
        if (gsm.EnableGPRS(CHECK_AND_OPEN) == 1) {
          // GPRS context was enabled, so we have IP address
          // and we can communicate if necessary
        }
**********************************************************/
char GSM::EnableGPRS(byte open_mode)
{
    char ret_val = -1;

    if (CLS_FREE != GetCommLineStatus()) return (ret_val);
    SetCommLineStatus(CLS_ATCMD);

    if (open_mode == CHECK_AND_OPEN) {
        // first try if the GPRS context has not been already initialized
        ret_val = SendATCmdWaitResp("AT+CIPSTATUS", 1000, 1000, "STATE: IP GPRSACT", 2);
        if (ret_val != AT_RESP_OK) {
            // context is not initialized => init the context
            //Enable GPRS
            ret_val = SendATCmdWaitResp("AT+CSTT", 1000, 1000, "OK", 1);
            if (ret_val == AT_RESP_OK) {
                // cstt OK
                ret_val = SendATCmdWaitResp("AT+CIICR", 60000, 1000, "OK", 1);
                if (ret_val == AT_RESP_OK) {
                    // context was activated
                    SendATCmdWaitResp("AT+CIFSR", 2000, 1000, "", 1);//get ip
                    ret_val = 1;
                }
                else ret_val = 0; // not activated
            }
            else ret_val = 0; // not activated
        }
        else ret_val = 1; // context has been already activated
    }
    else {
        // CLOSE_AND_REOPEN mode
        //disable GPRS context
        ret_val = SendATCmdWaitResp("AT+CIPSHUT", 2000, 1000, "SHUT OK", 3);
        if (ret_val == AT_RESP_OK) {
            // context is dactivated
            // => activate GPRS context again
            ret_val = SendATCmdWaitResp("AT+CSTT", 1000, 1000, "OK", 1);
            if (ret_val == AT_RESP_OK) {
                // cstt OK
                ret_val = SendATCmdWaitResp("AT+CIICR", 10000, 1000, "OK", 1);
                if (ret_val == AT_RESP_OK) {
                    // context was activated
                    SendATCmdWaitResp("AT+CIFSR", 2000, 1000, "", 1);//get ip
                    ret_val = 1;
                }
                else ret_val = 0; // not activated
            }
            else ret_val = 0; // not activated
        }
        else ret_val = 0; // not activated
    }

    SetCommLineStatus(CLS_FREE);
    return (ret_val);
}
开发者ID:sigalabs,项目名称:Advanced-GPRS-Shield,代码行数:86,代码来源:GSM_GPRS.cpp

示例14: SetSpeaker

/**********************************************************
Turns on/off the speaker

off_on: 0 - off
        1 - on
**********************************************************/
void GSM::SetSpeaker(byte off_on)
{
     if (CLS_FREE != GetCommLineStatus()) return;
     SetCommLineStatus(CLS_ATCMD);
     if (off_on) {
          //SendATCmdWaitResp("AT#GPIO=5,1,2", 500, 50, "#GPIO:", 1);
     } else {
          //SendATCmdWaitResp("AT#GPIO=5,0,2", 500, 50, "#GPIO:", 1);
     }
     SetCommLineStatus(CLS_FREE);
}
开发者ID:Adrenalinism,项目名称:Microduino-IDE,代码行数:17,代码来源:SIM900.cpp

示例15: Call

/**********************************************************
Method calls the specific number

number_string: pointer to the phone number string 
               e.g. gsm.Call("+420123456789"); 

**********************************************************/
void GSM::Call(char *number_string)
{
  if (CLS_FREE != GetCommLineStatus()) return;
  SetCommLineStatus(CLS_ATCMD);
  // ATDxxxxxx;<CR>
  Serial.print(F("ATD"));
  Serial.print(number_string);    
  Serial.print(F(";\r"));
  // 10 sec. for initial comm tmout
  // 20 msec. for inter character timeout
  WaitResp(10000, 20);
  SetCommLineStatus(CLS_FREE);
}
开发者ID:PriyankPa,项目名称:Advanced-GPRS-Shield,代码行数:20,代码来源:GSM.cpp


注:本文中的GetCommLineStatus函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。