Created
May 27, 2015 04:48
-
-
Save coyotebush/d8d8830aaa9a18bb7538 to your computer and use it in GitHub Desktop.
switch between cellular modem and ethernet on u-blox C027
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Include in your project: | |
// https://developer.mbed.org/teams/ublox/code/C027_Support/ | |
// plus, ONLY when compiling without CELLULAR_NETWORK: | |
// https://developer.mbed.org/users/mbed_official/code/EthernetInterface/ | |
// https://developer.mbed.org/users/mbed_official/code/mbed-rtos/ | |
#include "mbed.h" | |
// ... | |
#define CELLULAR_NETWORK 1 | |
#ifdef CELLULAR_NETWORK | |
#include "MDM.h" | |
#define SIMPIN NULL | |
#define APN "Broadband" | |
#define USERNAME NULL | |
#define PASSWORD NULL | |
#else | |
#include "EthernetInterface.h" | |
#endif | |
int main() | |
{ | |
#ifdef CELLULAR_NETWORK | |
MDMSerial mdm; | |
//mdm.setDebug(4); | |
if (!mdm.connect(SIMPIN, APN,USERNAME,PASSWORD)) | |
return -1; | |
#else | |
EthernetInterface ethernet; | |
ethernet.init(); // DHCP | |
if (ethernet.connect() != 0) | |
return -1; | |
#endif | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment