paho_mqtt.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Javier FILEIV <javier.fileiv@gmail.com>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  *
8  */
9 
19 #ifndef PAHO_MQTT_H
20 #define PAHO_MQTT_H
21 
22 #include "mutex.h"
23 #include "xtimer.h"
24 #include "thread.h"
25 #include "net/sock/tcp.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
34 #ifndef MQTT_THREAD_PRIORITY
35 #define MQTT_THREAD_PRIORITY (THREAD_PRIORITY_MAIN - 1)
36 #endif
37 
42 #ifndef MQTT_THREAD_STACKSIZE
43 #define MQTT_THREAD_STACKSIZE (THREAD_STACKSIZE_LARGE)
44 #endif
45 
48 #ifndef MQTT_YIELD_POLLING_MS
49 #define MQTT_YIELD_POLLING_MS (30)
50 #endif
51 
56 typedef struct {
59 } Timer;
60 
66 void TimerInit(Timer *timer);
67 
75 char TimerIsExpired(Timer *timer);
76 
83 void TimerCountdownMS(Timer *timer, unsigned int msecs);
84 
91 void TimerCountdown(Timer *timer, unsigned int secs);
92 
100 int TimerLeftMS(Timer *timer);
101 
105 typedef struct Network {
110  int (*mqttread) (struct Network*, unsigned char*, int, int);
114  int (*mqttwrite) (struct Network*, unsigned char*, int, int);
115 } Network;
116 
122 void NetworkInit(Network *n);
123 
133 int NetworkConnect(Network *n, char* address_ip, int port_number);
134 
140 void NetworkDisconnect(Network *n);
141 
145 typedef struct {
147 } Mutex;
148 
154 void MutexInit(Mutex *mutex);
155 
163 int MutexLock(Mutex *mutex);
164 
172 int MutexUnlock(Mutex *mutex);
173 
177 typedef struct {
178  char stack[MQTT_THREAD_STACKSIZE];
180 } Thread;
181 
191 int ThreadStart(Thread *thread, void (*fn)(void *), void *arg);
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* PAHO_MQTT_H */
198 
Timer
struct to get time references within mqtt paho
Definition: paho_mqtt.h:56
kernel_pid_t
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:125
Network
Network struct within mqtt paho.
Definition: paho_mqtt.h:105
Network
struct Network Network
Network struct within mqtt paho.
MutexInit
void MutexInit(Mutex *mutex)
Initialize mutex struct.
TimerCountdown
void TimerCountdown(Timer *timer, unsigned int secs)
start timer set to seconds
tcp.h
TCP sock definitions.
Thread::pid
kernel_pid_t pid
MQTT thread pid.
Definition: paho_mqtt.h:179
Timer::ticks_timeout
xtimer_ticks64_t ticks_timeout
timeout in ticks
Definition: paho_mqtt.h:58
TimerLeftMS
int TimerLeftMS(Timer *timer)
Returns millisecs left in timer.
Mutex
Mutex struct within mqtt paho.
Definition: paho_mqtt.h:145
ThreadStart
int ThreadStart(Thread *thread, void(*fn)(void *), void *arg)
Start new thread.
Network::mqttread
int(* mqttread)(struct Network *, unsigned char *, int, int)
read internal function
Definition: paho_mqtt.h:110
NetworkConnect
int NetworkConnect(Network *n, char *address_ip, int port_number)
Connect network to host.
MutexLock
int MutexLock(Mutex *mutex)
Locks mutex struct.
Network::mqttwrite
int(* mqttwrite)(struct Network *, unsigned char *, int, int)
write internal function
Definition: paho_mqtt.h:114
Mutex::lock
mutex_t lock
MQTT thread mutex.
Definition: paho_mqtt.h:146
NetworkDisconnect
void NetworkDisconnect(Network *n)
Disconnect network.
Thread
Thread struct within mqtt paho.
Definition: paho_mqtt.h:177
MQTT_THREAD_STACKSIZE
#define MQTT_THREAD_STACKSIZE
RIOT's mqtt paho thread stack size.
Definition: paho_mqtt.h:43
mutex.h
Mutex for thread synchronization.
xtimer_ticks64_t
xtimer timestamp (64 bit)
Definition: xtimer.h:60
TimerIsExpired
char TimerIsExpired(Timer *timer)
is timer expired?
TimerCountdownMS
void TimerCountdownMS(Timer *timer, unsigned int msecs)
start timer set to milli seconds
NetworkInit
void NetworkInit(Network *n)
Initialize network struct.
TimerInit
void TimerInit(Timer *timer)
Initialize timer struct.
Network::sock
sock_tcp_t sock
socket number
Definition: paho_mqtt.h:106
MutexUnlock
int MutexUnlock(Mutex *mutex)
Unlocks mutex struct.
sock_tcp
TCP sock type.
Definition: sock_types.h:101
xtimer.h
xtimer interface definitions
mutex_t
Mutex structure.
Definition: mutex.h:120
Timer::set_ticks
xtimer_ticks64_t set_ticks
timeout ticks
Definition: paho_mqtt.h:57