|
| 1 | +COMX LTE Module |
| 2 | +=============== |
| 3 | + |
| 4 | +.. sku: M031-A |
| 5 | +
|
| 6 | +.. include:: ../refs/module.lte.ref |
| 7 | + |
| 8 | +LTEModule Class provides a set of methods to control the LTE module. Through the |
| 9 | +chat script of AT commands, the module is set to PPP mode and then the data is |
| 10 | +sent to the Internet through the serial port. |
| 11 | + |
| 12 | +Support the following products: |
| 13 | + |
| 14 | + |COMX LTE| |
| 15 | + |
| 16 | + |
| 17 | +UiFlow2 Example |
| 18 | +--------------- |
| 19 | + |
| 20 | +HTTP GET over LTE |
| 21 | +^^^^^^^^^^^^^^^^^ |
| 22 | + |
| 23 | +Open the |core2_lte_http_example.m5f2| project in UiFlow2. |
| 24 | + |
| 25 | +This example demonstrates how to use PPP dial-up on the LTE module and then use |
| 26 | +the `requests2` library to send an HTTP GET request. |
| 27 | + |
| 28 | +UiFlow2 Code Block: |
| 29 | + |
| 30 | + |example_http.png| |
| 31 | + |
| 32 | +Example output: |
| 33 | + |
| 34 | + None |
| 35 | + |
| 36 | + |
| 37 | +Chat script |
| 38 | +^^^^^^^^^^^ |
| 39 | + |
| 40 | +Open the |core2_lte_chat_example.m5f2| project in UiFlow2. |
| 41 | + |
| 42 | +Set the LTE module to PPP mode through a custom AT command chat script. |
| 43 | + |
| 44 | +UiFlow2 Code Block: |
| 45 | + |
| 46 | + |example_chat.png| |
| 47 | + |
| 48 | +Example output: |
| 49 | + |
| 50 | + None |
| 51 | + |
| 52 | +MicroPython Example |
| 53 | +------------------- |
| 54 | + |
| 55 | +HTTP GET over LTE |
| 56 | +^^^^^^^^^^^^^^^^^ |
| 57 | + |
| 58 | +This example demonstrates how to use PPP dial-up on the LTE module and then use |
| 59 | +the `requests2` library to send an HTTP GET request. |
| 60 | + |
| 61 | +MicroPython Code Block: |
| 62 | + |
| 63 | + .. literalinclude:: ../../../examples/module/lte/core2_lte_http_example.py |
| 64 | + :language: python |
| 65 | + :linenos: |
| 66 | + |
| 67 | +Example output: |
| 68 | + |
| 69 | + None |
| 70 | + |
| 71 | +Chat script |
| 72 | +^^^^^^^^^^^ |
| 73 | + |
| 74 | +Set the LTE module to PPP mode through a custom AT command chat script. |
| 75 | + |
| 76 | +MicroPython Code Block: |
| 77 | + |
| 78 | + .. literalinclude:: ../../../examples/module/lte/core2_lte_chat_example.py |
| 79 | + :language: python |
| 80 | + :linenos: |
| 81 | + |
| 82 | +Example output: |
| 83 | + |
| 84 | + None |
| 85 | + |
| 86 | +**API** |
| 87 | +------- |
| 88 | + |
| 89 | +LTEModule |
| 90 | +^^^^^^^^^ |
| 91 | + |
| 92 | +.. autoclass:: module.lte.LTEModule |
| 93 | + :members: |
| 94 | + |
| 95 | + .. py:method:: active([is_active]) |
| 96 | +
|
| 97 | + Activate (“up”) or deactivate (“down”) the network interface, if a |
| 98 | + boolean argument is passed. Otherwise, query current state if no |
| 99 | + argument is provided. |
| 100 | + |
| 101 | + :param bool is_active: If True, the LTE module is enabled, if False, the LTE module is disabled. |
| 102 | + |
| 103 | + :return: Returns the activation status of the LTE module. |
| 104 | + :rtype: bool |
| 105 | + |
| 106 | + UiFlow2 Code Block: |
| 107 | + |
| 108 | + |active.png| |
| 109 | + |
| 110 | + MicroPython Code Block: |
| 111 | + |
| 112 | + .. code-block:: python |
| 113 | +
|
| 114 | + comlte_0.active(True) |
| 115 | + comlte_0.active(False) |
| 116 | + comlte_0.active() |
| 117 | +
|
| 118 | +
|
| 119 | + .. py:method:: connect(authmode=AUTH_NONE, username="", password="") |
| 120 | +
|
| 121 | + Initiate a PPP connection with the given parameters. |
| 122 | + |
| 123 | + :param int authmode: Authentication Mode, either LTEModule.AUTH_NONE, LTEModule.AUTH_PAP, or LTEModule.AUTH_CHAP. |
| 124 | + :param str username: An optional user name to use with the authentication mode. |
| 125 | + :param str password: An optional password to use with the authentication mode. |
| 126 | + |
| 127 | + :return: None |
| 128 | + |
| 129 | + UiFlow2 Code Block: |
| 130 | + |
| 131 | + |connect.png| |
| 132 | + |
| 133 | + MicroPython Code Block: |
| 134 | + |
| 135 | + .. code-block:: python |
| 136 | +
|
| 137 | + comlte_0.connect(authmode=AUTH_NONE, username="", password="") |
| 138 | + comlte_0.connect() |
| 139 | +
|
| 140 | +
|
| 141 | + .. py:method:: isconnected() |
| 142 | +
|
| 143 | + Returns True if the PPP link is connected and up. Returns False otherwise. |
| 144 | + |
| 145 | + :return: True if the PPP link is connected and up, False otherwise. |
| 146 | + :rtype: bool |
| 147 | + |
| 148 | + UiFlow2 Code Block: |
| 149 | + |
| 150 | + |isconnected.png| |
| 151 | + |
| 152 | + MicroPython Code Block: |
| 153 | + |
| 154 | + .. code-block:: python |
| 155 | +
|
| 156 | + comlte_0.isconnected() |
| 157 | +
|
| 158 | + .. py:method:: ifconfig() |
| 159 | +
|
| 160 | + Get IP-level network interface parameters: IP address, subnet mask, |
| 161 | + gateway and DNS server. This method returns a 4-tuple with the above |
| 162 | + information. |
| 163 | + |
| 164 | + :return: A 4-tuple with IP address, subnet mask, gateway and DNS server. |
| 165 | + |
| 166 | + UiFlow2 Code Block: |
| 167 | + |
| 168 | + |get_localip.png| |
| 169 | + |
| 170 | + |get_subnet.png| |
| 171 | + |
| 172 | + |get_gateway.png| |
| 173 | + |
| 174 | + |get_dns.png| |
| 175 | + |
| 176 | + MicroPython Code Block: |
| 177 | + |
| 178 | + .. code-block:: python |
| 179 | +
|
| 180 | + comlte_0.ifconfig() |
| 181 | + comlte_0.ifconfig()[0] # IP address |
| 182 | + comlte_0.ifconfig()[1] # network |
| 183 | + comlte_0.ifconfig()[2] # gateway |
| 184 | + comlte_0.ifconfig()[3] # DNS server |
0 commit comments