• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sim900_send_cmd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sim900_check_with_cmd

bool GPRS::readSMS(int messageIndex, char *message,int length)
{
    int i = 0;
    char gprsBuffer[100];
    //char cmd[16];
	char num[4];
    char *p,*s;
    
    sim900_check_with_cmd("AT+CMGF=1\r\n","OK\r\n",CMD);
    delay(1000);
	sim900_send_cmd("AT+CMGR=");
	itoa(messageIndex, num, 10);
	sim900_send_cmd(num);
	sim900_send_cmd("\r\n");
//  sprintf(cmd,"AT+CMGR=%d\r\n",messageIndex);
//    sim900_send_cmd(cmd);
    sim900_clean_buffer(gprsBuffer,sizeof(gprsBuffer));
    sim900_read_buffer(gprsBuffer,sizeof(gprsBuffer),DEFAULT_TIMEOUT);
    if(NULL != ( s = strstr(gprsBuffer,"+CMGR:"))){
        if(NULL != ( s = strstr(s,"\r\n"))){
            p = s + 2;
            while((*p != '\r')&&(i < length-1)) {
                message[i++] = *(p++);
            }
            message[i] = '\0';
            return true;
        }
    }
    return false;   
}
开发者ID:Yurysamara,项目名称:smart_power31,代码行数:30,代码来源:GPRS_Shield_Arduino.cpp


示例2: sim900_send_cmd

int GPRS::send(const char * str, int len)
{
    //char cmd[32];
	char num[4];
    if(len > 0){
        //snprintf(cmd,sizeof(cmd),"AT+CIPSEND=%d\r\n",len);
		//sprintf(cmd,"AT+CIPSEND=%d\r\n",len);
		sim900_send_cmd("AT+CIPSEND=");
		itoa(len, num, 10);
		sim900_send_cmd(num);
		if(!sim900_check_with_cmd("\r\n",">",CMD)) {
        //if(!sim900_check_with_cmd(cmd,">",CMD)) {
            return 0;
        }
        /*if(0 != sim900_check_with_cmd(str,"SEND OK\r\n", DEFAULT_TIMEOUT * 10 ,DATA)) {
            return 0;
        }*/
        delay(500);
        sim900_send_cmd(str);
        delay(500);
        sim900_send_End_Mark();
        if(!sim900_wait_for_resp("SEND OK\r\n", DATA, DEFAULT_TIMEOUT * 10, DEFAULT_INTERCHAR_TIMEOUT * 10)) {
            return 0;
        }        
    }
    return len;
}
开发者ID:Yurysamara,项目名称:smart_power31,代码行数:27,代码来源:GPRS_Shield_Arduino.cpp


示例3: itoa

 bool GPRS::delBookEntry(int index)
{
	char indexStr[4];
	itoa(index, indexStr, 10);
	sim900_flush_serial();
    sim900_send_cmd(F("AT+CPBW="));
    sim900_send_cmd(indexStr);
    return sim900_check_with_cmd(F("\r"),"OK\r\n",CMD);	
}
开发者ID:Seeed-Studio,项目名称:GPRS_SIM900,代码行数:9,代码来源:GPRS_Shield_Arduino.cpp


示例4: delay

bool GPRS::callUp(char *number)
{
  if(!sim900_check_with_cmd("AT+COLP=1\r\n","OK\r\n",CMD)) {
      return false;
  }
  delay(1000);
  sim900_send_cmd("ATD");
  sim900_send_cmd(number);
  sim900_send_cmd(";\r\n");
  return true;
}
开发者ID:amperka,项目名称:gprs-shield,代码行数:11,代码来源:GPRS_Shield_Arduino.cpp


示例5: delay

bool GPRS::callUp(char *number)
{
    //char cmd[24];
    if(!sim900_check_with_cmd("AT+COLP=1\r\n","OK\r\n",CMD)) {
        return false;
    }
    delay(1000);
	//HACERR quitar SPRINTF para ahorar memoria ???
    //sprintf(cmd,"ATD%s;\r\n", number);
    //sim900_send_cmd(cmd);
	sim900_send_cmd("ATD");
	sim900_send_cmd(number);
	sim900_send_cmd(";\r\n");
    return true;
}
开发者ID:Yurysamara,项目名称:smart_power31,代码行数:15,代码来源:GPRS_Shield_Arduino.cpp


示例6: snprintf

