Skip to content

Commit 33ec070

Browse files
authored
Add files via upload
Modified include directives to be able to compile for ESP32.
1 parent b49ee3c commit 33ec070

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

MySQL_Packet.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved.
3+
4+
This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation; version 2 of the License.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program; if not, write to the Free Software
15+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+
17+
MySQL_Packet.h - Packet library for communicating with a MySQL Server
18+
19+
This header file defines the base packet handling code for connecting
20+
to a MySQL server and executing queries.
21+
22+
Change History:
23+
24+
Version 1.0.0a Created by Dr. Charles A. Bell, April 2012.
25+
Version 1.0.0b Updated by Dr. Charles A. Bell, October 2013.
26+
Version 1.0.1b Updated by Dr. Charles A. Bell, February 2014.
27+
Version 1.0.2b Updated by Dr. Charles A. Bell, April 2014.
28+
Version 1.0.3rc Updated by Dr. Charles A. Bell, March 2015.
29+
Version 1.0.4ga Updated by Dr. Charles A. Bell, July 2015.
30+
Version 1.1.0a Created by Dr. Charles A. Bell, January 2016.
31+
Version 1.1.1a Created by Dr. Charles A. Bell, January 2016.
32+
*/
33+
#ifndef MYSQL_PACKET_H
34+
#define MYSQL_PACKET_H
35+
36+
//added Carlos
37+
#ifdef ARDUINO_ARCH_ESP32
38+
#include <Arduino.h>
39+
#else
40+
#include <Ethernet.h>
41+
#endif
42+
43+
#define MYSQL_OK_PACKET 0x00
44+
#define MYSQL_EOF_PACKET 0xfe
45+
#define MYSQL_ERROR_PACKET 0xff
46+
#define MYSQL_VERSION_STR "1.1.1a"
47+
48+
const char MEMORY_ERROR[] PROGMEM = "Memory error.";
49+
const char PACKET_ERROR[] PROGMEM = "Packet error.";
50+
const char READ_TIMEOUT[] PROGMEM = "ERROR: Timeout waiting for client.";
51+
52+
class MySQL_Packet {
53+
public:
54+
byte *buffer; // buffer for reading packets
55+
int packet_len; // length of current packet
56+
Client *client; // instance of client class (e.g. EthernetClient)
57+
char *server_version; // save server version from handshake
58+
59+
MySQL_Packet(Client *client_instance);
60+
boolean complete_handshake(char *user, char *password);
61+
void send_authentication_packet(char *user, char *password);
62+
void parse_handshake_packet();
63+
boolean scramble_password(char *password, byte *pwd_hash);
64+
void read_packet();
65+
int get_packet_type();
66+
void parse_error_packet();
67+
int get_lcb_len(int offset);
68+
int read_int(int offset, int size=0);
69+
void store_int(byte *buff, long value, int size);
70+
int wait_for_bytes(int bytes_count);
71+
void show_error(const char *msg, bool EOL = false);
72+
void print_packet();
73+
74+
private:
75+
byte seed[20];
76+
};
77+
78+
#endif

0 commit comments

Comments
 (0)