final groupe 1

Files at this revision

API Documentation at this revision

Comitter:
GrandDiego
Date:
Sun Feb 03 19:36:14 2019 +0000
Parent:
10:24671d8aa0c9
Commit message:
final groupe 1

Changed in this revision

GSM.cpp Show annotated file Show diff for this revision Revisions of this file
GSM.h Show annotated file Show diff for this revision Revisions of this file
--- a/GSM.cpp	Tue May 13 14:43:57 2014 +0000
+++ b/GSM.cpp	Sun Feb 03 19:36:14 2019 +0000
@@ -4,21 +4,8 @@
 
   Author:lawliet.zou@gmail.com
   2013-11-14
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
+*/
 
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
 #include "GSM.h"
 
 int GSM::readBuffer(char *buffer,int count)
@@ -46,6 +33,26 @@
     return 0;
 }
 
+void GSM::gprs_message(char * url , char * message) {
+    
+    //gprsSerial.printf("at+sapbr=1,1\r\n"); //enable gprs
+    //wait(0.05);
+    sendCmdAndWaitForResp("AT+SAPBR=1,1\r\n", "OK", 2);
+        
+    //gprsSerial.printf("at+httpinit\r\n");
+    //wait(0.05);
+    sendCmdAndWaitForResp("at+httpinit\r\n", "OK", 2);
+        
+    gprsSerial.printf("at+httppara=\"url\",\"%s%s\"\r\n", url, message);
+    wait(0.15);
+    //char str[50];
+    //snprintf(str, 50, "at+httppara=\"url\",\"%s%s\"\r\n", url, message);
+    //sendCmdAndWaitForResp(str, "OK", 2);
+        
+    //gprsSerial.printf("at+httpaction=0\r\n");
+    sendCmdAndWaitForResp("at+httpaction=0\r\n", "OK", 2);
+    
+}
 void cleanBuffer(char *buffer, int count)
 {
     for(int i=0; i < count; i++) {
--- a/GSM.h	Tue May 13 14:43:57 2014 +0000
+++ b/GSM.h	Sun Feb 03 19:36:14 2019 +0000
@@ -4,20 +4,6 @@
 
   Author:lawliet.zou@gmail.com
   2013-11-14
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 #ifndef __GSM_H__
@@ -50,10 +36,16 @@
      *  @param number default phone number during mobile communication
      */
     GSM(PinName tx, PinName rx, int baudRate,char *number) : gprsSerial(tx, rx) {
-        //gprsSerial.baud(baudRate);
-        phoneNumber = number;
+        gprsSerial.baud(baudRate);
+        phoneNumber = number; 
     };
     
+    // Fonctions rajoutées pour le projet HAB ;
+    void gprs_message(char * url , char * message);
+    
+    
+    
+    
     int powerCheck(void);
     /** init GSM module including SIM card check & signal strength & network check
      *  @returns
@@ -178,7 +170,11 @@
     Serial gprsSerial;
     //USBSerial pc;
 
+
+
 private:
+
+
     /** Read from GSM module and save to buffer array
      *  @param  *buffer buffer array to save what read from GSM module
      *  @param  *count  the maximal bytes number read from GSM module