bool GPRS::join()
{
    char cmd[64];
    char ipAddr[32];
    //Select multiple connection
    //sim900_check_with_cmd("AT+CIPMUX=1\r\n","OK",DEFAULT_TIMEOUT,CMD);

    //set APN
    snprintf(cmd,sizeof(cmd),"AT+CSTT=\"%s\",\"%s\",\"%s\"\r\n",_apn,_userName,_passWord);
    sim900_check_with_cmd(cmd, "OK", DEFAULT_TIMEOUT,CMD);

    //Brings up wireless connection
    sim900_check_with_cmd("AT+CIICR\r\n","OK",DEFAULT_TIMEOUT,CMD);

    //Get local IP address
    sim900_send_cmd("AT+CIFSR\r\n");
    sim900_read_buffer(ipAddr,32,2);

    if(NULL != strstr(ipAddr,"AT+CIFSR")) {
        _ip = str_to_ip(ipAddr+12);
        if(_ip != 0) {
            return true;
        }
    }
    return false;
}
开发者ID:HIMADE,项目名称:GPRS_Shield_Suli,代码行数:26,代码来源:GPRS_Shield_Arduino.cpp


示例7: need

int GPRS::readSMS(int messageIndex, char *message, int length, char *phone, char *datetime)  
{
  /* Response is like:
  AT+CMGR=2
  
  +CMGR: "REC READ","XXXXXXXXXXX","","14/10/09,17:30:17+08"
  SMS text here
  
  So we need (more or lees), 80 chars plus expected message length in buffer. CAUTION FREE MEMORY
  */

    int i = 0;
    char gprsBuffer[80 + length];
    char cmd[16];
    char *p,*p2,*s;
    
    sim900_check_with_cmd("AT+CMGF=1\r\n","OK\r\n",CMD);
    suli_delay_ms(1000);
    sprintf(cmd,"AT+CMGR=%d\r\n",messageIndex);
    sim900_send_cmd(cmd);
    sim900_clean_buffer(gprsBuffer,sizeof(gprsBuffer));
    sim900_read_buffer(gprsBuffer,sizeof(gprsBuffer),DEFAULT_TIMEOUT);
    
    if(NULL != ( s = strstr(gprsBuffer,"+CMGR:"))){
        // Extract phone number string
        p = strstr(s,",");
        p2 = p + 2; //We are in the first phone number character
        p = strstr((char *)(p2), "\"");
        if (NULL != p) {
            i = 0;
            while (p2 < p) {
                phone[i++] = *(p2++);
            }
            phone[i] = '\0';            
        }
        // Extract date time string
        p = strstr((char *)(p2),",");
        p2 = p + 1; 
        p = strstr((char *)(p2), ","); 
        p2 = p + 2; //We are in the first date time character
        p = strstr((char *)(p2), "\"");
        if (NULL != p) {
            i = 0;
            while (p2 < p) {
                datetime[i++] = *(p2++);
            }
            datetime[i] = '\0';
        }        
        if(NULL != ( s = strstr(s,"\r\n"))){
            i = 0;
            p = s + 2;
            while((*p != '\r')&&(i < length-1)) {
                message[i++] = *(p++);
            }
            message[i] = '\0';
        }
        return 0;
    }
    return -1;    
}
开发者ID:alhabbal,项目名称:GPRS_Shield_Suli,代码行数:60,代码来源:GPRS_Shield_Arduino.cpp


示例8: sim900_flush_serial

bool GPRS::getSubscriberNumber(char *number)
{
	//AT+CNUM								--> 7 + CR = 8
	//+CNUM: "","+628157933874",145,7,4		--> CRLF + 45 + CRLF = 49
	//										-->
	//OK									--> CRLF + 2 + CRLF = 6

    byte i = 0;
    char gprsBuffer[65];
    char *p,*s;
	sim900_flush_serial();
    sim900_send_cmd("AT+CNUM\r\n");
    sim900_clean_buffer(gprsBuffer,65);
    sim900_read_buffer(gprsBuffer,65,DEFAULT_TIMEOUT);
	//Serial.print(gprsBuffer);
    if(NULL != ( s = strstr(gprsBuffer,"+CNUM:"))) {
        s = strstr((char *)(s),",");
        s = s + 2;  //We are in the first phone number character 
        p = strstr((char *)(s),"\""); //p is last character """
        if (NULL != s) {
            i = 0;
            while (s < p) {
              number[i++] = *(s++);
            }
            number[i] = '\0';
        }
        return true;
    }  
    return false;
}
开发者ID:Yurysamara,项目名称:smart_power31,代码行数:30,代码来源:GPRS_Shield_Arduino.cpp


示例9: sim900_flush_serial

bool GPRS::getVcc(char *buffer)
{
	//AT+CBC            --> 6 + CR
	//+CBC: 0,100,4241	--> CRLF + 16 + CRLF
	//
	//OK			    --> CRLF + 2 + CRLF
	
    byte i = 0;
    char gprsBuffer[50];
    char *p,*s;
	sim900_flush_serial();
    sim900_send_cmd(F("AT+CBC\r"));
    sim900_clean_buffer(gprsBuffer,50);
    sim900_read_buffer(gprsBuffer,50,DEFAULT_TIMEOUT);
    if(NULL != ( s = strstr(gprsBuffer,"+CBC:"))) {
        s = strstr((char *)(s),",");
        s = s + 1; 
        s = strstr((char *)(s), ","); 
        s = s + 1; //We are in the first Vcc character
        p = s + 4; //p is last character
        if (NULL != s) {
            i = 0;
            while (s < p) {
              buffer[i++] = *(s++);
            }
            buffer[i] = '\0';            
        }
        return true;
    }  
    return false;
}
开发者ID:Seeed-Studio,项目名称:GPRS_SIM900,代码行数:31,代码来源:GPRS_Shield_Arduino.cpp


示例10: sim900_send_cmd

  bool GPRS::getDateTime(char *buffer)
  {
  //AT+CCLK?						--> 8 + CRLF = 10
  //+CCLK: "14/11/13,21:14:41+04"   --> 29+ CRLF = 31
  //								--> CRLF     =  2
  //OK

    byte i = 0;
    char gprsBuffer[46];
    char *p,*s;
    sim900_send_cmd("AT+CCLK?\r\n");
    sim900_clean_buffer(gprsBuffer,43);
    sim900_read_buffer(gprsBuffer,43,DEFAULT_TIMEOUT);
    if(NULL != ( s = strstr(gprsBuffer,"+CCLK:"))) {
      s = strstr((char *)(s),"\"");
        s = s + 1;  //We are in the first phone number character
        p = strstr((char *)(s),"\""); //p is last character """
        if (NULL != s) {
          i = 0;
          while (s < p) {
            buffer[i++] = *(s++);
          }
          buffer[i] = '\0';
        }
        //We are going to flush serial data until OK is recieved
        return sim900_wait_for_resp("OK\r\n", CMD);
      }
      return false;
    }
开发者ID:amperka,项目名称:gprs-shield,代码行数:29,代码来源:GPRS_Shield_Arduino.cpp


示例11: imei

String GPRS::getImei(){
    char buf[32];
    String imei(NULL);
    sim900_send_cmd("AT+GSN\r\n");
    sim900_read_buffer(buf,sizeof(buf),DEFAULT_TIMEOUT);
    String response(buf);
    if(strstr(buf,"OK") != NULL)
        imei = response.substring(10, 25);
    return imei;
};
开发者ID:HIMADE,项目名称:GPRS_Shield_Suli,代码行数:10,代码来源:GPRS_Shield_Arduino.cpp


示例12: suli_delay_ms

int GPRS::callUp(char *number)
{
    char cmd[24];
    if(0 != sim900_check_with_cmd("AT+COLP=1\r\n","OK",DEFAULT_TIMEOUT,CMD)) {
        return -1;
    }
    suli_delay_ms(1000);
    sprintf(cmd,"ATD%s;\r\n", number);
    sim900_send_cmd(cmd);
    return 0;
}
开发者ID:HIMADE,项目名称:GPRS_Shield_Suli,代码行数:11,代码来源:GPRS_Shield_Arduino.cpp


示例13: sim900_send_cmd

bool GPRS::ntpSyncDateTime(int8_t timezone)
{
    // e.g. "-105\0", this is not a valid value to pass to the SIM module, but we need to make sure not
    // to cross boundaries of the char array
    char timezoneString[5] = {'\0'};

    if (sim900_check_with_cmd(F("AT+CNTPCID=1\r\n"), "OK\r\n", CMD) == false)
        return false;

    sim900_send_cmd(F("AT+CNTP=\"pool.ntp.org\","));

    itoa(timezone, timezoneString, 10);

    sim900_send_cmd(timezoneString);

    if (sim900_check_with_cmd(F("\r\n"), "OK\r\n", CMD) == false)
        return false;

    return sim900_check_with_cmd(F("AT+CNTP\r\n"), "+CNTP: 1", CMD);
}
开发者ID:Seeed-Studio,项目名称:GPRS_SIM900,代码行数:20,代码来源:GPRS_Shield_Arduino.cpp


示例14: delay

bool GPRS::sendSMS(char *number, char *data)
{
    //char cmd[32];
    if(!sim900_check_with_cmd("AT+CMGF=1\r\n", "OK\r\n", CMD)) { // Set message mode to ASCII
        return false;
    }
    delay(500);
	sim900_send_cmd("AT+CMGS=\"");
	sim900_send_cmd(number);
    //sprintf(cmd,"AT+CMGS=\"%s\"\r\n", number);
	//snprintf(cmd, sizeof(cmd),"AT+CMGS=\"%s\"\r\n", number);
//    if(!sim900_check_with_cmd(cmd,">",CMD)) {
    if(!sim900_check_with_cmd("\"\r\n",">",CMD)) {
        return false;
    }
    delay(1000);
    sim900_send_cmd(data);
    delay(500);
    sim900_send_End_Mark();
    return true;
}
开发者ID:yavuzoguzipek,项目名称:HapticNavigationDevice,代码行数:21,代码来源:GPRS_Shield_Arduino.cpp


