This example establishes a transparent link between the mbed serial port and the modem (LISA or SARA) 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
Fork of C027_ModemTransparentSerial by
main.cpp@2:1970ac045983, 2013-10-25 (annotated)
- Committer:
- mazgch
- Date:
- Fri Oct 25 20:37:09 2013 +0000
- Revision:
- 2:1970ac045983
- Parent:
- 1:7334dcb895d0
- Child:
- 4:e089bc72b28c
use power config
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mazgch | 0:53fc79c7af10 | 1 | #include "mbed.h" |
mazgch | 2:1970ac045983 | 2 | #include "C027.h" |
mazgch | 0:53fc79c7af10 | 3 | |
mazgch | 0:53fc79c7af10 | 4 | int main() |
mazgch | 0:53fc79c7af10 | 5 | { |
mazgch | 2:1970ac045983 | 6 | C027 c027; |
mazgch | 2:1970ac045983 | 7 | c027.mdmPower(true); |
mazgch | 2:1970ac045983 | 8 | |
mazgch | 0:53fc79c7af10 | 9 | // open the mdm serial port |
mazgch | 0:53fc79c7af10 | 10 | Serial mdm(MDMTXD, MDMRXD); |
mazgch | 0:53fc79c7af10 | 11 | mdm.baud(MDMBAUD); |
mazgch | 0:53fc79c7af10 | 12 | // tell the modem that we can always receive data |
mazgch | 1:7334dcb895d0 | 13 | DigitalOut mdmRts(MDMRTS); |
mazgch | 0:53fc79c7af10 | 14 | mdmRts = 0; // (not using flow control) |
mazgch | 0:53fc79c7af10 | 15 | |
mazgch | 0:53fc79c7af10 | 16 | // open the PC serial port and (use the same baudrate) |
mazgch | 0:53fc79c7af10 | 17 | Serial pc(USBTX, USBRX); |
mazgch | 0:53fc79c7af10 | 18 | pc.baud(MDMBAUD); |
mazgch | 0:53fc79c7af10 | 19 | |
mazgch | 0:53fc79c7af10 | 20 | while (1) |
mazgch | 0:53fc79c7af10 | 21 | { |
mazgch | 0:53fc79c7af10 | 22 | // transfer data from pc to modem |
mazgch | 0:53fc79c7af10 | 23 | if (pc.readable() && mdm.writeable()) |
mazgch | 0:53fc79c7af10 | 24 | mdm.putc(pc.getc()); |
mazgch | 0:53fc79c7af10 | 25 | // transfer data from modem to pc |
mazgch | 0:53fc79c7af10 | 26 | if (mdm.readable() && pc.writeable()) |
mazgch | 0:53fc79c7af10 | 27 | pc.putc(mdm.getc()); |
mazgch | 0:53fc79c7af10 | 28 | } |
mazgch | 0:53fc79c7af10 | 29 | } |