Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
switch between cellular modem and ethernet on u-blox C027
// 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
You can’t perform that action at this time.