Example program that uses the mbed UbloxATCellularInterface or OnboardCellularInterface classes to perform simple sockets operations. This program can be used on the C027 and C030 boards, including the C030 N2xx version with a little editing.
Dependencies: ublox-at-cellular-interface ublox-cellular-base ublox-cellular-base-n2xx ublox-at-cellular-interface-n2xx
Diff: main.cpp
- Revision:
- 4:3e2b789c3adc
- Parent:
- 3:7ca70581ef20
- Child:
- 5:bf352de1d3e5
--- a/main.cpp Fri Jun 09 14:36:07 2017 +0000 +++ b/main.cpp Mon Jun 12 09:09:13 2017 +0000 @@ -112,6 +112,11 @@ int main() { UbloxATCellularInterface *interface = new UbloxATCellularInterface(); +// If you need to debug the cellular interface, comment out the +// instantiation above and uncomment the one below. +// UbloxATCellularInterface *interface = new UbloxATCellularInterface(MDMTXD, MDMRXD, +// MBED_CONF_UBLOX_CELL_BAUD_RATE, +// true); TCPSocket sockTcp; UDPSocket sockUdp; SocketAddress udpServer; @@ -119,7 +124,12 @@ SocketAddress tcpServer; char buf[1024]; int x; +#ifdef TARGET_UBLOX_C027 + // No user button on C027 + InterruptIn userButton(NC); +#else InterruptIn userButton(SW0); +#endif // Attach a function to the user button userButton.rise(&cbButton); @@ -147,7 +157,7 @@ printf("\"2.pool.ntp.org\" address: %s on port %d.\n", udpServer.get_ip_address(), udpServer.get_port()); printf("\"developer.mbed.org\" address: %s on port %d.\n", tcpServer.get_ip_address(), tcpServer.get_port()); - printf("Performing socket operations in a loop until the user button is pressed...\n"); + printf("Performing socket operations in a loop (until the user button is pressed on C030 or forever on C027)...\n"); while (!buttonPressed) { // UDP Sockets printf("=== UDP ===\n");