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
drivers: modem: gsm: allow using custom modem setup commands #39727
drivers: modem: gsm: allow using custom modem setup commands #39727
Conversation
Make modem cmd macros and structures public so that applications can use them. That is also necessary for the upcoming support of custom modem setup commands. Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
Sometimes there is a need to use a custom setup sequence for the GSM modem so add possibility to use your own setup_cmd structure with commands that are required. Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
SETUP_CMD(send_cmd_, NULL, NULL, 0U, NULL) | ||
|
||
/* series of modem setup commands to run */ | ||
struct setup_cmd { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to prefix that structure name with modem_
. The same goes for SETUP_CMD_NOHANDLE
and SETUP_CMD
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that it will be better to make a change in the next MR because in that one I wanted to make those macros public only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to make those macros public, we need to make sure they are in a proper namespace. So I would prefer renaming before making it public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. Should I do a change to the namespace in the same commit which makes this header public or split it into 2 commits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you wish, but I think having that in 2 commits might be easier to review.
/** | ||
* @brief Set custom modem setup commands. | ||
* | ||
* @param dev: gsm modem device. | ||
* @param data: custom modem setup commands array. | ||
* @param len: length of custom modem setup commands array. | ||
* | ||
* @retval None. | ||
*/ | ||
void gsm_ppp_set_custom_setup_cmds(const struct device *dev, | ||
const struct setup_cmd *data, | ||
size_t len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that going to be used by application or modem device drivers? Could you also elaborate or give an example how do you use that function in your case? I mean what exactly do you use as your "custom AT commands" and for what purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wondered how to use this function yesterday, it isn't immediately clear at least, @bbilas maybe you can modify the gsm_modem
sample and demonstrate a simple use case there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's going to be used by the application, the following example shows how I'm using it:
static const struct setup_cmd telit_setup_cmds[] = { /* Use band B20 only to speed-up registration to network */ SETUP_CMD_NOHANDLE("AT+QCFG=\"band\",0,80000,80000,1"), /* Use both NB-IoT and eMTC */ SETUP_CMD_NOHANDLE("AT+QCFG=\"iotopmode\",2,1"), /* Use NB-IoT -> eMTC scan sequence */ SETUP_CMD_NOHANDLE("AT+QCFG=\"nwscanseq\",0302,1"), /* Disable echo */ SETUP_CMD_NOHANDLE("ATE0"), }; static int modem_init(const struct device *dev) { modem = DEVICE_DT_GET(DT_NODELABEL(modem_gsm)); if (!device_is_ready(modem)) { LOG_ERR("Modem device not available!"); return -ENODEV; } /* Use custom setup commands for telit GSM modem */ gsm_ppp_set_custom_setup_cmds(modem_gsm, telit_setup_cmds, ARRAY_SIZE(telit_setup_cmds)); gsm_ppp_start(modem); return 0; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ycsin I agree that gsm_modem sample should contain some examples, I haven't thought about that. I will try to add it this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, not very relevant to this pr, have you ever thought about exposing the AT channel of the modem so that it is possible to configure the modem in application? i.e. enabling/disabling GPS, poll GPIO/ADC pins, modem FOTA, etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then we will break the API by replacing command list with callback. I would prefer callback, but let's say it is not a "must-have" from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just have both options? As I know the setup commands mostly don't need extra special logic so the simple commands replacement would be enough for some cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jukkar what is your opinion here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have big preference here, using callbacks sounds a bit more flexible so I am inclined to that direction. If both options are possible, then +1 to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mniestroj what is your opinion about having both options? Currently I would be able to get some time to finish at least the current proposition so it's still better to have this one instead of nothing.
I missed this PR because it's not prefixed with |
There's many ways to accomplish this. I will try to submit a PR today with an alternative. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Hi! |
I've re-opened that MR since I'm coming back to this topic this or next week since it's needed for my project. I'll consider your suggestions and we'll see how to deal with them. |
Stubbled across this PR and am intrigued. I can see you are attempting to use Vendor specific AT commands as part of the modem setup which has been an issue for some time. It may be worth considering a 'library' of additional vendor specific AT commands that would be included based on manufacturer as defined in the Config, ie CONFIG_MODEM_UBLOX_SARA. With the initialisation routine of various modem being a combination of hardware and software processes and timing creating a wholly generic driver may prove to be unrealistic and/or overly complex. Just some thoughts. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Sometimes there is a need to use a custom setup sequence for the GSM modem so add the possibility to use your own
setup_cmd structure with commands that are required.
Signed-off-by: Bartosz Bilas b.bilas@grinn-global.com