Skip to content

drivers/gsm: add a (generic) gsm driver, with support for UBlox and Quectel.#10086

Closed
maxvankessel wants to merge 5 commits intoRIOT-OS:masterfrom
maxvankessel:pr/modem
Closed

drivers/gsm: add a (generic) gsm driver, with support for UBlox and Quectel.#10086
maxvankessel wants to merge 5 commits intoRIOT-OS:masterfrom
maxvankessel:pr/modem

Conversation

@maxvankessel
Copy link
Copy Markdown
Contributor

@maxvankessel maxvankessel commented Sep 30, 2018

Contribution description

I've extended the PR #8602 "gsm" driver from @vincent-d.
Features of the PR (which incorporates functionality from other PR's):

  • Generic modem commands, e.g. IMEI, IMSI, SIM PIN & PUK.
  • GPRS commands, e.g. activating contexts, getting IP addresses of contexts.
  • Basic call interface, which needs to be extended.
  • SMS functionality.
  • Basic API for modem specific commands, e.g. poweron, poweroff, sleep.
  • Specific implementation for Quectel and UBlox devices.

Testing procedure

Example is included in the example directory. It holds numerous shell commands for communicating with the modem.

The example uses the generic gsm module for communicating with the modem. And due to the generic nature, it doesn't know how to power up the modem (which is also specific for different modems). So it has to be powered manually. Specific implementations hold these power up sequences.

Issues/PRs references

#8943

@miri64 miri64 added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: drivers Area: Device drivers labels Sep 30, 2018
@maxvankessel maxvankessel changed the title pr/modem drivers/gsm: add a (generic) gsm driver, with support for UBlox and Quectel. Oct 1, 2018
@tcschmidt tcschmidt requested a review from vincent-d October 19, 2018 16:51
@miri64 miri64 mentioned this pull request Dec 16, 2018
bool invert_status_pin; /**< select inversion of status pin */
gpio_t reset_pin; /**< quectel reset pin*/
bool invert_reset_pin; /**< select inversion of reset pin*/
gpio_t dtr_pin; /**< quectel dtr pin (modem intput) */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this dtr_pin seems to be very common in modem equipment. I think it makes sense to make it part of the gsm params, similar to the ri_pin. Also, typo in comment: intput.

@stale
Copy link
Copy Markdown

stale bot commented Aug 18, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 18, 2019
@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 28, 2019

@leandrolanzieri could you maybe have a look at this?

@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Aug 28, 2019
@leandrolanzieri
Copy link
Copy Markdown
Contributor

@leandrolanzieri could you maybe have a look at this?

Sure, will do

Copy link
Copy Markdown
Contributor

@leandrolanzieri leandrolanzieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxvankessel thanks for this. It's a long PR so I still haven't gone through all the modules, here are some comments mostly on the basic gsm module. More to come ;-) I'm trying to test this on an UBlox module, yet with no success. It would be nice to have someone test this on a Quectel.

EDIT: Also, please rebase before addressing any changes.

@@ -0,0 +1,97 @@
/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the vendor specific headers being added in this commit?

extern "C" {
#endif

typedef enum {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation for these enums and structs.

/**
* @brief gsm thread stack size
*/
#ifndef GSM_THREAD_STACKSIZE
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess some of the macros could be added to the compile configuration group (config)?

* @brief small line buffer size
*/
#ifndef GSM_AT_LINEBUFFER_SIZE_SMALL
#define GSM_AT_LINEBUFFER_SIZE_SMALL (32)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could spare a comment on what's the use of these two sizes? So the user knows what this config is affecting.

*
* @param[in] dev device to act on
*
* @return 0 for succes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return 0 for succes
* @return 0 for success

bool quotes = false;

pos += fmt_str(pos, "AT+CPIN=");
if (strlen(puk) == 8) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not safe. Calling strlen with a NULL pointer has an undefined behaviour, and this is being directly called with NULL from gsm_set_pin.

return res;
}

int __attribute__((weak)) gsm_signal_to_rssi(unsigned rssi)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving the specific implementation to the driver?


int res = at_send_cmd_get_resp(&dev->at_dev, "AT+CSQ", buf, sizeof(buf),
GSM_SERIAL_TIMEOUT_US);
if ((res > 2) && strncmp(buf, "+CSQ: ", 6) == 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the 2 come from?

}


ssize_t gsm_cmd(gsm_t *dev, const char *cmd, uint8_t *buf, size_t len, unsigned timeout)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function could be reused by others in the module.


#endif

#ifdef GSM_HAS_THREAD
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this macro logic could be simplified as right now there is no use for the thread unless AT_URC is being used.

@stale
Copy link
Copy Markdown

stale bot commented Mar 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Mar 20, 2020
@stale stale bot closed this Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers State: stale State: The issue / PR has no activity for >185 days Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants