![](/media/cache/profiles/e1c599867ee5449a59e6c638200a3d92.50x50_q85.jpg)
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.
Diff: main.cpp
- Revision:
- 16:9245c3a37491
- Parent:
- 15:262da03e3e20
- Child:
- 17:9b57d29e2eab
- Child:
- 20:27f878df6d14
diff -r 262da03e3e20 -r 9245c3a37491 main.cpp --- a/main.cpp Tue Sep 25 10:01:54 2012 +0000 +++ b/main.cpp Wed Sep 26 17:02:59 2012 +0000 @@ -40,7 +40,7 @@ } DigitalOut led1(LED1); // LED 1 is used to show the state of the door. ON is door open, and OFF is door close. -DigitalOut led2(LED2); +DigitalOut led2(LED2); // LED 2 is used to indicate that the main process is still running. DigitalOut led3(LED3); // LED 3 is use to indicate if the relay is being switched on to open the door DigitalOut led4(LED4); DigitalOut doorContactorRelay(p5); // create a digital pin object to control the door contactor relay @@ -70,12 +70,17 @@ 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. + + // 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. // so let us check that first! + while(detectRegState) { if(connectionManager.getLinkState(&rssi, ®State, &bearer)==0) + //if (detectRegState ==1) { if(rssi==-1000) { @@ -113,6 +118,7 @@ break; } } + Thread::wait(500); } @@ -159,7 +165,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); @@ -232,13 +238,13 @@ } int main() { - Ticker t; - t.attach(tick,1); + //Ticker t; + //t.attach(tick,1); DBG_INIT(); DBG_SET_SPEED(115200); Thread testTask(test, NULL, osPriorityNormal, 1024*5); - // keepAlive(NULL); + keepAlive(NULL); return 0;