ESP3D
3.0
Firmware for ESP boards connected to 3D Printer
BT_service.h
Go to the documentation of this file.
1
/*
2
BT_service.h - Bluetooth service functions class
3
4
Copyright (c) 2014 Luc Lebosse. All rights reserved.
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
10
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
#ifndef _BT_SERVICE_H
21
#define _BT_SERVICE_H
22
23
#include "Print.h"
24
25
#define ESP3D_BT_BUFFER_SIZE 512
26
27
class
BTService
:
public
Print
28
{
29
public
:
30
BTService
();
31
~BTService
();
32
static
void
BTEvent
(uint8_t event);
33
const
char
*
hostname
();
34
static
const
char
*
macAddress
();
35
static
const
char
*
clientmacAddress
();
36
bool
begin
();
37
void
end
();
38
void
handle
();
39
bool
reset
();
40
bool
started
();
41
static
void
setClientAddress
(
const
char
* saddress);
42
bool
isConnected
();
43
void
flush
();
44
int
availableForWrite
();
45
int
available
();
46
size_t
write
(uint8_t c);
47
size_t
write
(
const
uint8_t *buffer,
size_t
size);
48
inline
size_t
write
(
const
char
* s)
49
{
50
return
write
((uint8_t*) s, strlen(s));
51
}
52
inline
size_t
write
(
unsigned
long
n)
53
{
54
return
write
((uint8_t) n);
55
}
56
inline
size_t
write
(
long
n)
57
{
58
return
write
((uint8_t) n);
59
}
60
inline
size_t
write
(
unsigned
int
n)
61
{
62
return
write
((uint8_t) n);
63
}
64
inline
size_t
write
(
int
n)
65
{
66
return
write
((uint8_t) n);
67
}
68
int
read
();
69
size_t
readBytes
(uint8_t * sbuf,
size_t
len);
70
private :
71
static
String _btname;
72
static
String _btclient;
73
uint32_t _lastflush;
74
uint8_t _buffer[
ESP3D_BT_BUFFER_SIZE
+ 1];
//keep space of 0x0 terminal
75
size_t
_buffer_size;
76
void
push2buffer(uint8_t * sbuf,
size_t
len);
77
void
flushbuffer();
78
};
79
80
extern
BTService
bt_service
;
81
82
#endif //_BT_SERVICE_H
BTService::clientmacAddress
static const char * clientmacAddress()
BTService::available
int available()
BTService::write
size_t write(unsigned long n)
Definition:
BT_service.h:52
ESP3D_BT_BUFFER_SIZE
#define ESP3D_BT_BUFFER_SIZE
Definition:
BT_service.h:25
BTService::end
void end()
BTService::write
size_t write(const char *s)
Definition:
BT_service.h:48
BTService::macAddress
static const char * macAddress()
BTService
Definition:
BT_service.h:27
BTService::setClientAddress
static void setClientAddress(const char *saddress)
BTService::write
size_t write(int n)
Definition:
BT_service.h:64
BTService::~BTService
~BTService()
BTService::availableForWrite
int availableForWrite()
BTService::begin
bool begin()
BTService::write
size_t write(uint8_t c)
BTService::write
size_t write(unsigned int n)
Definition:
BT_service.h:60
BTService::BTEvent
static void BTEvent(uint8_t event)
BTService::write
size_t write(long n)
Definition:
BT_service.h:56
BTService::flush
void flush()
BTService::read
int read()
BTService::reset
bool reset()
BTService::handle
void handle()
BTService::started
bool started()
BTService::readBytes
size_t readBytes(uint8_t *sbuf, size_t len)
bt_service
BTService bt_service
BTService::isConnected
bool isConnected()
BTService::hostname
const char * hostname()
BTService::BTService
BTService()
esp3d
src
modules
bluetooth
BT_service.h
Generated by
1.8.17