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.
Diff: main.cpp
- Revision:
- 1:940070f92554
- Parent:
- 0:3d4b4cf5f0e3
- Child:
- 2:83d03d7148a5
--- a/main.cpp	Wed Nov 13 22:08:48 2019 +0000
+++ b/main.cpp	Thu Nov 14 14:02:32 2019 +0000
@@ -1,8 +1,13 @@
-#include "global.h"
-char modem_response[255];
+#include "BT.h"
 Timer t;
+char modem_response[255];
  int main(){
-     DEBUG_PRINTLN("PROGRAM START");
+    //Serial modemSerial(PC_6, PC_7);
+    BT bt(modemSerial);
+    DEBUG_PRINTLN("PROGRAM START");
+    MODEM_PRINTLN("ATE0");
+    get_response(1000,false);
+    DEBUG_PRINTLN("%s",modem_response);
      MODEM_PRINTLN("AT");
       get_response(1000,false);
      if((strcmp(modem_response,"OK") != 0)){
@@ -11,17 +16,17 @@
     }
     DEBUG_PRINTLN("%s",modem_response);
     MODEM_PRINTLN("AT+BTHOST?");
-    get_response(1000,false);
-    DEBUG_PRINTLN("%s",modem_response);
-    MODEM_PRINTLN("AT+BTSTATUS?");
-    get_response(1000,false);
+    get_response(1000,true);
     DEBUG_PRINTLN("%s",modem_response);
-    MODEM_PRINTLN("AT+BTPOWER=1");
-    get_response(1000,false);
-    DEBUG_PRINTLN("%s",modem_response);
-    MODEM_PRINTLN("AT+BTSCAN=1,10");
-    get_response(10000,true);
-    DEBUG_PRINTLN("%s",modem_response);
+     bt.get_bt_status();
+     bt.power_bt_device(1);
+     char id = bt.bt_scan();
+     if(id=='0'){
+         DEBUG_PRINTLN("Target device not found");
+     }
+     else{
+        bt.bt_pair_device(id);
+        }   
  while(1){
     
  }