This example establishes a transparent link between the mbed USB CDC port and the modem (LISA) on the C027. You can use it to use the standard u-blox tools such as m-center or any terminal program. These tools can then connect to the serial port and talk directly to the modem. Baudrate should be set to 115200 baud and is fixed. m-center can be downloaded from u-blox website following this link: http://www.u-blox.com/en/evaluation-tools-a-software/u-center/m-center.html

Dependencies:   C027 UbloxUSBModem mbed

Fork of C027_ModemTransparentSerial by u-blox

Install mbed Windows Drivers

Make sure you installed the drivers on your windows PC to get the virtual serial port. A installation guideline and the drivers can be found in the following wiki page. /handbook/Windows-serial-configuration

Committer:
mazgch
Date:
Fri Dec 06 09:54:21 2013 +0000
Revision:
6:8d5bf8e37f18
Parent:
5:853bcd1ce32b
pulled in new library, LISA-C requires to use CDC1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazgch 0:53fc79c7af10 1 #include "mbed.h"
mazgch 3:8d37a7a064f1 2 #include "C027.h"
mazgch 2:20ff91824a26 3 #include "WANDongle.h"
mazgch 2:20ff91824a26 4 #include "USBSerialStream.h"
mazgch 2:20ff91824a26 5 #include "UbloxCDMAModemInitializer.h"
mazgch 2:20ff91824a26 6 #include "UbloxGSMModemInitializer.h"
mazgch 0:53fc79c7af10 7
mazgch 0:53fc79c7af10 8 int main()
mazgch 0:53fc79c7af10 9 {
mazgch 3:8d37a7a064f1 10 C027 c027;
mazgch 6:8d5bf8e37f18 11 c027.mdmUsbEnable(true);
mazgch 3:8d37a7a064f1 12 c027.mdmPower(true);
mazgch 5:853bcd1ce32b 13
mazgch 0:53fc79c7af10 14 // open the mdm serial port
mazgch 2:20ff91824a26 15 WANDongle mdmDongle;
mazgch 6:8d5bf8e37f18 16 USBSerialStream mdmStream(mdmDongle.getSerial(1/* the CDC usually 0 or 1, LISA-C requires CDC1*/));
mazgch 2:20ff91824a26 17 USBHost* host = USBHost::getHostInst();
mazgch 2:20ff91824a26 18 mdmDongle.addInitializer(new UbloxCDMAModemInitializer(host));
mazgch 2:20ff91824a26 19 mdmDongle.addInitializer(new UbloxGSMModemInitializer(host));
mazgch 2:20ff91824a26 20
mazgch 0:53fc79c7af10 21 // open the PC serial port and (use the same baudrate)
mazgch 0:53fc79c7af10 22 Serial pc(USBTX, USBRX);
mazgch 0:53fc79c7af10 23 pc.baud(MDMBAUD);
mazgch 0:53fc79c7af10 24
mazgch 0:53fc79c7af10 25 while (1)
mazgch 0:53fc79c7af10 26 {
mazgch 2:20ff91824a26 27 uint8_t buf[64];
mazgch 2:20ff91824a26 28 size_t len;
mazgch 2:20ff91824a26 29 int i;
mazgch 2:20ff91824a26 30 if (!mdmDongle.connected())
mazgch 2:20ff91824a26 31 {
mazgch 2:20ff91824a26 32 mdmDongle.tryConnect();
mazgch 2:20ff91824a26 33 }
mazgch 2:20ff91824a26 34 else
mazgch 2:20ff91824a26 35 {
mazgch 2:20ff91824a26 36 // transfer data from pc to modem
mazgch 2:20ff91824a26 37 len = mdmStream.space();
mazgch 2:20ff91824a26 38 if (len>0)
mazgch 2:20ff91824a26 39 {
mazgch 2:20ff91824a26 40 if (len > sizeof(buf))
mazgch 2:20ff91824a26 41 len = sizeof(buf);
mazgch 2:20ff91824a26 42 for (i = 0; (i < len) && pc.readable(); )
mazgch 2:20ff91824a26 43 buf[i++] = pc.getc();
mazgch 2:20ff91824a26 44 if (OK == mdmStream.write(buf, i))
mazgch 2:20ff91824a26 45 /* what to do here ?*/;
mazgch 2:20ff91824a26 46 }
mazgch 2:20ff91824a26 47 // transfer data from modem to pc
mazgch 2:20ff91824a26 48 len = mdmStream.available();
mazgch 2:20ff91824a26 49 if ((len>0) && pc.writeable())
mazgch 2:20ff91824a26 50 {
mazgch 2:20ff91824a26 51 if (len > sizeof(buf))
mazgch 2:20ff91824a26 52 len = sizeof(buf);
mazgch 2:20ff91824a26 53 if (OK == mdmStream.read(buf, &len, len))
mazgch 2:20ff91824a26 54 {
mazgch 2:20ff91824a26 55 for (i = 0; (i < len); )
mazgch 2:20ff91824a26 56 pc.putc(buf[i++]);
mazgch 2:20ff91824a26 57 }
mazgch 2:20ff91824a26 58 }
mazgch 2:20ff91824a26 59 }
mazgch 0:53fc79c7af10 60 }
mazgch 0:53fc79c7af10 61 }