Hi,
First, you have to consider 2 usecases:
- the IP stack is runnning in the modem (what we call "socket mode" in X-Cube-Cellular)
- the IP stack is running STM32-side with LwIP (what we call "LwIP mode" in X-Cube-Cellular)
If you are using "LwIP mode", adding a new modem should be easy because you can use standard AT commands.
If you want to use the "socket mode", it is more complicated. First, the modem has to support this mode.
Then each modem has its own proprietary implementation for "socket mode", with specific AT commands.
As there may be huge differences between 2 modems, it's difficult to evaluate the amount of work in this case.
So, I recommend to use "LwIP mode", at least on first approach.
The disavantage of the LwIP solution is that it is more memory consuming in STM32 side.
Note: to use "LwIP mode", set USE_SOCKETS_TYPE to USE_SOCKETS_LWIP in the file plf_features.h
The easiest way is to use one existing modem implementation and 'hack' it.
I suggest to use 'MONARCH' as a starting point because its implementation is using more standard commands than Quectel's one
(BG96 and UG96 are using optimized commands for some features).
All modifications you have to do are located in \Drivers\BSP\X_STMOD_PLUS_MODEMS\your_modem directory
So, in case of "LwIP mode", here are the main things to add a new modem:
STEP 1/ adapt the "hardware" interface with the modem
This is done in the file sysctrl_specific.c
You need to customize the funtions for Power ON, Power Off, Reset (Hardware reset) and sim selection.
There are certainly some timings to respect with GPIO during power ON and power Off sequences.
(note: some modems are using AT commands only for reset and sim selection).
STEP 2/ adapt the AT commands to use
This is done in the file at_custom_modem_specific.c
At the beginning of this file, there is a commands Look-up table.
If you are using LwIP, it should work using only "GENERIC SPECIFIC COMMANDS" (from 3GPP TS 27.007 and GSM 07.07 and V25ter) which are implemented in at_modem_signalling.c (this file regroup functions to encode/decode standard AT commands).
In the function ATCustom_***_getCmd(), you may have to adapt following cases:
- SID_CS_POWER_ON
- SID_CS_RESET
- SID_CS_POWER_OFF
- SID_CS_INIT_MODEM
Indeed, these steps can use modem specific AT commands or custom AT commands sequence.
You can also have to manage a modem 'start event' which is modem specific (+SYSSTART for the MONARCH), it''s not mandatory.
If you are using "MONARCH" as starting point, I think that in the Look-up table, you just have to replace fCmdBuild_ATD_MONARCH by fCmdBuild_ATD.
All other commands are already using standard commands if I'm not wrong...
and it should be almost all what you have to do !
NB:
The file at_custom_modem_signalling.c contains only modem specific command (new features or override standard commands).
The file at_custom_modem_socket.c contains only modem specific for the socket mode.
You should not have to modify/use them for LwIP.
If you are using another STM32 board or if your modem is not using same GPIOs as the original project, you will have also to update the file plf_hw_config.h where are defined the UART settings and all the GPIOs used between the STM32 and the modem.