Enables "direct" communication between GSM and serial port
Fork of C027_ModemTransparentSerial by
main.cpp@9:57346cb22188, 2015-10-02 (annotated)
- Committer:
- MrGu
- Date:
- Fri Oct 02 09:47:53 2015 +0000
- Revision:
- 9:57346cb22188
- Parent:
- 8:b561b2003e76
Talk with GSM modem from serial port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mazgch | 0:53fc79c7af10 | 1 | #include "mbed.h" |
MrGu | 9:57346cb22188 | 2 | #include "C027_api.h" |
MrGu | 9:57346cb22188 | 3 | |
mazgch | 0:53fc79c7af10 | 4 | |
mazgch | 8:b561b2003e76 | 5 | /* This example is establishing a transparent link between |
mazgch | 8:b561b2003e76 | 6 | the mbed serial port and the serial communication interface |
mazgch | 8:b561b2003e76 | 7 | of the Modem(MDM). |
mazgch | 8:b561b2003e76 | 8 | |
mazgch | 8:b561b2003e76 | 9 | For a more advanced driver for the GPS or Modem(MDM) please |
mazgch | 8:b561b2003e76 | 10 | look at the follwing library and example: |
mazgch | 8:b561b2003e76 | 11 | C027_Support Library |
mazgch | 8:b561b2003e76 | 12 | http://mbed.org/teams/ublox/code/C027_Support/ |
mazgch | 8:b561b2003e76 | 13 | C027_Support Example |
mazgch | 8:b561b2003e76 | 14 | http://mbed.org/teams/ublox/code/C027_SupportTest/ |
mazgch | 8:b561b2003e76 | 15 | */ |
mazgch | 0:53fc79c7af10 | 16 | int main() |
mazgch | 0:53fc79c7af10 | 17 | { |
mazgch | 8:b561b2003e76 | 18 | // setting the power on pin low while powering the device will turn it on |
mazgch | 8:b561b2003e76 | 19 | DigitalOut pin(MDMPWRON, 0); |
mazgch | 8:b561b2003e76 | 20 | wait_ms(10); |
mazgch | 8:b561b2003e76 | 21 | c027_mdm_powerOn(false); |
mazgch | 2:1970ac045983 | 22 | |
mazgch | 0:53fc79c7af10 | 23 | // open the mdm serial port |
mazgch | 8:b561b2003e76 | 24 | Serial mdm(MDMTXD,MDMRXD); |
mazgch | 0:53fc79c7af10 | 25 | mdm.baud(MDMBAUD); |
mazgch | 8:b561b2003e76 | 26 | mdm.set_flow_control(SerialBase::RTSCTS, MDMRTS,MDMCTS); |
mazgch | 0:53fc79c7af10 | 27 | |
mazgch | 0:53fc79c7af10 | 28 | // open the PC serial port and (use the same baudrate) |
MrGu | 9:57346cb22188 | 29 | Serial pc(P4_28, P4_29); |
mazgch | 0:53fc79c7af10 | 30 | pc.baud(MDMBAUD); |
mazgch | 0:53fc79c7af10 | 31 | while (1) |
mazgch | 0:53fc79c7af10 | 32 | { |
mazgch | 0:53fc79c7af10 | 33 | // transfer data from pc to modem |
mazgch | 0:53fc79c7af10 | 34 | if (pc.readable() && mdm.writeable()) |
MrGu | 9:57346cb22188 | 35 | { |
mazgch | 0:53fc79c7af10 | 36 | mdm.putc(pc.getc()); |
MrGu | 9:57346cb22188 | 37 | } |
mazgch | 0:53fc79c7af10 | 38 | // transfer data from modem to pc |
mazgch | 0:53fc79c7af10 | 39 | if (mdm.readable() && pc.writeable()) |
MrGu | 9:57346cb22188 | 40 | { |
mazgch | 0:53fc79c7af10 | 41 | pc.putc(mdm.getc()); |
MrGu | 9:57346cb22188 | 42 | } |
mazgch | 0:53fc79c7af10 | 43 | } |
mazgch | 0:53fc79c7af10 | 44 | } |