Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem dspmodified mbed
Diff: merged_code.cpp
- Revision:
- 19:0f009e5e5646
- Parent:
- 17:824537d9204b
diff -r 824537d9204b -r 0f009e5e5646 merged_code.cpp
--- a/merged_code.cpp Tue Jun 23 11:24:06 2015 +0000
+++ b/merged_code.cpp Tue Jun 23 12:21:19 2015 +0000
@@ -9,7 +9,7 @@
#define freq 1
#define fft_points 16384
#define dur_sec 16.384
-#define module_name "TFT2" //enter module name here
+#define module_name "BHJ2" //enter module name here
Serial pc(USBTX, USBRX);
Serial gsm(D1, D0);
@@ -124,8 +124,26 @@
pc.printf("%s",timestamp); //copies response to timestamp for further processing
}
//pc.printf("\r\nanswer %d\r\n",answer);
- return answer;
+ return response;
}
+
+//--------------------------------------------------------------------------------------------------//
+// iteration
+//--------------------------------------------------------------------------------------------------//
+
+bool iteration_send_ATcommand(char* ATcommand, char* expected_answer, unsigned int timeout, int clk_flag,int attempts)
+{
+ for(int i=0; i < attempts; i++)
+ {
+ if(sendATCommand(ATcommand,expected_answer,timeout,clk_flag)){
+ return 1;
+ }
+ }
+ return 0 ;
+}
+
+
+
//--------------------------------------------------------------------------------------------------//
// Getting Timestamp Function //
//--------------------------------------------------------------------------------------------------//
@@ -610,6 +628,7 @@
//--------------------------------------------------------------------------------------------------//
void gsm_init()
{
+
int cnt = 0;
while((sendATcommand("AT+CREG?", "+CREG: 1,1", 10,2) || sendATcommand("AT+CREG?", "+CREG: 1,5", 5,0)) == 0)
{
@@ -618,7 +637,7 @@
pc.printf("creg is 1");
return;
}
- else if(sendATcommand("AT+CREG=1", "+CREG:5", 5,0))
+ else if((response="+CREG:5"))
{
pc.printf("creg is 5");
return;
@@ -630,6 +649,7 @@
reset_mod();
return;
}
+
}
}
//--------------------------------------------------------------------------------------------------//