A library for talking to Multi-Tech's Cellular SocketModem Devices.
Dependents: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
Diff: cellular/Cellular.h
- Revision:
- 89:9e5da66e4f1e
- Parent:
- 87:5db6c084adc7
- Child:
- 90:b5abba87d9e2
--- a/cellular/Cellular.h Fri Dec 27 16:48:30 2013 +0000 +++ b/cellular/Cellular.h Fri Dec 27 17:44:55 2013 +0000 @@ -91,7 +91,10 @@ * * main() { * //Wait for radio to boot up -* wait(30); +* for (int i = 30; i >= 0; i = i - 5) { +* wait(5); +* printf("Waiting %d seconds...\n\r", i); +* } * * //Setup serial interface to radio * MTSSerialFlowControl* serial = new MTSSerialFlowControl(PTD3, PTD2, PTA12, PTC8); @@ -102,18 +105,26 @@ * cellular->init(serial); * * //Start test -* printf("Test: %s\n\r", Cellular::getCodeNames(cellular->test()).c_str()); +* printf("AT Test: %s\n\r", getCodeNames(cellular->test()).c_str()); +* +* //Waiting for network registration +* printf("Checking Network Registration, this may take some time...\n\r"); +* while (cellular->getRegistration() != Cellular::REGISTERED) { +* printf("Still waiting... Checking again.\n\r"); +* wait(1); +* } +* printf("Connected to the Network!\n\r"); * * //Send SMS Message -* Cellular::Code code; +* Code code; * std::string sMsg("Hello from Multi-Tech MBED!"); * std::string sPhoneNum("16128675309"); //Put your phone number here or leave Jenny's... * * printf("Sending message [%s] to [%s]\r\n", sMsg.c_str(), sPhoneNum.c_str()); * code = cellular->sendSMS(sPhoneNum, sMsg); * -* if(code != Cellular::CELL_OK) { -* printf("Error during SMS send [%s]\r\n", Cellular::getCodeNames(code).c_str()); +* if(code != SUCCESS) { +* printf("Error during SMS send [%s]\r\n", getCodeNames(code).c_str()); * } else { * printf("Success!\r\n"); * } @@ -142,13 +153,16 @@ * * main() { * //Define connection parameters -* Cellular::Code code; +* Code code; * const int TEST_PORT = 7000; * //const std::string TEST_SERVER("204.26.122.5"); * const std::string TEST_SERVER("ws://echo.websocket.org"); * * //Wait for radio to boot up -* wait(30); +* for (int i = 30; i >= 0; i = i - 5) { +* wait(5); +* printf("Waiting %d seconds...\n\r", i); +* } * * //Setup serial interface to radio * MTSSerialFlowControl* serial = new MTSSerialFlowControl(PTD3, PTD2, PTA12, PTC8); @@ -159,27 +173,25 @@ * cellular->init(serial); * * //Start test -* printf("Test: %s\n\r", Cellular::getCodeNames(cellular->test()).c_str()); +* printf("AT Test: %s\n\r", getCodeNames(cellular->test()).c_str()); * * printf("Setting APN\r\n"); -* code = cellular->setApn("wap.cingular"); // Use from your service provider -* if(code == Cellular::CELL_OK) { +* code = cellular->setApn("wap.cingular"); // Use from your service provider! +* if(code == SUCCESS) { * printf("Success!\r\n"); * } else { -* printf("Error during APN setup [%s]\r\n", cellular->getCodeNames(code).c_str()); +* printf("Error during APN setup [%s]\r\n", getCodeNames(code).c_str()); * } * -* printf("Signal Strength: %d\n\r", cellular->getSignalStrength()); -* printf("Registration State: %s\n\r", Cellular::getRegistrationNames(cellular->getRegistration()).c_str()); -* * //Setup a data connection -* printf("Attempting to Connect\n\r"); -* while (cellular->connect()) { +* printf("Attempting to Connect, this may take some time...\n\r"); +* while (!cellular->connect()) { +* printf("Failed to connect... Trying again.\n\r"); * wait(1); * } * printf("Connected to the Network!\n\r"); * -* printf("Opening a TCP Socket\r\n"); +* printf("Opening a TCP Socket...\r\n"); * if(cellular->open(TEST_SERVER, TEST_PORT, IPStack::TCP)) { * printf("Success!\r\n"); * } else { @@ -212,12 +224,6 @@ * printf("End Program\n\r"); * } * @endcode -* -* The following set of example code demonstrates how to setup and use a TCP socket connection -* using the Mbed compatible Socket interfaces. -* @code -* #include "mbed.h" -* @endcode */ class Cellular : virtual mts::IPStack