drivers: modem: hl7800: Add delayed start
Allow application control for starting modem driver. This allows network attach to be randomized. Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
This commit is contained in:
parent
b83681d156
commit
11e992099b
3 changed files with 39 additions and 17 deletions
|
@ -269,4 +269,9 @@ config MODEM_HL7800_GET_IP_ADDR_INFO_ATTEMPTS
|
||||||
int "Number of attempts to get IP address info during init"
|
int "Number of attempts to get IP address info during init"
|
||||||
default 4
|
default 4
|
||||||
|
|
||||||
|
config MODEM_HL7800_DELAY_START
|
||||||
|
bool "Delay secondary initialization of driver and network attach"
|
||||||
|
help
|
||||||
|
When true the application must call mdm_hl7800_reset.
|
||||||
|
|
||||||
endif # MODEM_HL7800
|
endif # MODEM_HL7800
|
||||||
|
|
|
@ -557,6 +557,7 @@ static int write_apn(char *access_point_name);
|
||||||
#ifdef CONFIG_MODEM_HL7800_LOW_POWER_MODE
|
#ifdef CONFIG_MODEM_HL7800_LOW_POWER_MODE
|
||||||
static void mark_sockets_for_reconfig(void);
|
static void mark_sockets_for_reconfig(void);
|
||||||
#endif
|
#endif
|
||||||
|
static void hl7800_build_mac(struct hl7800_iface_ctx *ictx);
|
||||||
|
|
||||||
#ifdef CONFIG_MODEM_HL7800_FW_UPDATE
|
#ifdef CONFIG_MODEM_HL7800_FW_UPDATE
|
||||||
static char *get_fota_state_string(enum mdm_hl7800_fota_state state);
|
static char *get_fota_state_string(enum mdm_hl7800_fota_state state);
|
||||||
|
@ -4189,6 +4190,19 @@ reboot:
|
||||||
allow_sleep(sleep);
|
allow_sleep(sleep);
|
||||||
/* trigger APN update event */
|
/* trigger APN update event */
|
||||||
event_handler(HL7800_EVENT_APN_UPDATE, &ictx.mdm_apn);
|
event_handler(HL7800_EVENT_APN_UPDATE, &ictx.mdm_apn);
|
||||||
|
|
||||||
|
#ifdef CONFIG_MODEM_HL7800_DELAY_START
|
||||||
|
if (!ictx.initialized) {
|
||||||
|
if (ictx.iface != NULL) {
|
||||||
|
hl7800_build_mac(&ictx);
|
||||||
|
net_if_set_link_addr(ictx.iface, ictx.mac_addr,
|
||||||
|
sizeof(ictx.mac_addr),
|
||||||
|
NET_LINK_ETHERNET);
|
||||||
|
ictx.initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -4810,19 +4824,15 @@ static struct net_offload offload_funcs = {
|
||||||
.put = offload_put,
|
.put = offload_put,
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline uint8_t *hl7800_get_mac(const struct device *dev)
|
/* Use the last 6 digits of the IMEI as the mac address */
|
||||||
|
static void hl7800_build_mac(struct hl7800_iface_ctx *ictx)
|
||||||
{
|
{
|
||||||
struct hl7800_iface_ctx *ctx = dev->data;
|
ictx->mac_addr[0] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 6];
|
||||||
|
ictx->mac_addr[1] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 5];
|
||||||
/* use the last 6 digits of the IMEI as the mac address */
|
ictx->mac_addr[2] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 4];
|
||||||
ctx->mac_addr[0] = ictx.mdm_imei[MDM_HL7800_IMEI_STRLEN - 6];
|
ictx->mac_addr[3] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 3];
|
||||||
ctx->mac_addr[1] = ictx.mdm_imei[MDM_HL7800_IMEI_STRLEN - 5];
|
ictx->mac_addr[4] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 2];
|
||||||
ctx->mac_addr[2] = ictx.mdm_imei[MDM_HL7800_IMEI_STRLEN - 4];
|
ictx->mac_addr[5] = ictx->mdm_imei[MDM_HL7800_IMEI_STRLEN - 1];
|
||||||
ctx->mac_addr[3] = ictx.mdm_imei[MDM_HL7800_IMEI_STRLEN - 3];
|
|
||||||
ctx->mac_addr[4] = ictx.mdm_imei[MDM_HL7800_IMEI_STRLEN - 2];
|
|
||||||
ctx->mac_addr[5] = ictx.mdm_imei[MDM_HL7800_IMEI_STRLEN - 1];
|
|
||||||
|
|
||||||
return ctx->mac_addr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MODEM_HL7800_FW_UPDATE
|
#ifdef CONFIG_MODEM_HL7800_FW_UPDATE
|
||||||
|
@ -4903,7 +4913,6 @@ static int hl7800_init(const struct device *dev)
|
||||||
}
|
}
|
||||||
net_if_flag_set(ictx.iface, NET_IF_NO_AUTO_START);
|
net_if_flag_set(ictx.iface, NET_IF_NO_AUTO_START);
|
||||||
|
|
||||||
(void)memset(&ictx, 0, sizeof(ictx));
|
|
||||||
/* init sockets */
|
/* init sockets */
|
||||||
for (i = 0; i < MDM_MAX_SOCKETS; i++) {
|
for (i = 0; i < MDM_MAX_SOCKETS; i++) {
|
||||||
ictx.sockets[i].socket_id = -1;
|
ictx.sockets[i].socket_id = -1;
|
||||||
|
@ -5064,7 +5073,11 @@ static int hl7800_init(const struct device *dev)
|
||||||
RX_THREAD_PRIORITY, 0, K_NO_WAIT),
|
RX_THREAD_PRIORITY, 0, K_NO_WAIT),
|
||||||
"hl7800 rx");
|
"hl7800 rx");
|
||||||
|
|
||||||
|
#ifdef CONFIG_MODEM_HL7800_DELAY_START
|
||||||
|
modem_reset();
|
||||||
|
#else
|
||||||
ret = modem_reset_and_configure();
|
ret = modem_reset_and_configure();
|
||||||
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -5075,10 +5088,14 @@ static void offload_iface_init(struct net_if *iface)
|
||||||
struct hl7800_iface_ctx *ctx = dev->data;
|
struct hl7800_iface_ctx *ctx = dev->data;
|
||||||
|
|
||||||
iface->if_dev->offload = &offload_funcs;
|
iface->if_dev->offload = &offload_funcs;
|
||||||
net_if_set_link_addr(iface, hl7800_get_mac(dev), sizeof(ctx->mac_addr),
|
|
||||||
NET_LINK_ETHERNET);
|
|
||||||
ctx->iface = iface;
|
ctx->iface = iface;
|
||||||
ictx.initialized = true;
|
|
||||||
|
if (!IS_ENABLED(CONFIG_MODEM_HL7800_DELAY_START)) {
|
||||||
|
hl7800_build_mac(&ictx);
|
||||||
|
net_if_set_link_addr(iface, ictx.mac_addr, sizeof(ictx.mac_addr),
|
||||||
|
NET_LINK_ETHERNET);
|
||||||
|
ictx.initialized = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct net_if_api api_funcs = {
|
static struct net_if_api api_funcs = {
|
||||||
|
|
|
@ -155,7 +155,7 @@ typedef void (*mdm_hl7800_event_callback_t)(enum mdm_hl7800_event event,
|
||||||
int32_t mdm_hl7800_power_off(void);
|
int32_t mdm_hl7800_power_off(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset the HL7800
|
* @brief Reset the HL7800 (and allow it to reconfigure).
|
||||||
*
|
*
|
||||||
* @return int32_t 0 for success
|
* @return int32_t 0 for success
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue