Skip to content

STMOD_CELLULAR: improve debug print #12011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 53 additions & 23 deletions components/cellular/COMPONENT_STMOD_CELLULAR/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,78 @@ 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.

https://github.com/ARMmbed/mbed-os/blob/master/TESTS/netsocket/README.md

Here is the used mbed_app.json:
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"
}
}
}
````


````
$ 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
Expand Down
24 changes: 11 additions & 13 deletions components/cellular/COMPONENT_STMOD_CELLULAR/STModCellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "rtos/ThisThread.h"
#include "mbed_trace.h"

#define TRACE_GROUP "CELL"
#define TRACE_GROUP "STMOD"

using namespace mbed;

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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");
}
}

Expand Down Expand Up @@ -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);
Expand Down