Skip to content

Add HL78XX Modem Driver Implementation Using Modem Chat Framework #89541

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

zafersn
Copy link
Contributor

@zafersn zafersn commented May 6, 2025

This pull request introduces the initial draft implementation of the HL78XX modem driver, built on the modem_chat framework. The current version establishes the core structure and essential functionality required to support the HL78XX modem series.

The primary objective at this stage is to review and align on the overall design and integration approach. Following this, development will continue with additional features such as:

  • Power saving mode support

  • User pipe connection handling

  • Other modem-specific enhancements

  • Verified compatibility and correct operation with the following sample applications:

    • aws_mqtt
    • dns_resolve
    • big_http_download
    • lwm2m

Feedback on both structure and test approach is welcome.

@rerickson1 rerickson1 self-requested a review May 6, 2025 14:48
@rerickson1 rerickson1 self-assigned this May 6, 2025
if MODEM_HL78XX

choice MODEM_HL78XX_VARIANT
bool "Sierre Wireless hl781x variant selection"
Copy link
Member

Choose a reason for hiding this comment

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

Should be Sierra. Or should we change all references to Semtech now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not quite sure, but Sierre still seems to be good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't see any good explanation for this, but the packages and everything that they show it is Sierra Wireless.
they might have kept the copyright on the Sierra Wireless name as well

@zafersn zafersn force-pushed the hl78xx_driver branch 2 times, most recently from 31e6d9f to b1e6ffc Compare May 8, 2025 10:27
@nashif nashif requested a review from Copilot May 8, 2025 11:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces the initial HL78XX modem driver implementation based on the modem_chat framework while updating sample applications to integrate power management calls. Key changes include:

  • Adding power management includes and calls in sample applications to power on the modem.
  • Enhancing the modem socket poll routine with temporary POLLOUT handling.
  • Introducing new HL78XX utility and header files to support modem functionality.

Reviewed Changes

Copilot reviewed 8 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
samples/net/lwm2m_client/src/lwm2m-client.c Added power management headers and a power-on invocation for the HL78XX modem.
samples/net/cloud/aws_iot_mqtt/src/main.c Added similar power management initialization for the modem in the AWS IoT MQTT sample.
drivers/modem/modem_socket.c Updated POLLOUT event handling with temporary logging and fallback behavior.
drivers/modem/hl78xx/hl78xx_utility.c Added HL78XX utility functions; note an inconsistent module name in the log registration.
drivers/modem/hl78xx/hl78xx.h Introduced declarations and definitions supporting the HL78XX modem driver.
Files not reviewed (6)
  • drivers/modem/CMakeLists.txt: Language not supported
  • drivers/modem/Kconfig: Language not supported
  • drivers/modem/hl78xx/CMakeLists.txt: Language not supported
  • samples/net/cloud/aws_iot_mqtt/boards/hl78xx_chat.conf: Language not supported
  • samples/net/lwm2m_client/Kconfig: Language not supported
  • samples/net/lwm2m_client/overlay-hl78xx_chat.conf: Language not supported
Comments suppressed due to low confidence (1)

drivers/modem/hl78xx/hl78xx_utility.c:18

  • [nitpick] The module name 'hl7812_utility' appears inconsistent with the HL78XX naming convention used elsewhere. Consider renaming it to 'hl78xx_utility' for naming consistency.
LOG_MODULE_REGISTER(hl7812_utility, CONFIG_MODEM_LOG_LEVEL);

@zafersn zafersn force-pushed the hl78xx_driver branch 16 times, most recently from c4e404b to df0f647 Compare May 12, 2025 11:04
@zafersn zafersn marked this pull request as ready for review May 12, 2025 13:10
@zafersn zafersn requested review from rerickson1 and rlubos May 16, 2025 15:27
@zafersn zafersn force-pushed the hl78xx_driver branch 8 times, most recently from 070889d to a7f1641 Compare May 18, 2025 22:15
Adding HL78XX Modem Driver Implementation Using Modem Chat Framework

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
@zafersn zafersn force-pushed the hl78xx_driver branch 4 times, most recently from 416d248 to e8af631 Compare May 19, 2025 19:36
Add HL78xx driver sample application to show hl78xx user APIs & Configs

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Copy link

@zafersn
Copy link
Contributor Author

zafersn commented May 19, 2025

@rerickson1 ,

I added an event notifier/dispatcher to let the app layer know when something happens with the modem, like different events or status changes. I included a basic example of how this works in the sample app here:

static void evnt_listener(struct hl78xx_evt *event)
{
#ifdef CONFIG_MODEM_HL78XX_LOG_CONTEXT_VERBOSE_DEBUG
LOG_DBG("%d HL78XX modem Event Received: %d", __LINE__, event->type);
#endif
switch (event->type) {
/* Do something */
case HL78XX_RAT_UPDATE:
LOG_DBG("%d HL78XX modem rat mode changed: %d", __LINE__, event->content.rat_mode);
break;
case HL78XX_LTE_REGISTRATION_STAT_UPDATE:
LOG_DBG("%d HL78XX modem registration status: %d", __LINE__,
event->content.reg_status);
break;
case HL78XX_LTE_SIM_REGISTRATIION:
break;
case HL78XX_LTE_PSMEV:
break;
default:
break;
}
}

