For RevB MBED Hardware, with the new boot sequence. 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-REVB UbloxUSBModem mbed

Revision:
0:92ab4f4846f8
Child:
1:15b5edb4a91f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 13 00:40:55 2013 +0000
@@ -0,0 +1,87 @@
+#include "mbed.h"
+#include "C027.h"
+#include "WANDongle.h"
+#include "USBSerialStream.h"
+#include "UbloxCDMAModemInitializer.h"
+#include "UbloxGSMModemInitializer.h"
+
+DigitalOut mdm_activity(LED);
+
+int main() 
+{
+    int led_toggle_count = 5;
+
+    // the instantiation of the type, calls C027::C027
+    C027 c027;
+    
+    c027.mdmPower(true);
+
+#if 0
+    while(1) {
+        mdm_activity = !mdm_activity;
+        wait(0.2);
+    }
+#else
+    while( led_toggle_count-- > 0 )
+    {
+        mdm_activity = !mdm_activity;
+        wait(0.2);
+    }
+#endif
+        
+    // open the mdm serial port
+    WANDongle mdmDongle;
+    USBSerialStream mdmStream(mdmDongle.getSerial(1/* the CDC usually 0 or 1, LISA-C requires CDC1*/));
+    USBHost* host = USBHost::getHostInst();
+    mdmDongle.addInitializer(new UbloxCDMAModemInitializer(host));
+    mdmDongle.addInitializer(new UbloxGSMModemInitializer(host));
+   
+    // open the PC serial port and (use the same baudrate)
+    Serial pc(USBTX, USBRX);
+    pc.baud(MDMBAUD);
+    
+    while (1)
+    {
+        uint8_t buf[64];
+        size_t len;
+        int i;
+        
+        if (!mdmDongle.connected())
+        {
+            mdmDongle.tryConnect();
+        }
+        else
+        {
+        
+            // transfer data from pc to modem
+            len = mdmStream.space();
+            if (len>0)
+            {
+                if (len > sizeof(buf))
+                    len = sizeof(buf);
+                for (i = 0; (i < len) && pc.readable(); )
+                    buf[i++] = pc.getc();
+                if (OK == mdmStream.write(buf, i))
+                    /* do something? */;
+            }
+            // transfer data from modem to pc
+            len = mdmStream.available();
+            if ((len>0) && pc.writeable())
+            {
+                if (len > sizeof(buf))
+                    len = sizeof(buf);
+                if (OK == mdmStream.read(buf, &len, len))
+                {
+                    for (i = 0; (i < len); ) 
+                    {
+                        mdm_activity=!mdm_activity;
+                        pc.putc(buf[i++]);
+                    }
+                    
+                    // default the led to off 
+                    mdm_activity=0;
+                }
+            }
+        }
+    }
+}