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 6:5a892c3d738e, committed 2012-07-25
- Comitter:
- nherriot
- Date:
- Wed Jul 25 10:33:28 2012 +0000
- Parent:
- 5:ca4f06634bcb
- Child:
- 7:316c2dac06a5
- Commit message:
- removing redundant code.
Changed in this revision
--- a/VodafoneK3770Lib.lib Tue May 15 16:30:49 2012 +0000 +++ b/VodafoneK3770Lib.lib Wed Jul 25 10:33:28 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/programs/VodafoneK3770Lib/m9ujje \ No newline at end of file +VodafoneK3770Lib#9ad20223a8fa
--- a/main.cpp Tue May 15 16:30:49 2012 +0000
+++ b/main.cpp Wed Jul 25 10:33:28 2012 +0000
@@ -23,17 +23,15 @@
#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 "mbed.h"
-
#include "rtos.h"
-
-#include "if/VodafoneK3770.h"
+#include "VodafoneK3770.h"
#include <string>
@@ -84,23 +82,31 @@
continue;
}
- DBG("The message is from number: %s and the message is: %s", num, msg);
- if (strcmp (msg, "OPEN") ==0)
- {
+ DBG("The message is from number: %s and the message is: \"%s\"", num, msg);
+ if(strcmp(num,"+447836503274")==0) {
+ threeg.sendSM("07836503274","SPAM ALERT! UNKNOWN NUMBER");
+ threeg.sendSM("07836503274","INITIATING DEFENSE MECHANISM: 1 DAY OF RETALIATION SMS");
+ for(int i=0; i<10; i++) {
+ threeg.sendSM("07836503274","ANTI-SPAM SMS PUNISHMENT. DON'T SPAM THE DOOR!!");
+ Thread:wait(10000);
+ }
+ }
+
+ if (strcmp (msg, "open") ==0) {
DBG("The SMS message indicates I should open the door");
// do something to open the door
doorOpen = 1;
led3 = 1;
- }
- else
- {
+ threeg.sendSM(num, " Door open sir... Welcome home! ");
+ } else {
DBG("The SMS message is not recognized");
+ threeg.sendSM(num, " Wrong password sir... Try 'open' and I'll open! ;-) ");
}
}
- Thread::wait(3000);
+ Thread::wait(500);
}
}
@@ -124,7 +130,7 @@
DBG_INIT();
Thread testTask(test, NULL, osPriorityNormal, 1024*4);
- keepAlive(NULL);
+ // keepAlive(NULL);
return 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jul 25 10:33:28 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479 \ No newline at end of file
--- a/mbed.lib Tue May 15 16:30:49 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/projects/libraries/svn/mbed/trunk@43 \ No newline at end of file