Originally, I planned to replicate AT_MONITOR from the nRF SDK (https://github.com/nrfconnect/sdk-nrf/blob/main/lib/at_monitor/at_monitor.c) and just forward all URCs (unsolicited result codes)/ at cmd traffics to the app layer directly. But that would have required changes in the modem_chat driver, which I wanted to avoid.

So instead, I went with a cleaner approach, the event notifier. Now, whenever the modem reports something like registration status changes, PSM updates, RAT mode changes, etc., those events get pushed to all registered listeners.


choice MODEM_HL78XX_VARIANT
bool "Sierra Wireless hl78xx variant selection"
default MODEM_HL7812
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't MODEM_HL78XX_AUTODETECT_VARIANT be a better default here?

Comment on lines +90 to +91
help
The address family for IP connections.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
help
The address family for IP connections.
help
The address family for IP connections.

Comment on lines +140 to +142
help
- Keep the device in boot mode untiL have +CREG/+CEREG: 1(normal) or 5(roaming)
endif # MODEM_HL78XX_BOOT_IN_FULLY_FUNCTIONAL_MODE
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
help
- Keep the device in boot mode untiL have +CREG/+CEREG: 1(normal) or 5(roaming)
endif # MODEM_HL78XX_BOOT_IN_FULLY_FUNCTIONAL_MODE
help
Keep the device in boot mode untiL have +CREG/+CEREG: 1(normal) or 5(roaming)
endif # MODEM_HL78XX_BOOT_IN_FULLY_FUNCTIONAL_MODE

}

/* Initialize during SYS_INIT */
SYS_INIT(hl78xx_evt_monitor_sys_init, APPLICATION, 0);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a kconfig for application level priority?

Comment on lines +107 to +109
}
void hl78xx_on_kstatev_parser(struct hl78xx_data *data, int state)
{
Copy link
Member

Choose a reason for hiding this comment

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

Check clang formatting on all files.

Suggested change
}
void hl78xx_on_kstatev_parser(struct hl78xx_data *data, int state)
{
}
void hl78xx_on_kstatev_parser(struct hl78xx_data *data, int state)
{

Comment on lines +132 to +135
}
static bool parse_ip(bool is_ipv4, const char *ip_str, void *out_addr)
{
int ret = net_addr_pton(is_ipv4 ? AF_INET : AF_INET6, ip_str, out_addr);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
static bool parse_ip(bool is_ipv4, const char *ip_str, void *out_addr)
{
int ret = net_addr_pton(is_ipv4 ? AF_INET : AF_INET6, ip_str, out_addr);
}
static bool parse_ip(bool is_ipv4, const char *ip_str, void *out_addr)
{
int ret = net_addr_pton(is_ipv4 ? AF_INET : AF_INET6, ip_str, out_addr);

Comment on lines +406 to +407
}
void iface_status_work_cb(struct hl78xx_data *data, modem_chat_script_callback script_user_callback)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
void iface_status_work_cb(struct hl78xx_data *data, modem_chat_script_callback script_user_callback)
}
void iface_status_work_cb(struct hl78xx_data *data, modem_chat_script_callback script_user_callback)

Comment on lines +419 to +421
}
void dns_work_cb(void)
{
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
void dns_work_cb(void)
{
}
void dns_work_cb(void)
{

Comment on lines +1057 to +1060
}
/* send binary data via the +KUDPSND commands */
static ssize_t send_socket_data(void *obj, const struct sockaddr *dst_addr, const char *buf,
size_t buf_len, k_timeout_t timeout)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
/* send binary data via the +KUDPSND commands */
static ssize_t send_socket_data(void *obj, const struct sockaddr *dst_addr, const char *buf,
size_t buf_len, k_timeout_t timeout)
}
/* send binary data via the +KUDPSND commands */
static ssize_t send_socket_data(void *obj, const struct sockaddr *dst_addr, const char *buf,
size_t buf_len, k_timeout_t timeout)

Comment on lines +1146 to +1148
}
static ssize_t offload_sendto(void *obj, const void *buf, size_t len, int flags,
const struct sockaddr *to, socklen_t tolen)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
static ssize_t offload_sendto(void *obj, const void *buf, size_t len, int flags,
const struct sockaddr *to, socklen_t tolen)
}
static ssize_t offload_sendto(void *obj, const void *buf, size_t len, int flags,
const struct sockaddr *to, socklen_t tolen)

CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_INIT_STACKS=y
CONFIG_HW_STACK_PROTECTION=y
CONFIG_REQUIRES_FULL_LIBC=y
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Member

Choose a reason for hiding this comment

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

This feels overly complicated for such a simple sample. Can this be optimized to only include options that are absolutely necessary?

pm_device_action_run(modem, PM_DEVICE_ACTION_RESUME);
#endif

#ifdef CONFIG_MODEM_HL78XX_BOOT_IN_FULLY_FUNCTIONAL_MODE
Copy link
Member

Choose a reason for hiding this comment

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

What about other boot modes? How can they be used? Can the user then change at runtime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants