samples: net: modem: add modem power callbacks

Register modem power callbacks to show how it can be
used to provide e.g modem power on and off sequences.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
This commit is contained in:
Bartosz Bilas 2022-02-19 13:42:41 +01:00 committed by Anas Nashif
parent d5e0102772
commit 1fd95768c8

View file

@ -90,6 +90,22 @@ static void event_handler(struct net_mgmt_event_callback *cb,
}
}
static void modem_on_cb(const struct device *dev, void *user_data)
{
ARG_UNUSED(dev);
ARG_UNUSED(user_data);
LOG_INF("GSM modem on callback fired");
}
static void modem_off_cb(const struct device *dev, void *user_data)
{
ARG_UNUSED(dev);
ARG_UNUSED(user_data);
LOG_INF("GSM modem off callback fired");
}
int main(void)
{
const struct device *uart_dev =
@ -97,6 +113,9 @@ int main(void)
gsm_dev = DEVICE_DT_GET(DT_INST(0, zephyr_gsm_ppp));
/* Optional register modem power callbacks */
gsm_ppp_register_modem_power_callback(gsm_dev, modem_on_cb, modem_off_cb, NULL);
LOG_INF("Board '%s' APN '%s' UART '%s' device %p (%s)",
CONFIG_BOARD, CONFIG_MODEM_GSM_APN,
DT_BUS_LABEL(DT_INST(0, zephyr_gsm_ppp)), uart_dev,