Skip to content

Commit f3a5cfa

Browse files
trantanenrlubos
authored andcommitted
samples: cellular: slm_shell: Add data and indication callbacks
Add data handler for received data. Also add indication handler whenever CONFIG_MODEM_SLM_INDICATE_PIN is configured so that SLM shell gets notified during sleep if incoming data or AT notifications are waiting in the SLM side. Jira: LRCS-82 Signed-off-by: Tommi Rantanen <[email protected]>
1 parent 407643d commit f3a5cfa

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

samples/cellular/slm_shell/boards/nrf5340dk_nrf5340_cpuapp.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ CONFIG_NRFX_UARTE2=y
1212
CONFIG_UART_2_INTERRUPT_DRIVEN=n
1313
CONFIG_UART_2_ASYNC=y
1414
CONFIG_MODEM_SLM_WAKEUP_PIN=23
15+
CONFIG_MODEM_SLM_INDICATE_PIN=28

samples/cellular/slm_shell/src/main.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,41 @@ static void cereg_mon(const char *notif)
2121
}
2222
}
2323

24+
void slm_shell_data_indication(const uint8_t *data, size_t datalen)
25+
{
26+
LOG_INF("Data received (len=%d): %.*s", datalen, datalen, (const char *)data);
27+
}
28+
29+
#if (CONFIG_MODEM_SLM_INDICATE_PIN >= 0)
30+
void slm_shell_indication_handler(void)
31+
{
32+
int err;
33+
34+
LOG_INF("SLM indicate pin triggered");
35+
err = modem_slm_wake_up();
36+
if (err) {
37+
LOG_ERR("Failed to toggle power pin");
38+
}
39+
}
40+
#endif /* CONFIG_MODEM_SLM_INDICATE_PIN */
41+
2442
int main(void)
2543
{
44+
int err;
45+
2646
LOG_INF("SLM Shell starts on %s", CONFIG_BOARD);
2747

28-
(void)modem_slm_init(NULL);
48+
err = modem_slm_init(slm_shell_data_indication);
49+
if (err) {
50+
LOG_ERR("Failed to initialize SLM: %d", err);
51+
}
52+
53+
#if (CONFIG_MODEM_SLM_INDICATE_PIN >= 0)
54+
err = modem_slm_register_ind(slm_shell_indication_handler, true);
55+
if (err) {
56+
LOG_ERR("Failed to register indication: %d", err);
57+
}
58+
#endif /* CONFIG_MODEM_SLM_INDICATE_PIN */
59+
2960
return 0;
3061
}

0 commit comments

Comments
 (0)