Skip to content

Commit

Permalink
net: lib: nrf_cloud: post order mqtt message support
Browse files Browse the repository at this point in the history
CB24FW-107: add support for post order MQTT messages

Signed-off-by: Alexander Yurtsev <[email protected]>
  • Loading branch information
ayurtsev committed Oct 2, 2024
1 parent bfdb66c commit 71b6309
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/net/nrf_cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ enum nrf_cloud_evt_type {
* This event is only sent if @kconfig{CONFIG_NRF_CLOUD_FOTA_AUTO_START_JOB} is disabled.
*/
NRF_CLOUD_EVT_FOTA_JOB_AVAILABLE,
/** A post order message was received. */
NRF_CLOUD_EVT_RX_POST_ORDER,
/** An error occurred. The status field in the event struct will
* be populated with a @ref nrf_cloud_error_status value.
*/
Expand Down
1 change: 1 addition & 0 deletions include/net/nrf_cloud_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
#define NRF_CLOUD_JSON_VAL_TOPIC_RCV "/r"
#define NRF_CLOUD_JSON_VAL_TOPIC_WILDCARD "/+"
#define NRF_CLOUD_JSON_VAL_TOPIC_BIN "/bin"
#define NRF_CLOUD_JSON_VAL_TOPIC_POST_ORDER "/post_order"
#define NRF_CLOUD_JSON_VAL_PROTO_MQTT "MQTT"
#define NRF_CLOUD_JSON_VAL_PROTO_COAP "CoAP"
#define NRF_CLOUD_JSON_VAL_PROTO_REST "REST"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum nrf_cloud_rcv_topic {
NRF_CLOUD_RCV_TOPIC_AGNSS,
NRF_CLOUD_RCV_TOPIC_PGPS,
NRF_CLOUD_RCV_TOPIC_LOCATION,
NRF_CLOUD_RCV_TOPIC_POST_ORDER,
/* Unknown/unhandled topic */
NRF_CLOUD_RCV_TOPIC_UNKNOWN
};
Expand Down
4 changes: 4 additions & 0 deletions subsys/net/lib/nrf_cloud/src/nrf_cloud_codec_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ static const char *const sensor_type_str[] = {
#define TOPIC_VAL_RCV_PGPS (NRF_CLOUD_JSON_VAL_TOPIC_PGPS NRF_CLOUD_JSON_VAL_TOPIC_RCV)
#define TOPIC_VAL_RCV_C2D (NRF_CLOUD_JSON_VAL_TOPIC_C2D NRF_CLOUD_JSON_VAL_TOPIC_RCV)
#define TOPIC_VAL_RCV_GND_FIX (NRF_CLOUD_JSON_VAL_TOPIC_GND_FIX NRF_CLOUD_JSON_VAL_TOPIC_RCV)
#define TOPIC_VAL_RCV_POST_ORDER \
(NRF_CLOUD_JSON_VAL_TOPIC_POST_ORDER NRF_CLOUD_JSON_VAL_TOPIC_RCV)

/* Max length of a NRF_CLOUD_JSON_MSG_TYPE_VAL_DISCONNECT message */
#define NRF_CLOUD_JSON_MSG_MAX_LEN_DISCONNECT 200
Expand Down Expand Up @@ -623,6 +625,8 @@ enum nrf_cloud_rcv_topic nrf_cloud_dc_rx_topic_decode(const char * const topic)
return NRF_CLOUD_RCV_TOPIC_LOCATION;
} else if (strstr(topic, TOPIC_VAL_RCV_C2D)) {
return NRF_CLOUD_RCV_TOPIC_GENERAL;
} else if (strstr(topic, TOPIC_VAL_RCV_POST_ORDER)) {
return NRF_CLOUD_RCV_TOPIC_POST_ORDER;
} else {
return NRF_CLOUD_RCV_TOPIC_UNKNOWN;
}
Expand Down
3 changes: 3 additions & 0 deletions subsys/net/lib/nrf_cloud/src/nrf_cloud_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ static int dc_rx_data_handler(const struct nct_evt *nct_evt)
case NRF_CLOUD_RCV_TOPIC_UNKNOWN:
LOG_DBG("Received data on unknown topic: %s",
(char *)(cloud_evt.topic.ptr ? cloud_evt.topic.ptr : "NULL"));
case NRF_CLOUD_RCV_TOPIC_POST_ORDER:
cloud_evt.type = NRF_CLOUD_EVT_RX_POST_ORDER;
break;
/* Intentional fall-through */
case NRF_CLOUD_RCV_TOPIC_GENERAL:
default:
Expand Down

0 comments on commit 71b6309

Please sign in to comment.