This repository has been archived by the owner on Mar 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
esp8266.h
108 lines (85 loc) · 3.04 KB
/
esp8266.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* C library for the ESP8266 WiFi module with a PIC microcontroller
* Copyright (C) 2015 Camil Staps <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*****************************************************************************
*
* File: esp8266.h
* Author: Camil Staps <[email protected]>
* Website: http://github.com/camilstaps/ESP8266_PIC
* Version: 0.1
*
* See: esp8266.c
*
* This is the header file for the ESP8266 PIC18 library. It contains:
*
* * Constants and bitmasks
* * Prototypes for functions that should be written by the user for his
* implementation
* * Prototypes for functions that can be used by the user
* * Prototypes for functions that are intended for internal use only
*/
#include <stdbool.h>
#include <stdint.h>
#ifndef ESP8266_H
#define ESP8266_H
#ifdef __cplusplus
extern "C" {
#endif
/** Some constants **/
#define ESP8266_STATION 0x01
#define ESP8266_SOFTAP 0x02
#define ESP8266_TCP 1
#define ESP8266_UDP 0
#define ESP8266_OK 1
#define ESP8266_READY 2
#define ESP8266_FAIL 3
#define ESP8266_NOCHANGE 4
#define ESP8266_LINKED 5
#define ESP8266_UNLINK 6
/** Should be witten by the user for input from / output to the ESP module **/
void _esp8266_putch(unsigned char);
unsigned char _esp8266_getch(void);
/** Function prototypes **/
bit esp8266_isStarted(void); // Check if the module is started (AT)
bit esp8266_restart(void); // Restart module (AT+RST)
void esp8266_echoCmds(bool); // Enabled/disable command echoing (ATE)
// WIFI Mode (station/softAP/station+softAP) (AT+CWMODE)
void esp8266_mode(unsigned char);
// Connect to AP (AT+CWJAP)
unsigned char esp8266_connect(unsigned char*, unsigned char*);
// Disconnect from AP (AT+CWQAP)
void esp8266_disconnect(void);
// Local IP (AT+CIFSR)
void esp8266_ip(char*);
// Create connection (AT+CIPSTART)
bit esp8266_start(unsigned char protocol, char* ip, unsigned char port);
// Send data (AT+CIPSEND)
bit esp8266_send(unsigned char*);
// Receive data (+IPD)
void esp8266_receive(unsigned char*, uint16_t, bool);
/** Functions for internal use only **/
// Print a string to the output
void _esp8266_print(unsigned const char *);
// Wait for a certain string on the input
inline uint16_t _esp8266_waitFor(unsigned char *);
// Wait for any response on the input
inline unsigned char _esp8266_waitResponse(void);
#ifdef __cplusplus
}
#endif
#endif /* ESP8266_H */