示例15: sim900_clean_buffer

bool GPRS::sendUSSDSynchronous(char *ussdCommand, char *resultcode, char *response)
{
	//AT+CUSD=1,"{command}"
	//OK
	//
	//+CUSD:1,"{response}",{int}

	byte i = 0;
    char gprsBuffer[200];
    char *p,*s;
    sim900_clean_buffer(response, sizeof(response));
	
	sim900_flush_serial();
    sim900_send_cmd("AT+CUSD=1,\"");
    sim900_send_cmd(ussdCommand);
    sim900_send_cmd("\"\r");
	if(!sim900_wait_for_resp("OK\r\n", CMD))
		return false;
    sim900_clean_buffer(gprsBuffer,200);
    sim900_read_buffer(gprsBuffer,200,DEFAULT_TIMEOUT);
    if(NULL != ( s = strstr(gprsBuffer,"+CUSD: "))) {
        *resultcode = *(s+7);
		resultcode[1] = '\0';
		if(!('0' <= *resultcode && *resultcode <= '2'))
			return false;
		s = strstr(s,"\"");
        s = s + 1;  //We are in the first phone number character
        p = strstr(s,"\""); //p is last character """
        if (NULL != s) {
            i = 0;
            while (s < p) {
              response[i++] = *(s++);
            }
            response[i] = '\0';            
        }
		return true;
	}
	return false;
}
开发者ID:Yurysamara,项目名称:smart_power31,代码行数:39,代码来源:GPRS_Shield_Arduino.cpp


示例16: delay

boolean GPRS::send(const char * str)
{
	if(!sim900_check_with_cmd(F("AT+CIPSEND\r\n"),">",CMD)) {
		return false;
	}
	delay(500);
	sim900_send_cmd(str);
	delay(500);
	sim900_send_End_Mark();
	if(!sim900_wait_for_resp("SEND OK\r\n", DATA, DEFAULT_TIMEOUT * 10, DEFAULT_INTERCHAR_TIMEOUT * 10)) {
		return false;
	}   
    return true;
}
开发者ID:Seeed-Studio,项目名称:GPRS_SIM900,代码行数:14,代码来源:GPRS_Shield_Arduino.cpp


示例17: sim900_send_cmd

int GPRS::isSMSunread()
{
    char gprsBuffer[64];  //64 is enough to see +CMGL:
    char *p,*s;
    //List of all UNREAD SMS and DON'T change the SMS UNREAD STATUS
    sim900_send_cmd("AT+CMGL=\"REC UNREAD\",1\r\n");
    /*If you want to change SMS status to READ you will need to send:
          AT+CMGL=\"REC UNREAD\"\r\n
      This command will list all UNREAD SMS and change all of them to READ
      
     If there is not SMS, response is (26 chars)
         AT+CMGL="REC UNREAD",1
         OK
     If there is SMS, response is like (>64 chars)
         AT+CMGL="REC UNREAD",1
         +CMGL: 9,"REC UNREAD","XXXXXXXXX","","14/10/16,21:40:08+08"
         Here SMS text.
         OK  
         
         or

         AT+CMGL="REC UNREAD",1
         +CMGL: 9,"REC UNREAD","XXXXXXXXX","","14/10/16,21:40:08+08"
         Here SMS text.
         +CMGL: 10,"REC UNREAD","YYYYYYYYY","","14/10/16,21:40:08+08"
         Here second SMS        
         OK           
    */
    sim900_clean_buffer(gprsBuffer,64);
    sim900_read_buffer(gprsBuffer,64,DEFAULT_TIMEOUT); 
    
    if(NULL != ( s = strstr(gprsBuffer,"OK"))) {
        //In 64 bytes "doesn't" fit whole +CMGL: response, if recieve only "OK"
        //    means you don't have any UNREAD SMS
        return 0;
    } else {
        if(NULL != ( s = strstr(gprsBuffer,"+CMGL:"))) {
            //There is at least one UNREAD SMS, get index/position
            p = strstr((char *)gprsBuffer,":");
            if (p != NULL) {
                //We are going to flush serial data until OK is recieved
                sim900_wait_for_resp("OK", DEFAULT_TIMEOUT, CMD);
                return atoi(p+1);
            }
        } else {
            return 0; 
        }
    } 
    return -1;
}
开发者ID:HIMADE,项目名称:GPRS_Shield_Suli,代码行数:50,代码来源:GPRS_Shield_Arduino.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sim_activate函数代码示例发布时间:2022-05-30
下一篇:
C++ sim900_check_with_cmd函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap