Skip to content

Commit 125bb7f

Browse files
junqingzourlubos
authored andcommitted
samples: serial_lte_modem adapt to new at_notif lib
AT response is now distributed by at_notif, instead of at_cmd. Signed-off-by: Jun Qing Zou <[email protected]>
1 parent 3ba40a4 commit 125bb7f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

samples/nrf9160/serial_lte_modem/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ config SLM_AT_MODE
1212
bool "Serial LTE Modem by raw AT mode"
1313
default y
1414
select AT_CMD
15+
select AT_NOTIF
1516
select AT_CMD_PARSER
1617

1718
config SLM_AT_MAX_PARAM

samples/nrf9160/serial_lte_modem/src/main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@
44
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
55
*/
66
#include <logging/log.h>
7-
LOG_MODULE_REGISTER(app, CONFIG_SLM_LOG_LEVEL);
87

98
#include <zephyr.h>
109
#include <stdio.h>
1110
#include <uart.h>
1211
#include <string.h>
1312
#include <bsd.h>
1413
#include <lte_lc.h>
15-
1614
#include <hal/nrf_gpio.h>
1715
#include <hal/nrf_power.h>
1816
#include <hal/nrf_regulators.h>
19-
2017
#include "slm_at_host.h"
2118

2219
#if defined(CONFIG_SLM_CONNECT_UART_0) && defined(CONFIG_SLM_GPIO_WAKEUP)
2320
#error CONFIG_SLM_GPIO_WAKEUP should not be defined when UART0 is used
2421
#endif
2522

23+
LOG_MODULE_REGISTER(app, CONFIG_SLM_LOG_LEVEL);
24+
2625
/* global variable used across different files */
2726
struct at_param_list m_param_list;
2827

samples/nrf9160/serial_lte_modem/src/slm_at_host.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <string.h>
1313
#include <init.h>
1414
#include <at_cmd.h>
15+
#include <at_notif.h>
1516

1617
LOG_MODULE_REGISTER(at_host, CONFIG_SLM_LOG_LEVEL);
1718

@@ -71,9 +72,12 @@ static inline void write_uart_string(char *str, size_t len)
7172
}
7273
}
7374

74-
static void response_handler(char *response)
75+
static void response_handler(void *context, char *response)
7576
{
7677
int len = strlen(response) + 1;
78+
79+
ARG_UNUSED(context);
80+
7781
/* Forward the data over UART */
7882
if (len > 1) {
7983
write_uart_string(response, len);
@@ -307,7 +311,11 @@ int slm_at_host_init(void)
307311
return -EINVAL;
308312
}
309313

310-
at_cmd_set_notification_handler(response_handler);
314+
err = at_notif_register_handler(NULL, response_handler);
315+
if (err != 0) {
316+
LOG_ERR("Can't register handler err=%d", err);
317+
return err;
318+
}
311319

312320
/* Initialize the UART module */
313321
err = at_uart_init(uart_dev_name);

0 commit comments

Comments
 (0)