2016-01-02 07:41:28 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @file MQTTESP8266.h
|
|
|
|
* @author Baoshi <mail(at)ba0sh1(dot)com>
|
|
|
|
* @version 0.1
|
|
|
|
* @date Sep 9, 2015
|
|
|
|
* @brief Eclipse Paho ported to ESP8266 RTOS
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
* @copyright
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015, Baoshi Zhu. All rights reserved.
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE.txt file.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED 'AS-IS', WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTY. IN NO EVENT WILL THE AUTHOR(S) BE HELD LIABLE FOR ANY DAMAGES
|
|
|
|
* ARISING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef _MQTT_ESP8266_H_
|
|
|
|
#define _MQTT_ESP8266_H_
|
|
|
|
|
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <portmacro.h>
|
|
|
|
|
2016-09-15 17:52:57 +00:00
|
|
|
typedef struct mqtt_timer mqtt_timer_t;
|
2016-01-02 07:41:28 +00:00
|
|
|
|
2016-09-15 17:52:57 +00:00
|
|
|
struct mqtt_timer
|
2016-01-02 07:41:28 +00:00
|
|
|
{
|
2016-11-05 10:04:03 +00:00
|
|
|
TickType_t end_time;
|
2016-01-02 07:41:28 +00:00
|
|
|
};
|
|
|
|
|
2016-09-15 17:52:57 +00:00
|
|
|
typedef struct mqtt_network mqtt_network_t;
|
2016-01-02 07:41:28 +00:00
|
|
|
|
2016-09-15 17:52:57 +00:00
|
|
|
struct mqtt_network
|
2016-01-02 07:41:28 +00:00
|
|
|
{
|
|
|
|
int my_socket;
|
2016-09-15 17:52:57 +00:00
|
|
|
int (*mqttread) (mqtt_network_t*, unsigned char*, int, int);
|
|
|
|
int (*mqttwrite) (mqtt_network_t*, unsigned char*, int, int);
|
2016-01-02 07:41:28 +00:00
|
|
|
};
|
|
|
|
|
2016-09-15 17:52:57 +00:00
|
|
|
char mqtt_timer_expired(mqtt_timer_t*);
|
|
|
|
void mqtt_timer_countdown_ms(mqtt_timer_t*, unsigned int);
|
|
|
|
void mqtt_timer_countdown(mqtt_timer_t*, unsigned int);
|
|
|
|
int mqtt_timer_left_ms(mqtt_timer_t*);
|
|
|
|
void mqtt_timer_init(mqtt_timer_t*);
|
2016-01-02 07:41:28 +00:00
|
|
|
|
2016-09-15 17:52:57 +00:00
|
|
|
int mqtt_esp_read(mqtt_network_t*, unsigned char*, int, int);
|
|
|
|
int mqtt_esp_write(mqtt_network_t*, unsigned char*, int, int);
|
|
|
|
void mqtt_esp_disconnect(mqtt_network_t*);
|
2016-01-02 07:41:28 +00:00
|
|
|
|
2016-09-15 17:52:57 +00:00
|
|
|
void mqtt_network_new(mqtt_network_t* n);
|
|
|
|
int mqtt_network_connect(mqtt_network_t* n, const char* host, int port);
|
|
|
|
int mqtt_network_disconnect(mqtt_network_t* n);
|
2016-01-02 07:41:28 +00:00
|
|
|
|
|
|
|
#endif /* _MQTT_ESP8266_H_ */
|