Skip to content
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

Fix init BLE and OT on the same build. #8

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/nrf_rpc/nrf_rpc_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ typedef struct nrf_rpc_uart {
hdlc_state_t hdlc_state;
uint8_t frame_buffer[NRF_RPC_MAX_FRAME_SIZE];
size_t frame_len;

/* UART send semaphore */
struct k_sem uart_tx_sem;
} nrf_rpc_uart;

extern const struct nrf_rpc_tr_api nrf_rpc_uart_service_api;
Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/rpc/common/bt_rpc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ BUILD_ASSERT(!IS_ENABLED(CONFIG_BT_BREDR), "BT_RPC does not support BR/EDR");
#if CONFIG_NRF_RPC_IPC_SERVICE
NRF_RPC_IPC_TRANSPORT(bt_rpc_tr, DEVICE_DT_GET(DT_NODELABEL(ipc0)), "bt_rpc_ept");
#elif CONFIG_NRF_RPC_UART_TRANSPORT
NRF_RPC_UART_TRANSPORT(bt_rpc_tr, DEVICE_DT_GET(DT_NODELABEL(uart1)));
NRF_RPC_UART_TRANSPORT(rpc_tr, DEVICE_DT_GET(DT_NODELABEL(uart1)));
#endif
NRF_RPC_GROUP_DEFINE(bt_rpc_grp, "bt_rpc", &bt_rpc_tr, NULL, NULL, NULL);
NRF_RPC_GROUP_DEFINE(bt_rpc_grp, "bt_rpc", &rpc_tr, NULL, NULL, NULL);

enum {
CHECK_ENTRY_FLAGS,
Expand Down
8 changes: 5 additions & 3 deletions subsys/net/openthread/rpc/common/ot_rpc_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@

#if CONFIG_NRF_RPC_IPC_SERVICE
NRF_RPC_IPC_TRANSPORT(ot_group_tr, DEVICE_DT_GET(DT_NODELABEL(ipc0)), "ot_rpc_ept");
#elif CONFIG_NRF_RPC_UART_TRANSPORT
NRF_RPC_UART_TRANSPORT(ot_group_tr, DEVICE_DT_GET(DT_NODELABEL(uart1)));
#elif CONFIG_NRF_RPC_UART_TRANSPORT && !CONFIG_BT_RPC
NRF_RPC_UART_TRANSPORT(rpc_tr, DEVICE_DT_GET(DT_NODELABEL(uart1)));
#elif CONFIG_NRF_RPC_UART_TRANSPORT && CONFIG_BT_RPC
extern const struct nrf_rpc_tr rpc_tr;
#endif
NRF_RPC_GROUP_DEFINE(ot_group, "ot", &ot_group_tr, NULL, NULL, NULL);
NRF_RPC_GROUP_DEFINE(ot_group, "ot", &rpc_tr, NULL, NULL, NULL);
LOG_MODULE_REGISTER(ot_rpc, LOG_LEVEL_DBG);

#ifdef CONFIG_OPENTHREAD_RPC_INITIALIZE_NRF_RPC
Expand Down
10 changes: 9 additions & 1 deletion subsys/nrf_rpc/nrf_rpc_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
{
struct nrf_rpc_uart *uart_tr = transport->ctx;

if(uart_tr->transport != NULL) {

Check failure on line 118 in subsys/nrf_rpc/nrf_rpc_uart.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACING

subsys/nrf_rpc/nrf_rpc_uart.c:118 space required before the open parenthesis '('
LOG_DBG("init not needed");
return 0;
}

uart_tr->transport = transport;

LOG_DBG("init called");
Expand Down Expand Up @@ -145,6 +150,8 @@
return 0;
}

k_sem_init(&uart_tr->uart_tx_sem, 1, 1);

k_work_init(&uart_tr->cb_work, work_handler);
ring_buf_init(&uart_tr->rx_ringbuf, sizeof(uart_tr->rx_buffer), uart_tr->rx_buffer);
uart_tr->hdlc_state = hdlc_state_unsync;
Expand All @@ -159,7 +166,7 @@
LOG_HEXDUMP_DBG(data, length, "Sending frame");
struct nrf_rpc_uart *uart_tr = transport->ctx;
// uint16_t crc;

k_sem_take(&uart_tr->uart_tx_sem, K_FOREVER);
// crc = crc16_ccitt(0xffff, data, length);
uart_poll_out(uart_tr->uart, hdlc_char_delimiter);

Expand All @@ -179,6 +186,7 @@
uart_poll_out(uart_tr->uart, hdlc_char_delimiter);

k_free((void*)data);
k_sem_give(&uart_tr->uart_tx_sem);

return 0;
}
Expand Down
Loading