Skip to content
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

modem_console get_module_name does not call the SHINY function (IDFGH-11628) #452

Closed
3 tasks done
dajtxx opened this issue Dec 7, 2023 · 1 comment · Fixed by #477
Closed
3 tasks done

modem_console get_module_name does not call the SHINY function (IDFGH-11628) #452

dajtxx opened this issue Dec 7, 2023 · 1 comment · Fixed by #477
Assignees
Milestone

Comments

@dajtxx
Copy link

dajtxx commented Dec 7, 2023

Answers checklist.

  • I have read the documentation for esp-protocols components and the issue is not addressed there.
  • I have updated my esp-protocols branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

While trying to implement a custom module by experimenting with the modem_console example I found the SHINY module is not called when using the get_module_name command:

I (539) main_task: Started on CPU0
I (549) main_task: Calling app_main()
I (569) uart: queue free spaces: 30
I (569) modem_console: Initializing esp_modem for the SHINY module...

Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.
esp> get_module_name
I (19569) modem_console: Reading module name...
E (24569) modem_console: Failed with TIMEOUT
Command returned non-zero error code: 0x1 (ERROR)

The logging output shows the custom SHINY module is being used, but instead of returning the hard-coded module name from the overridden method it is calling the generic module method which issues an AT command.

@github-actions github-actions bot changed the title modem_console get_module_name does not call the SHINY function modem_console get_module_name does not call the SHINY function (IDFGH-11628) Dec 7, 2023
@david-cermak
Copy link
Collaborator

Okay, it seems that this command is overwritten in

#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, arg_nr, ...) \
return_type Shiny::DCE::name(__VA_ARGS__) { return esp_modem::dce_commands::name(this ARGS(arg_nr) ); }

I'm sorry, I wanted to demonstrate how to handle URC messages in 7547267 and forgot that this would basically replace that overridden command.
To use that command again, we need to create the dce using standard esp_modem::DCE rather than Shiny::DCE by:

diff --git a/components/esp_modem/examples/modem_console/main/modem_console_main.cpp b/components/esp_modem/examples/modem_console/main/modem_console_main.cpp
index b703d99..ba8f791 100644
--- a/components/esp_modem/examples/modem_console/main/modem_console_main.cpp
+++ b/components/esp_modem/examples/modem_console/main/modem_console_main.cpp
@@ -132,7 +132,8 @@ extern "C" void app_main(void)
 
 #if defined(CONFIG_EXAMPLE_MODEM_DEVICE_SHINY)
     ESP_LOGI(TAG, "Initializing esp_modem for the SHINY module...");
-    auto dce = create_shiny_dce(&dce_config, uart_dte, esp_netif);
+    auto dce = esp_modem::dce_factory::Factory::build_unique<MyShinyModem>(&dce_config, uart_dte, esp_netif);
 #elif defined(CONFIG_EXAMPLE_MODEM_DEVICE_BG96)
     ESP_LOGI(TAG, "Initializing esp_modem for the BG96 module...");
     auto dce = create_BG96_dce(&dce_config, uart_dte, esp_netif);

I'll fix the example and add more comments!

If you just want to modify few commands, you can check the pppos_client example (this is much simpler):

/**
* @brief Definition of a custom module based on some already defined module
* Here we use GenericModule, but you can use any kind of device
* that is closer to your CustomModule.
*/
class SIM7600_WITH_TIME: public GenericModule {
/**
* @brief Need to reuse the constructors of our ancestor
*/
using GenericModule::GenericModule;
public:
/**
* @brief New command that is not defined in the GenericModule
*/
command_result get_time(std::string &time)
{
return esp_modem::dce_commands::generic_get_string(dte.get(), "AT+CCLK?\r", time);
}
/**
* @brief This command is already defined in the GenericModule
*
* Here we just modify get_signal_quality() to return zeroes
* for demonstration purpose only, since it's called within this example
*/
command_result get_signal_quality(int &rssi, int &ber) override
{
rssi = ber = 0;
return esp_modem::command_result::OK;
}
};

(unlike the Shiny::DCE class which completely rewrites the defaults and even uses custom commands for handling URC)

@david-cermak david-cermak added this to the modem-v1.1.0 milestone Jan 8, 2024
david-cermak added a commit to david-cermak/esp-protocols that referenced this issue Jan 22, 2024
1.1.0
Features
- Added support for at_raw() command (ae38110, espressif#471)
- Added iperf test for PPP netifs (976e98d)
- Added test that performs OTA to exercise modem layers (f2223dd)
Bug Fixes
- Fixed OTA test to gracefully fail with no verification (1dc4299)
- Added C-API to configure APN (ce7dadd, espressif#485)
- Fixed AT commands to copy strings to prevent overrides (741d166, espressif#463)
- Fixed incorrect dial command format (0998f3d, espressif#433)
- Fixed documentation and example on creating custom device (577de67, espressif#452)
- Removed CI jobs for IDF v4.2 (d88cd61)
- Fixed OAT test to verify server cert and CN (edc3e72)
- Fixed set_pdp_context() command timeout (1d80cbc, espressif#455)
Updated
- docs(modem): Added description of manual test procedure (68ce794)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants