STMOD_CELLULAR: improve debug print

pull/12011/head
jeromecoutant 2019-12-03 11:40:25 +01:00
parent a8ee2d8c7d
commit 00d91149cc
2 changed files with 64 additions and 36 deletions

View File

@ -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). 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 ## Cellular tests in mbed-os
- features-cellular-tests-api-cellular_device Since mbed-os-5.14.1, cellular tests have been replaced with generic mbed-os netsocket and network interface tests.
- features-cellular-tests-api-cellular_information
- features-cellular-tests-api-cellular_network
- features-cellular-tests-api-cellular_sms
- features-cellular-tests-socket-udp
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": { "config": {
"cellular-sim-pin" : { "echo-server-discard-port": {
"help": "PIN code", "help": "Discard port of echo server",
"value": "\"1234\"" "value": "9
}, },
"apn": { "echo-server-discard-port-tls": {
"help": "The APN string to use for this SIM/network, set to 0 if none", "help": "Discard port of echo server",
"value": "\"APN\"" "value": "2009"
}, },
"username": { "echo-server-port": {
"help": "The user name string to use for this APN, set to zero if none", "help": "Port of echo server",
"value": 0 "value": "7"
}, },
"password": { "echo-server-port-tls": {
"help": "The password string to use for this APN, set to 0 if none", "help": "Echo port of echo server",
"value": 0 "value": "2007"
} },
}, },
"target_overrides": { "target_overrides": {
"DISCO_L496AG": { "DISCO_L496AG": {
"target.components_add": ["STMOD_CELLULAR"], "target.components_add": [
"stmod_cellular.provide-default": "true" "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 ## Cellular mbed-os example

View File

@ -19,7 +19,7 @@
#include "rtos/ThisThread.h" #include "rtos/ThisThread.h"
#include "mbed_trace.h" #include "mbed_trace.h"
#define TRACE_GROUP "CELL" #define TRACE_GROUP "STMOD"
using namespace mbed; 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_clk(MBED_CONF_STMOD_CELLULAR_SIM_CLK),
m_sim_data(MBED_CONF_STMOD_CELLULAR_SIM_DATA) m_sim_data(MBED_CONF_STMOD_CELLULAR_SIM_DATA)
{ {
tr_debug("STModCellular creation\r\n"); tr_info("STModCellular creation");
// start with modem disabled // start with modem disabled
m_powerkey.write(0); m_powerkey.write(0);
@ -54,10 +54,10 @@ STModCellular::~STModCellular()
nsapi_error_t STModCellular::soft_power_on() 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) #if (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_UG96)
tr_debug("Booting UG96\r\n"); tr_info("Booting UG96");
m_reset.write(1); m_reset.write(1);
rtos::ThisThread::sleep_for(200); rtos::ThisThread::sleep_for(200);
m_reset.write(0); m_reset.write(0);
@ -68,9 +68,8 @@ nsapi_error_t STModCellular::soft_power_on()
/* Because modem status is not available on STMOD+ connector, /* Because modem status is not available on STMOD+ connector,
* let's wait for Modem complete boot */ * let's wait for Modem complete boot */
rtos::ThisThread::sleep_for(2300); rtos::ThisThread::sleep_for(2300);
#endif #elif (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_BG96)
#if (MBED_CONF_STMOD_CELLULAR_TYPE == STMOD_BG96) tr_info("Booting BG96");
tr_debug("Booting BG96\r\n");
m_powerkey.write(1); m_powerkey.write(1);
m_reset.write(1); m_reset.write(1);
rtos::ThisThread::sleep_for(150); rtos::ThisThread::sleep_for(150);
@ -107,10 +106,10 @@ nsapi_error_t STModCellular::soft_power_on()
_at->restore_at_timeout(); _at->restore_at_timeout();
_at->unlock(); _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)) { 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); pin_mode(MBED_CONF_STMOD_CELLULAR_CTS, PullDown);
@ -127,9 +126,9 @@ nsapi_error_t STModCellular::soft_power_on()
_at->unlock(); _at->unlock();
if (err == NSAPI_ERROR_OK) { if (err == NSAPI_ERROR_OK) {
tr_debug("Flow control turned ON\r\n"); tr_debug("Flow control turned ON");
} else { } 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" #include "UARTSerial.h"
CellularDevice *CellularDevice::get_default_instance() 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); 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)) { 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); serial.set_flow_control(SerialBase::RTSCTS, MBED_CONF_STMOD_CELLULAR_RTS, MBED_CONF_STMOD_CELLULAR_CTS);
} }
static STModCellular device(&serial); static STModCellular device(&serial);