Loading...
Searching...
No Matches
paho_mqtt.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Javier FILEIV <javier.fileiv@gmail.com>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "mutex.h"
19#include "thread.h"
20#include "net/sock/tcp.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
29#ifndef MQTT_THREAD_PRIORITY
30#define MQTT_THREAD_PRIORITY (THREAD_PRIORITY_MAIN - 1)
31#endif
32
36
37#ifndef MQTT_THREAD_STACKSIZE
38#define MQTT_THREAD_STACKSIZE (THREAD_STACKSIZE_LARGE)
39#endif
43#ifndef MQTT_YIELD_POLLING_MS
44#define MQTT_YIELD_POLLING_MS (30)
45#endif
46
51typedef struct {
52 uint32_t timeout;
53 uint32_t time_set;
54} Timer;
55
61void TimerInit(Timer *timer);
62
70char TimerIsExpired(Timer *timer);
71
78void TimerCountdownMS(Timer *timer, unsigned int msecs);
79
86void TimerCountdown(Timer *timer, unsigned int secs);
87
95int TimerLeftMS(Timer *timer);
96
100typedef struct Network {
105 int (*mqttread) (struct Network*, unsigned char*, int, int);
109 int (*mqttwrite) (struct Network*, unsigned char*, int, int);
111
118
128int NetworkConnect(Network *n, char* address_ip, int port_number);
129
136
140typedef struct {
142} Mutex;
143
149void MutexInit(Mutex *mutex);
150
158int MutexLock(Mutex *mutex);
159
167int MutexUnlock(Mutex *mutex);
168
176
186int ThreadStart(Thread *thread, void (*fn)(void *), void *arg);
187
188#ifdef __cplusplus
189}
190#endif
191
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:134
struct sock_tcp sock_tcp_t
forward declare for async
Definition types.h:93
void TimerCountdownMS(Timer *timer, unsigned int msecs)
start timer set to milli seconds
char TimerIsExpired(Timer *timer)
is timer expired?
#define MQTT_THREAD_STACKSIZE
RIOT's mqtt paho thread stack size.
Definition paho_mqtt.h:38
int MutexLock(Mutex *mutex)
Locks mutex struct.
int ThreadStart(Thread *thread, void(*fn)(void *), void *arg)
Start new thread.
int MutexUnlock(Mutex *mutex)
Unlocks mutex struct.
int NetworkConnect(Network *n, char *address_ip, int port_number)
Connect network to host.
void TimerInit(Timer *timer)
Initialize timer struct.
void TimerCountdown(Timer *timer, unsigned int secs)
start timer set to seconds
void NetworkDisconnect(Network *n)
Disconnect network.
void MutexInit(Mutex *mutex)
Initialize mutex struct.
int TimerLeftMS(Timer *timer)
Returns millisecs left in timer.
void NetworkInit(Network *n)
Initialize network struct.
Mutex for thread synchronization.
TCP sock definitions.
Mutex struct within mqtt paho.
Definition paho_mqtt.h:140
mutex_t lock
MQTT thread mutex.
Definition paho_mqtt.h:141
Network struct within mqtt paho.
Definition paho_mqtt.h:100
int(* mqttwrite)(struct Network *, unsigned char *, int, int)
write internal function
Definition paho_mqtt.h:109
sock_tcp_t sock
socket number
Definition paho_mqtt.h:101
int(* mqttread)(struct Network *, unsigned char *, int, int)
read internal function
Definition paho_mqtt.h:105
Thread struct within mqtt paho.
Definition paho_mqtt.h:172
kernel_pid_t pid
MQTT thread pid.
Definition paho_mqtt.h:174
char stack[MQTT_THREAD_STACKSIZE]
stack for MQTT thread
Definition paho_mqtt.h:173
struct to get time references within mqtt paho
Definition paho_mqtt.h:51
uint32_t time_set
set time in ms
Definition paho_mqtt.h:53
uint32_t timeout
timeout in ms
Definition paho_mqtt.h:52
Mutex structure.
Definition mutex.h:36