Petter Bellander / Mbed 2 deprecated Saab-BT

Dependencies:   mbed

Revision:
14:3f4098e94c29
Parent:
13:968af0520530
Child:
15:82c3cc87bd02
--- a/main.cpp	Sat Jan 30 21:03:52 2016 +0000
+++ b/main.cpp	Sun Jan 31 20:58:42 2016 +0000
@@ -37,7 +37,7 @@
     rn52.init();
     cdc.init();
     printf("Adding wakeup routine\r\n");
-    wakeup.attach(&check_for_wakeup, 1);
+    wakeup.attach(&check_for_wakeup, 0.5);
     printf("Starting loop\r\n");
     while(1) {
         if(active) {
@@ -65,10 +65,13 @@
             }
         }
         while(pc.readable()) {
-            if(pc.getc() == '1') {
-                active = 1;
-                rn52.enable();
-                cdc.enable();
+            switch (pc.getc()) {
+                case '1':
+                    printf("enabling\r\n");
+                    active = 1;
+                    rn52.enable();
+                    cdc.enable();
+                    break;    
             }
         }
     }
@@ -100,12 +103,6 @@
                 rn52.get_caller_id(&res);
                 printf("%s\r\n", res.response);
                 break;
-            case '0':
-                printf("deactivating\r\n");
-                active = 0;
-                rn52.disable();
-                cdc.disable();
-                break;
         }
     }
 }
@@ -115,8 +112,8 @@
         case IBUS_HEAD_UNIT_OFF:
             cdc.display("Shutdown");
             active = 0;
+            cdc.disable();
             rn52.disable();
-            cdc.disable();
             break;
         case IBUS_NEXT:
             rn52.toggle_play();
@@ -156,8 +153,7 @@
                 printf("duration:  %i\r\n", res.duration);
                 printf("track_count:  %i\r\n", res.track_count);
                 printf("track_number:  %i\r\n", res.track_number);
-                //cdc.display(res.title);
-                cdc.display("BT SPELAR");
+                cdc.display(res.title);
                 cdc.set_track((char)res.track_number);
                 break;
             case RN52_OTHER_EVENT: //no specific event occured, check connection status