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 "thread.h"
24 #include "net/sock/tcp.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
33 #ifndef MQTT_THREAD_PRIORITY
34 #define MQTT_THREAD_PRIORITY (THREAD_PRIORITY_MAIN - 1)
35 #endif
36 
41 #ifndef MQTT_THREAD_STACKSIZE
42 #define MQTT_THREAD_STACKSIZE (THREAD_STACKSIZE_LARGE)
43 #endif
47 #ifndef MQTT_YIELD_POLLING_MS
48 #define MQTT_YIELD_POLLING_MS (30)
49 #endif
50 
55 typedef struct {
56  uint32_t timeout;
57  uint32_t time_set;
58 } Timer;
59 
65 void TimerInit(Timer *timer);
66 
74 char TimerIsExpired(Timer *timer);
75 
82 void TimerCountdownMS(Timer *timer, unsigned int msecs);
83 
90 void TimerCountdown(Timer *timer, unsigned int secs);
91 
99 int TimerLeftMS(Timer *timer);
100 
104 typedef struct Network {
109  int (*mqttread) (struct Network*, unsigned char*, int, int);
113  int (*mqttwrite) (struct Network*, unsigned char*, int, int);
115 
122 
132 int NetworkConnect(Network *n, char* address_ip, int port_number);
133 
140 
144 typedef struct {
146 } Mutex;
147 
153 void MutexInit(Mutex *mutex);
154 
162 int MutexLock(Mutex *mutex);
163 
171 int MutexUnlock(Mutex *mutex);
172 
176 typedef struct {
177  char stack[MQTT_THREAD_STACKSIZE];
179 } Thread;
180 
190 int ThreadStart(Thread *thread, void (*fn)(void *), void *arg);
191 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif /* PAHO_MQTT_H */
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:139
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:42
int MutexLock(Mutex *mutex)
Locks mutex struct.
int ThreadStart(Thread *thread, void(*fn)(void *), void *arg)
Start new thread.
struct Network Network
Network struct within mqtt paho.
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:144
mutex_t lock
MQTT thread mutex.
Definition: paho_mqtt.h:145
Network struct within mqtt paho.
Definition: paho_mqtt.h:104
int(* mqttwrite)(struct Network *, unsigned char *, int, int)
write internal function
Definition: paho_mqtt.h:113
sock_tcp_t sock
socket number
Definition: paho_mqtt.h:105
int(* mqttread)(struct Network *, unsigned char *, int, int)
read internal function
Definition: paho_mqtt.h:109
Thread struct within mqtt paho.
Definition: paho_mqtt.h:176
kernel_pid_t pid
MQTT thread pid.
Definition: paho_mqtt.h:178
struct to get time references within mqtt paho
Definition: paho_mqtt.h:55
uint32_t time_set
set time in ms
Definition: paho_mqtt.h:57
uint32_t timeout
timeout in ms
Definition: paho_mqtt.h:56
Mutex structure.
Definition: mutex.h:146
TCP sock type.
Definition: sock_types.h:101