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.

Files at this revision

API Documentation at this revision

Comitter:
nherriot
Date:
Sun Feb 10 16:32:32 2013 +0000
Parent:
22:87d73be30243
Child:
25:1c47f3a5b8e3
Commit message:
small dbg changes

Changed in this revision

VodafoneUSBModem_bleedingedge.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/VodafoneUSBModem_bleedingedge.lib	Tue Feb 05 08:58:35 2013 +0000
+++ b/VodafoneUSBModem_bleedingedge.lib	Sun Feb 10 16:32:32 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#6f42a974eea6
+http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#0da249386019
--- a/main.cpp	Tue Feb 05 08:58:35 2013 +0000
+++ b/main.cpp	Sun Feb 10 16:32:32 2013 +0000
@@ -63,11 +63,11 @@
 }
 
 void test(void const*) {
-  VodafoneUSBModem connectionManager;                     // create a connection manager object
 
   DBG("Hello world and Vodafone Connection Manager test program!");
   DBG("Waiting 30 seconds for modem to settle down");
-
+  Thread::wait(10000);
+  VodafoneUSBModem connectionManager;                     // create a connection manager object
 
   char num[17];                                           // create a buffer to hold the telephone number in
   char msg[160];                                          // create a buffer to hold the text message in
@@ -77,8 +77,11 @@
   int rssi = -1000;                                                                         // a signal strength indicator variable - set to a very default low value.
 
   // this is a fudge to let the modem settle down - we wait for 30 seconds
-  Thread::wait(30000);
+  
   DBG("Wait over - initialising the modem manager");
+  
+  
+  
   int ret = connectionManager.getLinkState(&rssi, &regState, &bearer);
   // LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_HOME_NETWORK;
 
@@ -113,6 +116,9 @@
             case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL:
                 DBG("regState: NO SIGNAL");
                 break;
+            case HARDWARE_NO_RESPONSE:
+                DBG("Looks like there is no modem inserted, or power to the modem module has failed?");
+                break;
             case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK:
                 detectRegState = false;
                 DBG("regState: HOME NETWORK");
@@ -127,6 +133,7 @@
         }
       }
   Thread::wait(500);
+  int ret = connectionManager.getLinkState(&rssi, &regState, &bearer);
   }
 
   // let the boss man know I'm alive and entering my main loop  
@@ -212,7 +219,7 @@
       continue;
     }
         
-    DBG("The SMS count is now at: %d for this modem", count);
+    // DBG("The SMS count is now at: %d for this modem", count);
     if( count > 0)                                          // if there are messages in the mailbox start pulling them off the queue
     {
       DBG("%d SMS to read", count);
@@ -292,7 +299,8 @@
   //t.attach(tick,1);
   DBG_INIT();
   DBG_SET_SPEED(115200);
-  Thread testTask(test, NULL, osPriorityNormal, 1024*5);
+  test(NULL);
+  //Thread testTask(test, NULL, osPriorityNormal, 1024*5);
 
   keepAlive(NULL);