Permalink
Browse files

Edited Ibelium Library

  • Loading branch information...
1 parent 5ae9a57 commit 180a4021943a04fa63d6db2d48738592e2e77fe0 @rkevingibson rkevingibson committed Feb 9, 2013
Showing with 11 additions and 8 deletions.
  1. +9 −4 Ibelium/Ibelium.cpp
  2. +2 −4 Ibelium/Ibelium.h
View
@@ -28,7 +28,7 @@ int Ibelium::sendATCmd(char* cmd) {
int Ibelium::sendATQuery(char* cmd, char* response) {
//Send an AT command, and get the response from the board.
- free(response); //Avoid creating a memory leak.
+ //free(response); //Avoid creating a memory leak.
_error=0;
_watchdog=0;
@@ -48,6 +48,7 @@ int Ibelium::sendATQuery(char* cmd, char* response) {
if(_watchdog>=1000) //No response received after a certain length of time
{
+ Serial.println("Watchdog timer gone");
_error=2;
break;
}
@@ -63,15 +64,17 @@ int Ibelium::sendATQuery(char* cmd, char* response) {
if(size>256){ //Reponse too long
_error = 1;
+ Serial.println(size);
break;
}
- } while(!(buff[x-1]=='K' && buff[x-2]=='O'));//Keep Waiting for a response until the last two characters are 'OK'
+ } while(x<2 || !(buff[x-1]=='K' && buff[x-2]=='O') );//Keep Waiting for a response until the last two characters are 'OK'
+ buff[x]=0x0;
response = buff;
- if(_error!=0)
- return 1;
+ if(_error==0)
+ return x;
else
return 0;
}
@@ -88,3 +91,5 @@ void Ibelium::switchModule() {
delay(2000);
digitalWrite(onModulePin,LOW);
}
+
+
View
@@ -2,8 +2,6 @@
messages, uploading log files to an ftp server, and receiving text messages.
-
-
*/
#ifndef Ibelium_h
#define Ibelium_h
@@ -20,9 +18,9 @@ class Ibelium
int init();
int sendSMS(char* message, char* response);
int sendATCmd(char* cmd);
- //char* checkError(); Not implemented yet
-private:
int sendATQuery(char* cmd, char* response);
+ //char* checkError(); Not implemented yet
+private:
void switchModule();
int _error; //An error code

0 comments on commit 180a402

Please sign in to comment.