Skip to content
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
2 changes: 2 additions & 0 deletions generated/include/infuse/rpc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,8 @@ struct rpc_data_sender_response {
struct rpc_data_receiver_request {
struct infuse_rpc_req_header header;
struct infuse_rpc_req_data_header data_header;
/** Allow unaligned input data */
uint8_t unaligned_input;
} __packed;

struct rpc_data_receiver_response {
Expand Down
17 changes: 17 additions & 0 deletions include/infuse/rpc/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ struct net_buf *rpc_response_simple_req(struct net_buf *request, int16_t rc, voi
struct net_buf *rpc_server_pull_data(uint32_t request_id, uint32_t expected_offset, int *err,
k_timeout_t timeout);

/**
* @brief Attempt to pull unaligned @ref INFUSE_RPC_DATA packet from queue
*
* Unlike @ref rpc_server_pull_data, the offsets are not expected to be aligned to word
* boundaries.
*
* @param request_id RPC request ID
* @param expected_offset Expected data offset
* @param err Error code when function returned NULL
* @param timeout Duration to wait for packet
*
* @retval buf @ref INFUSE_RPC_DATA packet on success
* @retval NULL on error
*/
struct net_buf *rpc_server_pull_data_unaligned(uint32_t request_id, uint32_t expected_offset,
int *err, k_timeout_t timeout);

/**
* @brief Send initial @ref INFUSE_RPC_DATA_ACK to signify we are ready for data
*
Expand Down
4 changes: 3 additions & 1 deletion scripts/west_commands/cloud_definitions/rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,9 @@
"default": "y if ZTEST",
"default_auth": "EPACKET_AUTH_DEVICE",
"rpc_data": true,
"request_params": [],
"request_params": [
{"name": "unaligned_input", "type": "uint8_t", "description": "Allow unaligned input data"}
],
"response_params": [
{"name": "recv_len", "type": "uint32_t", "description": "Number of bytes received"},
{"name": "recv_crc", "type": "uint32_t", "description": "CRC32 of bytes received"}
Expand Down
11 changes: 10 additions & 1 deletion subsys/rpc/commands/data_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct net_buf *rpc_command_data_receiver(struct net_buf *request)
uint32_t received = 0;
uint32_t expected_offset = 0;
uint8_t ack_period;
uint8_t unaligned;
uint32_t crc = 0;
size_t var_len;
int rc = 0;
Expand All @@ -47,6 +48,7 @@ struct net_buf *rpc_command_data_receiver(struct net_buf *request)
expected = req->data_header.size;
remaining = req->data_header.size;
ack_period = req->data_header.rx_ack_period;
unaligned = req->unaligned_input;

rpc_command_runner_request_unref(request);
request = NULL;
Expand All @@ -57,13 +59,20 @@ struct net_buf *rpc_command_data_receiver(struct net_buf *request)
rpc_server_ack_data_ready(interface, from, request_id);

while (remaining > 0) {
data_buf = rpc_server_pull_data(request_id, expected_offset, &rc, K_MSEC(500));
if (unaligned) {
data_buf = rpc_server_pull_data_unaligned(request_id, expected_offset, &rc,
K_MSEC(500));
} else {
data_buf =
rpc_server_pull_data(request_id, expected_offset, &rc, K_MSEC(500));
}
if (data_buf == NULL) {
goto end;
}
var_len = RPC_DATA_VAR_LEN(data_buf);
if (var_len > remaining) {
LOG_WRN("Received too much data %d/%d", var_len, remaining);
net_buf_unref(data_buf);
rc = -EINVAL;
goto end;
}
Expand Down
1 change: 1 addition & 0 deletions subsys/rpc/commands/file_write_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct net_buf *rpc_command_file_write_basic(struct net_buf *request)
var_len = RPC_DATA_VAR_LEN(data_buf);
if (var_len > remaining) {
LOG_WRN("Received too much data %d/%d", var_len, remaining);
net_buf_unref(data_buf);
rc = -EINVAL;
goto error;
}
Expand Down
19 changes: 15 additions & 4 deletions subsys/rpc/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ void rpc_server_pull_data_reset(void)
{
data_packet_ack_counter = 0;
}

struct net_buf *rpc_server_pull_data(uint32_t request_id, uint32_t expected_offset, int *err,
k_timeout_t timeout)
static struct net_buf *pull_data_core(uint32_t request_id, uint32_t expected_offset, int *err,
k_timeout_t timeout, bool requires_aligned)
{
struct infuse_rpc_data *data;
struct net_buf *buf;
Expand Down Expand Up @@ -98,7 +97,7 @@ struct net_buf *rpc_server_pull_data(uint32_t request_id, uint32_t expected_offs
if (data->offset != expected_offset) {
LOG_WRN("Missed data %08X-%08X", expected_offset, data->offset - 1);
}
if (data->offset % sizeof(uint32_t)) {
if (requires_aligned && (data->offset % sizeof(uint32_t))) {
LOG_WRN("Unaligned data offset %08X", data->offset);
net_buf_unref(buf);
*err = -EINVAL;
Expand All @@ -110,6 +109,18 @@ struct net_buf *rpc_server_pull_data(uint32_t request_id, uint32_t expected_offs
}
}

struct net_buf *rpc_server_pull_data(uint32_t request_id, uint32_t expected_offset, int *err,
k_timeout_t timeout)
{
return pull_data_core(request_id, expected_offset, err, timeout, true);
}

struct net_buf *rpc_server_pull_data_unaligned(uint32_t request_id, uint32_t expected_offset,
int *err, k_timeout_t timeout)
{
return pull_data_core(request_id, expected_offset, err, timeout, false);
}

static void send_ack(const struct device *interface, union epacket_interface_address address,
uint32_t request_id, uint8_t num_offsets)
{
Expand Down
6 changes: 6 additions & 0 deletions tests/subsys/definitions_extend/generated/Kconfig.kv_keys
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ config KV_STORE_KEY_LTE_NETWORKING_MODES
help
Enabled LTE networking modes and preferences

config KV_STORE_KEY_LTE_SIM_IMSI
bool "Enable KV key LTE_SIM_IMSI"
default y if NRF_MODEM_LIB
help
'International Modem Subscriber Identity' as returned by AT+CIMI

config KV_STORE_KEY_BLUETOOTH_PEER
bool "Enable KV key BLUETOOTH_PEER"
help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
* @copyright 2024 Embeint Holdings Pty Ltd
* @author scripts/west_commands/cloudgen.py
*
<<<<<<< HEAD
* INFUSE-IOT-AUTOGENERATED
*
* SPDX-License-Identifier: LicenseRef-Embeint
=======
* SPDX-License-Identifier: FSL-1.1-ALv2
>>>>>>> f86d22f2 (treewide: relicense to `FSL-1.1-ALv2`)
*/

#ifndef INFUSE_SDK_INCLUDE_GENERATED_KV_DEFINITIONS_H_
Expand Down Expand Up @@ -308,6 +304,12 @@ struct kv_lte_networking_modes {
uint8_t prefer;
} __packed;

/** 'International Modem Subscriber Identity' as returned by AT+CIMI */
struct kv_lte_sim_imsi {
/** 15 digit IMSI */
uint64_t imsi;
} __packed;

/** Bluetooth peer device */
struct kv_bluetooth_peer {
/** Peer device Bluetooth address */
Expand Down Expand Up @@ -478,6 +480,8 @@ enum kv_builtin_id {
KV_KEY_LTE_PDP_CONFIG = 45,
/** Enabled LTE networking modes and preferences */
KV_KEY_LTE_NETWORKING_MODES = 46,
/** 'International Modem Subscriber Identity' as returned by AT+CIMI */
KV_KEY_LTE_SIM_IMSI = 47,
/** Bluetooth peer device */
KV_KEY_BLUETOOTH_PEER = 50,
/** LoRa modem configuration */
Expand Down Expand Up @@ -540,6 +544,7 @@ enum kv_builtin_size {
_KV_KEY_EPACKET_UDP_PORT_SIZE = sizeof(struct kv_epacket_udp_port),
_KV_KEY_LTE_MODEM_IMEI_SIZE = sizeof(struct kv_lte_modem_imei),
_KV_KEY_LTE_NETWORKING_MODES_SIZE = sizeof(struct kv_lte_networking_modes),
_KV_KEY_LTE_SIM_IMSI_SIZE = sizeof(struct kv_lte_sim_imsi),
_KV_KEY_BLUETOOTH_PEER_SIZE = sizeof(struct kv_bluetooth_peer),
_KV_KEY_LORA_CONFIG_SIZE = sizeof(struct kv_lora_config),
_KV_KEY_BLUETOOTH_THROUGHPUT_LIMIT_SIZE = sizeof(struct kv_bluetooth_throughput_limit),
Expand Down Expand Up @@ -572,6 +577,7 @@ enum kv_builtin_size {
#define _KV_KEY_LTE_SIM_UICC_TYPE struct kv_lte_sim_uicc
#define _KV_KEY_LTE_PDP_CONFIG_TYPE struct kv_lte_pdp_config
#define _KV_KEY_LTE_NETWORKING_MODES_TYPE struct kv_lte_networking_modes
#define _KV_KEY_LTE_SIM_IMSI_TYPE struct kv_lte_sim_imsi
#define _KV_KEY_BLUETOOTH_PEER_TYPE struct kv_bluetooth_peer
#define _KV_KEY_LORA_CONFIG_TYPE struct kv_lora_config
#define _KV_KEY_BLUETOOTH_THROUGHPUT_LIMIT_TYPE struct kv_bluetooth_throughput_limit
Expand Down Expand Up @@ -624,6 +630,8 @@ enum kv_builtin_size {
(1 +)) \
IF_ENABLED(CONFIG_KV_STORE_KEY_LTE_NETWORKING_MODES, \
(1 +)) \
IF_ENABLED(CONFIG_KV_STORE_KEY_LTE_SIM_IMSI, \
(1 +)) \
IF_ENABLED(CONFIG_KV_STORE_KEY_BLUETOOTH_PEER, \
(1 +)) \
IF_ENABLED(CONFIG_KV_STORE_KEY_LORA_CONFIG, \
Expand Down Expand Up @@ -816,6 +824,13 @@ static struct key_value_slot_definition _KV_SLOTS_ARRAY_DEFINE[] = {
.flags = KV_FLAGS_REFLECT,
},
#endif /* CONFIG_KV_STORE_KEY_LTE_NETWORKING_MODES */
#ifdef CONFIG_KV_STORE_KEY_LTE_SIM_IMSI
{
.key = KV_KEY_LTE_SIM_IMSI,
.range = 1,
.flags = KV_FLAGS_REFLECT | KV_FLAGS_READ_ONLY,
},
#endif /* CONFIG_KV_STORE_KEY_LTE_SIM_IMSI */
#ifdef CONFIG_KV_STORE_KEY_BLUETOOTH_PEER
{
.key = KV_KEY_BLUETOOTH_PEER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
* @copyright 2024 Embeint Holdings Pty Ltd
* @author scripts/west_commands/cloudgen.py
*
<<<<<<< HEAD
* INFUSE-IOT-AUTOGENERATED
*
* SPDX-License-Identifier: LicenseRef-Embeint
=======
* SPDX-License-Identifier: FSL-1.1-ALv2
>>>>>>> f86d22f2 (treewide: relicense to `FSL-1.1-ALv2`)
*/

#ifndef INFUSE_SDK_INCLUDE_GENERATED_RPC_COMMANDS_H_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
* @copyright 2024 Embeint Holdings Pty Ltd
* @author scripts/west_commands/cloudgen.py
*
<<<<<<< HEAD
* INFUSE-IOT-AUTOGENERATED
*
* SPDX-License-Identifier: LicenseRef-Embeint
=======
* SPDX-License-Identifier: FSL-1.1-ALv2
>>>>>>> f86d22f2 (treewide: relicense to `FSL-1.1-ALv2`)
*/

#ifndef INFUSE_SDK_INCLUDE_GENERATED_RPC_TYPES_H_
Expand Down Expand Up @@ -1055,6 +1051,8 @@ struct rpc_data_sender_response {
struct rpc_data_receiver_request {
struct infuse_rpc_req_header header;
struct infuse_rpc_req_data_header data_header;
/** Allow unaligned input data */
uint8_t unaligned_input;
} __packed;

struct rpc_data_receiver_response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
* @copyright 2024 Embeint Holdings Pty Ltd
* @author scripts/west_commands/cloudgen.py
*
<<<<<<< HEAD
* INFUSE-IOT-AUTOGENERATED
*
* SPDX-License-Identifier: LicenseRef-Embeint
=======
* SPDX-License-Identifier: FSL-1.1-ALv2
>>>>>>> f86d22f2 (treewide: relicense to `FSL-1.1-ALv2`)
*/

#ifndef INFUSE_SDK_INCLUDE_GENERATED_TDF_DEFINITIONS_H_
Expand Down Expand Up @@ -696,6 +692,18 @@ struct tdf_network_scan_count {
uint32_t frame[_count]; \
} __packed;

/** Battery voltage */
struct tdf_battery_voltage {
/** Battery voltage (milliVolts) */
uint16_t voltage;
} __packed;

/** Battery state of charge */
struct tdf_battery_soc {
/** State of charge (percent) */
uint8_t soc;
} __packed;

/** Extension TDF 1 */
struct tdf_ext1 {
/** Demo 1 */
Expand Down Expand Up @@ -812,6 +820,10 @@ enum tdf_builtin_id {
TDF_NETWORK_SCAN_COUNT = 51,
/** Generic exception stack frame */
TDF_EXCEPTION_STACK_FRAME = 52,
/** Battery voltage */
TDF_BATTERY_VOLTAGE = 53,
/** Battery state of charge */
TDF_BATTERY_SOC = 54,
/** Extension TDF 1 */
TDF_EXT1 = 1025,
/** Extension TDF 2 */
Expand Down Expand Up @@ -869,6 +881,8 @@ enum tdf_builtin_id {
#define _TDF_WIFI_CONNECTION_FAILED_TYPE struct tdf_wifi_connection_failed
#define _TDF_WIFI_DISCONNECTED_TYPE struct tdf_wifi_disconnected
#define _TDF_NETWORK_SCAN_COUNT_TYPE struct tdf_network_scan_count
#define _TDF_BATTERY_VOLTAGE_TYPE struct tdf_battery_voltage
#define _TDF_BATTERY_SOC_TYPE struct tdf_battery_soc
#define _TDF_EXT1_TYPE struct tdf_ext1
#define _TDF_EXT2_TYPE struct tdf_ext2

Expand Down Expand Up @@ -921,6 +935,8 @@ enum tdf_builtin_size {
_TDF_WIFI_CONNECTION_FAILED_SIZE = sizeof(struct tdf_wifi_connection_failed),
_TDF_WIFI_DISCONNECTED_SIZE = sizeof(struct tdf_wifi_disconnected),
_TDF_NETWORK_SCAN_COUNT_SIZE = sizeof(struct tdf_network_scan_count),
_TDF_BATTERY_VOLTAGE_SIZE = sizeof(struct tdf_battery_voltage),
_TDF_BATTERY_SOC_SIZE = sizeof(struct tdf_battery_soc),
_TDF_EXT1_SIZE = sizeof(struct tdf_ext1),
_TDF_EXT2_SIZE = sizeof(struct tdf_ext2),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @copyright 2024 Embeint Holdings Pty Ltd
* @author scripts/west_commands/cloudgen.py
*
* INFUSE-IOT-AUTOGENERATED
*
* SPDX-License-Identifier: FSL-1.1-ALv2
*/

Expand Down
1 change: 1 addition & 0 deletions tests/subsys/rpc/client/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ static void test_command_data_param(uint32_t size, uint8_t ack_period, bool sing
.size = size,
.rx_ack_period = ack_period,
},
.unaligned_input = 0,
};
uint8_t buffer[128];
uint32_t request_id;
Expand Down
Loading