Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
shell_mqtt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 G-Technologies Sdn. Bhd.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef SHELL_MQTT_H__
8#define SHELL_MQTT_H__
9
10#include <zephyr/kernel.h>
11#include <zephyr/shell/shell.h>
12#include <zephyr/net/socket.h>
13#include <zephyr/net/net_mgmt.h>
16#include <zephyr/net/mqtt.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#define RX_RB_SIZE CONFIG_SHELL_MQTT_RX_BUF_SIZE
24#define TX_BUF_SIZE CONFIG_SHELL_MQTT_TX_BUF_SIZE
25#define SH_MQTT_BUFFER_SIZE 64
26#define DEVICE_ID_BIN_MAX_SIZE 3
27#define DEVICE_ID_HEX_MAX_SIZE ((DEVICE_ID_BIN_MAX_SIZE * 2) + 1)
28#define SH_MQTT_TOPIC_MAX_SIZE DEVICE_ID_HEX_MAX_SIZE + 3
29
31
39
106
107#define SHELL_MQTT_DEFINE(_name) \
108 static struct shell_mqtt _name##_shell_mqtt; \
109 struct shell_transport _name = { .api = &shell_mqtt_transport_api, \
110 .ctx = (struct shell_mqtt *)&_name##_shell_mqtt }
111
121
134bool shell_mqtt_get_devid(char *id, int id_max_len);
135
136#ifdef __cplusplus
137}
138#endif
139
140#endif /* SHELL_MQTT_H__ */
API for monitoring network connections and interfaces.
void(* shell_transport_handler_t)(enum shell_transport_evt evt, void *context)
Definition shell.h:624
Public kernel APIs.
MQTT Client Implementation.
BSD Sockets compatible API definitions.
Network Events code public header.
Network Management API public header.
#define TX_BUF_SIZE
Definition shell_mqtt.h:24
#define RX_RB_SIZE
Definition shell_mqtt.h:23
const struct shell_transport_api shell_mqtt_transport_api
#define SH_MQTT_TOPIC_MAX_SIZE
Definition shell_mqtt.h:28
#define DEVICE_ID_HEX_MAX_SIZE
Definition shell_mqtt.h:27
bool shell_mqtt_get_devid(char *id, int id_max_len)
Function to define the device ID (devid) for which the shell mqtt backend uses as a client ID when it...
const struct shell * shell_backend_mqtt_get_ptr(void)
This function provides pointer to shell mqtt backend instance.
#define SH_MQTT_BUFFER_SIZE
Definition shell_mqtt.h:25
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Mutex Structure.
Definition kernel.h:2917
A structure used to submit work after a delay.
Definition kernel.h:3908
A structure used to hold work until it can be processed.
Definition kernel.h:4032
A structure used to submit work.
Definition kernel.h:3880
MQTT Client definition to maintain information relevant to the client.
Definition mqtt.h:494
Parameters for a publish message (PUBLISH).
Definition mqtt.h:249
Network Management event callback structure Used to register a callback into the network management e...
Definition net_mgmt.h:143
A structure to represent a ring buffer.
Definition ring_buffer.h:41
Definition shell_mqtt.h:62
uint8_t tx[64]
Definition shell_mqtt.h:64
uint8_t rx[64]
Definition shell_mqtt.h:63
Definition shell_mqtt.h:32
uint16_t len
Current tx buf length.
Definition shell_mqtt.h:37
char buf[CONFIG_SHELL_MQTT_TX_BUF_SIZE]
tx buffer.
Definition shell_mqtt.h:34
MQTT-based shell transport.
Definition shell_mqtt.h:41
struct shell_mqtt_tx_buf tx_buf
Definition shell_mqtt.h:53
struct k_work_delayable subscribe_dwork
Definition shell_mqtt.h:84
struct k_work net_disconnected_work
Definition shell_mqtt.h:82
struct ring_buf rx_rb
Definition shell_mqtt.h:49
struct k_work_delayable publish_dwork
Definition shell_mqtt.h:86
void * shell_context
Context registered by shell.
Definition shell_mqtt.h:56
struct k_work_delayable connect_dwork
Definition shell_mqtt.h:83
char sub_topic[((3 *2)+1)+3]
Definition shell_mqtt.h:43
struct net_mgmt_event_callback mgmt_cb
Definition shell_mqtt.h:78
struct zsock_addrinfo * haddr
Definition shell_mqtt.h:72
struct k_work_delayable process_dwork
Definition shell_mqtt.h:85
char pub_topic[((3 *2)+1)+3]
Definition shell_mqtt.h:44
uint8_t * rx_rb_ptr
Definition shell_mqtt.h:51
char device_id[((3 *2)+1)]
Definition shell_mqtt.h:42
shell_transport_handler_t shell_handler
Handler function registered by shell.
Definition shell_mqtt.h:47
enum shell_mqtt::sh_mqtt_transport_state transport_state
sh_mqtt_network_state
Network states.
Definition shell_mqtt.h:101
@ SHELL_MQTT_NETWORK_DISCONNECTED
Definition shell_mqtt.h:102
@ SHELL_MQTT_NETWORK_CONNECTED
Definition shell_mqtt.h:103
struct mqtt_client mqtt_cli
The mqtt client struct.
Definition shell_mqtt.h:59
enum shell_mqtt::sh_mqtt_network_state network_state
struct shell_mqtt::buffer buf
struct mqtt_publish_param pub_data
Definition shell_mqtt.h:76
struct sockaddr_storage broker
MQTT Broker details.
Definition shell_mqtt.h:70
uint8_t rx_rb_buf[CONFIG_SHELL_MQTT_RX_BUF_SIZE]
Definition shell_mqtt.h:50
enum shell_mqtt::sh_mqtt_subscribe_state subscribe_state
struct zsock_pollfd fds[1]
Definition shell_mqtt.h:73
sh_mqtt_subscribe_state
MQTT subscription states.
Definition shell_mqtt.h:95
@ SHELL_MQTT_NOT_SUBSCRIBED
Definition shell_mqtt.h:96
@ SHELL_MQTT_SUBSCRIBED
Definition shell_mqtt.h:97
sh_mqtt_transport_state
MQTT connection states.
Definition shell_mqtt.h:89
@ SHELL_MQTT_TRANSPORT_DISCONNECTED
Definition shell_mqtt.h:90
@ SHELL_MQTT_TRANSPORT_CONNECTED
Definition shell_mqtt.h:91
int nfds
Definition shell_mqtt.h:74
struct k_mutex lock
Definition shell_mqtt.h:67
struct k_work_q workq
work
Definition shell_mqtt.h:81
Unified shell transport interface.
Definition shell.h:646
Shell instance internals.
Definition shell.h:890
Definition used when querying address information.
Definition socket.h:272
Definition of the monitored socket/file descriptor.
Definition socket_poll.h:28