mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #12011 from jeromecoutant/PR_STMOD_DEBUG
STMOD_CELLULAR: improve debug printpull/12025/head
commit
020e508e42
|
@ -11,40 +11,70 @@ and [p-l496g-cell02](https://www.st.com/en/evaluation-tools/p-l496g-cell02.html)
|
|||
|
||||
The STMOD+ Connector specification can be found [here](https://www.st.com/content/ccc/resource/technical/document/technical_note/group0/04/7f/90/c1/ad/54/46/1f/DM00323609/files/DM00323609.pdf/jcr:content/translations/en.DM00323609.pdf).
|
||||
|
||||
## Debug print
|
||||
|
||||
mbed_trace feature is used: https://github.com/ARMmbed/mbed-os/blob/master/features/frameworks/mbed-trace/README.md
|
||||
|
||||
Enable it in your mbed_app.json file:
|
||||
|
||||
````
|
||||
{
|
||||
"target_overrides": {
|
||||
"*": {
|
||||
"mbed-trace.enable": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
Look for "STMOD" group name:
|
||||
````
|
||||
[DBG ][STMOD]: STMOD_CELLULAR default instance
|
||||
[INFO][STMOD]: STModCellular creation
|
||||
[DBG ][STMOD]: STMOD cellular modem power ON
|
||||
[INFO][STMOD]: Booting BG96
|
||||
[INFO][STMOD]: Modem ready to receive AT commands
|
||||
[INFO][STMOD]: Enable flow control
|
||||
[DBG ][STMOD]: Flow control turned ON
|
||||
````
|
||||
|
||||
|
||||
## Cellular tests in mbed-os
|
||||
|
||||
- features-cellular-tests-api-cellular_device
|
||||
- features-cellular-tests-api-cellular_information
|
||||
- features-cellular-tests-api-cellular_network
|
||||
- features-cellular-tests-api-cellular_sms
|
||||
- features-cellular-tests-socket-udp
|
||||
Since mbed-os-5.14.1, cellular tests have been replaced with generic mbed-os netsocket and network interface tests.
|
||||
|
||||
Here is the used mbed_app.json:
|
||||
https://github.com/ARMmbed/mbed-os/blob/master/TESTS/netsocket/README.md
|
||||
|
||||
Here is an example of needed mbed_app.json:
|
||||
|
||||
````
|
||||
{
|
||||
"config": {
|
||||
"cellular-sim-pin" : {
|
||||
"help": "PIN code",
|
||||
"value": "\"1234\""
|
||||
"echo-server-discard-port": {
|
||||
"help": "Discard port of echo server",
|
||||
"value": "9
|
||||
},
|
||||
"apn": {
|
||||
"help": "The APN string to use for this SIM/network, set to 0 if none",
|
||||
"value": "\"APN\""
|
||||
"echo-server-discard-port-tls": {
|
||||
"help": "Discard port of echo server",
|
||||
"value": "2009"
|
||||
},
|
||||
"username": {
|
||||
"help": "The user name string to use for this APN, set to zero if none",
|
||||
"value": 0
|
||||
"echo-server-port": {
|
||||
"help": "Port of echo server",
|
||||
"value": "7"
|
||||
},
|
||||
"password": {
|
||||
"help": "The password string to use for this APN, set to 0 if none",
|
||||
"value": 0
|
||||
}
|
||||
},
|
||||
"echo-server-port-tls": {
|
||||
"help": "Echo port of echo server",
|
||||
"value": "2007"
|
||||
},
|
||||
},
|
||||
"target_overrides": {
|
||||
"DISCO_L496AG": {
|
||||
"target.components_add": ["STMOD_CELLULAR"],
|
||||
"stmod_cellular.provide-default": "true"
|
||||
"target.components_add": [
|
||||
"STMOD_CELLULAR"
|
||||
],
|
||||
"stmod_cellular.provide-default": "true",
|
||||
"nsapi.default-cellular-apn": "\"APN\"",
|
||||
"target.network-default-interface-type": "CELLULAR"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +82,7 @@ Here is the used mbed_app.json:
|
|||
|
||||
|
||||
````
|
||||
$ mbed test -t ARM -m DISCO_L496AG -v -n features-cellular-*
|
||||
$ mbed test -t ARM -m DISCO_L496AG -v -n tests-net*
|
||||
````
|
||||
|
||||
## Cellular mbed-os example
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "rtos/ThisThread.h"
|
||||
#include "mbed_trace.h"
|
||||
|
||||
#define TRACE_GROUP "CELL"
|
||||
#define TRACE_GROUP "STMOD"
|
||||
|
||||
using namespace mbed;
|
||||
|
||||
|
@ -33,7 +33,7 @@ STModCellular::STModCellular(FileHandle *fh) : STMOD_CELLULAR_MODEM(fh),
|
|||
m_sim_clk(MBED_CONF_STMOD_CELLULAR_SIM_CLK),
|
||||
m_sim_data(MBED_CONF_STMOD_CELLULAR_SIM_DATA)
|
||||
{
|
||||
tr_debug("STModCellular creation\r\n");
|
||||
tr_info("STModCellular creation");
|
||||
|
||||
// start with modem disabled
|
||||
m_powerkey.write(0);
|
||||
|
@ -54,10 +54,10 @@ STModCellular::~STModCellular()
|
|||
|
||||
nsapi_error_t STModCellular::soft_power_on()
|
||||
{
|
||||
tr_debug("STMOD cellular modem power ON\r\n");
|
||||
tr_debug("STMOD cellular modem power ON");
|
||||
|
||||
#if (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_UG96)
|
||||
tr_debug("Booting UG96\r\n");
|
||||
tr_info("Booting UG96");
|
||||
m_reset.write(1);
|
||||
rtos::ThisThread::sleep_for(200);
|
||||
m_reset.write(0);
|
||||
|
@ -68,9 +68,8 @@ nsapi_error_t STModCellular::soft_power_on()
|
|||
/* Because modem status is not available on STMOD+ connector,
|
||||
* let's wait for Modem complete boot */
|
||||
rtos::ThisThread::sleep_for(2300);
|
||||
#endif
|
||||
#if (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_BG96)
|
||||
tr_debug("Booting BG96\r\n");
|
||||
#elif (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_BG96)
|
||||
tr_info("Booting BG96");
|
||||
m_powerkey.write(1);
|
||||
m_reset.write(1);
|
||||
rtos::ThisThread::sleep_for(150);
|
||||
|
@ -107,10 +106,10 @@ nsapi_error_t STModCellular::soft_power_on()
|
|||
_at->restore_at_timeout();
|
||||
_at->unlock();
|
||||
|
||||
tr_debug("Modem %sready to receive AT commands\r\n", rdy ? "" : "NOT ");
|
||||
tr_info("Modem %sready to receive AT commands", rdy ? "" : "NOT ");
|
||||
|
||||
if ((MBED_CONF_STMOD_CELLULAR_CTS != NC) && (MBED_CONF_STMOD_CELLULAR_RTS != NC)) {
|
||||
tr_debug("Enable flow control\r\n");
|
||||
tr_info("Enable flow control");
|
||||
|
||||
pin_mode(MBED_CONF_STMOD_CELLULAR_CTS, PullDown);
|
||||
|
||||
|
@ -127,9 +126,9 @@ nsapi_error_t STModCellular::soft_power_on()
|
|||
_at->unlock();
|
||||
|
||||
if (err == NSAPI_ERROR_OK) {
|
||||
tr_debug("Flow control turned ON\r\n");
|
||||
tr_debug("Flow control turned ON");
|
||||
} else {
|
||||
tr_error("Failed to enable hw flow control\r\n");
|
||||
tr_error("Failed to enable hw flow control");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,11 +159,10 @@ nsapi_error_t STModCellular::soft_power_off()
|
|||
#include "UARTSerial.h"
|
||||
CellularDevice *CellularDevice::get_default_instance()
|
||||
{
|
||||
tr_debug("MODEM default instance\r\n");
|
||||
tr_debug("STMOD_CELLULAR default instance");
|
||||
|
||||
static UARTSerial serial(MBED_CONF_STMOD_CELLULAR_TX, MBED_CONF_STMOD_CELLULAR_RX, MBED_CONF_STMOD_CELLULAR_BAUDRATE);
|
||||
if ((MBED_CONF_STMOD_CELLULAR_CTS != NC) && (MBED_CONF_STMOD_CELLULAR_RTS != NC)) {
|
||||
tr_debug("STMOD_CELLULAR flow control: RTS %d CTS %d\r\n", MBED_CONF_STMOD_CELLULAR_RTS, MBED_CONF_STMOD_CELLULAR_CTS);
|
||||
serial.set_flow_control(SerialBase::RTSCTS, MBED_CONF_STMOD_CELLULAR_RTS, MBED_CONF_STMOD_CELLULAR_CTS);
|
||||
}
|
||||
static STModCellular device(&serial);
|
||||
|
|
Loading…
Reference in New Issue