Door controller and proximity switch detection.

Dependencies:   mbed-rtos mbed VodafoneUSBModem_bleedingedge

This program takes in a digital input - which is a reed switch for a door - and an output to a relay. The door is open with a simple 'text' to the modem on the USB bus (i used k3770 vodafone dongle).

The door will send an alarm message to your nominated numbers at the start of the program if the door is open without a command being sent.

Very simple - and just meant as a demonstration of how to incorporate GSM/3G functionality to a evice.

Revision:
21:7068b39d3006
Parent:
20:27f878df6d14
Parent:
18:ad4ae0caf337
Child:
26:b9a0fa0f2469
diff -r 27f878df6d14 -r 7068b39d3006 main.cpp
--- a/main.cpp	Thu Sep 27 13:18:02 2012 +0000
+++ b/main.cpp	Thu Sep 27 14:49:15 2012 +0000
@@ -23,12 +23,12 @@
 
 #define __DEBUG__ 4 //Maximum verbosity
 #ifndef __MODULE__
-// #define __MODULE__ "net_voda_k3770_test.cpp"
+#define __MODULE__ "net_voda_k3770_test.cpp"
 #endif
 
 #define MY_PHONE_NUMBER "+447717275049"
 
-#include "core/fwk.h"
+//#include "core/fwk.h"
 #include "mbed.h"
 #include "rtos.h"
 #include "VodafoneUSBModem.h"
@@ -70,7 +70,8 @@
   LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN;                                 // an enum to hold the type of bearer established by the connection manager
   int rssi = -1000;                                                                         // a signal strength indicator variable - set to a very default low value.
 
-
+  int ret = connectionManager.getLinkState(&rssi, &regState, &bearer);
+  
   // LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_HOME_NETWORK;
 
   // before we do anything we need to make sure we have a connection to a network.
@@ -79,8 +80,8 @@
   
   while(detectRegState)
   {
-      if(connectionManager.getLinkState(&rssi, &regState, &bearer)==0) 
-      //if (detectRegState ==1)
+      //if(connectionManager.getLinkState(&rssi, &regState, &bearer)==0) 
+      if (detectRegState ==1)
       {
         if(rssi==-1000) 
         { 
@@ -115,19 +116,14 @@
                 break;
             default:
                 DBG("regState: ERROR. Failing.");
-                break;
+
         }
       }
   Thread::wait(500);
   }
 
-
-
-
-
-  connectionManager.sendSM(MY_PHONE_NUMBER, "Hello from mbed door controller:)");
-
-
+  ret = connectionManager.sendSM(MY_PHONE_NUMBER, "Hello from mbed door controller");
+  
 
   while(true)
   {
@@ -221,7 +217,6 @@
     }
     Thread::wait(500);
   }
-
 }
 
 void keepAlive(void const*) {
@@ -242,8 +237,8 @@
   //t.attach(tick,1);
   DBG_INIT();
   DBG_SET_SPEED(115200);
+  Thread testTask(test, NULL, osPriorityNormal, 1024*6);
 
-  Thread testTask(test, NULL, osPriorityNormal, 1024*5);
   keepAlive(NULL);