• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright (c) 2014, 2015 IBM Corp.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * and Eclipse Distribution License v1.0 which accompany this distribution.
7  *
8  * The Eclipse Public License is available at
9  *    http://www.eclipse.org/legal/epl-v10.html
10  * and the Eclipse Distribution License is available at
11  *   http://www.eclipse.org/org/documents/edl-v10.php.
12  *
13  * Contributors:
14  *    Allan Stockdill-Mander - initial API and implementation and/or initial documentation
15  *******************************************************************************/
16 
17 #if !defined(MQTTFreeRTOS_H)
18 #define MQTTFreeRTOS_H
19 
20 #include "FreeRTOS.h"
21 #include "FreeRTOS_Sockets.h"
22 #include "FreeRTOS_IP.h"
23 #include "semphr.h"
24 #include "task.h"
25 
26 typedef struct Timer
27 {
28 	TickType_t xTicksToWait;
29 	TimeOut_t xTimeOut;
30 } Timer;
31 
32 typedef struct Network Network;
33 
34 struct Network
35 {
36 	xSocket_t my_socket;
37 	int (*mqttread) (Network*, unsigned char*, int, int);
38 	int (*mqttwrite) (Network*, unsigned char*, int, int);
39 	void (*disconnect) (Network*);
40 };
41 
42 void TimerInit(Timer*);
43 char TimerIsExpired(Timer*);
44 void TimerCountdownMS(Timer*, unsigned int);
45 void TimerCountdown(Timer*, unsigned int);
46 int TimerLeftMS(Timer*);
47 
48 typedef struct Mutex
49 {
50 	SemaphoreHandle_t sem;
51 } Mutex;
52 
53 void MutexInit(Mutex*);
54 int MutexLock(Mutex*);
55 int MutexUnlock(Mutex*);
56 
57 typedef struct Thread
58 {
59 	TaskHandle_t task;
60 } Thread;
61 
62 int ThreadStart(Thread*, void (*fn)(void*), void* arg);
63 
64 int FreeRTOS_read(Network*, unsigned char*, int, int);
65 int FreeRTOS_write(Network*, unsigned char*, int, int);
66 void FreeRTOS_disconnect(Network*);
67 
68 void NetworkInit(Network*);
69 int NetworkConnect(Network*, char*, int);
70 /*int NetworkConnectTLS(Network*, char*, int, SlSockSecureFiles_t*, unsigned char, unsigned int, char);*/
71 
72 #endif
73