本文整理汇总了C++中sim900_send_cmd函数的典型用法代码示例。如果您正苦于以下问题:C++ sim900_send_cmd函数的具体用法?C++ sim900_send_cmd怎么用?C++ sim900_send_cmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sim900_send_cmd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
};
示例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;
}
示例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);
}
示例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;
}
示例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;
}