Tiny protocol  0.7.0
Tiny communication protocol for microcontrollers
TinyLightProtocol.h
Go to the documentation of this file.
1 /*
2  Copyright 2017 (C) Alexey Dynda
3 
4  This file is part of Tiny Protocol Library.
5 
6  Protocol Library is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Protocol 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
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with Protocol Library. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
27 #ifndef _TINY_LIGHT_PROTOCOL_H_
28 #define _TINY_LIGHT_PROTOCOL_H_
29 
30 #include "TinyPacket.h"
31 #include "proto/light/tiny_light.h"
32 
33 #ifdef ARDUINO
34 # include <HardwareSerial.h>
35 #else
36 # include <string.h>
37 #endif
38 
39 namespace Tiny {
40 
47 {
48 public:
49  inline ProtoLight(): m_data{0} { }
50 
59  void begin (write_block_cb_t writecb,
60  read_block_cb_t readcb);
61 
62 #ifdef ARDUINO
63 
68  void beginToSerial();
69 #endif
70 
74  void end ();
75 
84  int write (char* buf, int size);
85 
94  int read (char* buf, int size);
95 
104  int write (Packet &pkt);
105 
114  int read (Packet &pkt);
115 
116 private:
117  STinyLightData m_data;
118 };
119 
120 
121 } // Tiny namespace
122 
123 
124 #endif
int(* write_block_cb_t)(void *pdata, const void *buffer, int size)
Definition: tiny_proto_types.h:114
Tiny protocol Arduino API.
Definition: TinyLightProtocol.h:39
int read(char *buf, int size)
void begin(write_block_cb_t writecb, read_block_cb_t readcb)
int write(char *buf, int size)
Definition: tiny_light.h:51
Definition: TinyPacket.h:44
Definition: TinyLightProtocol.h:46
int(* read_block_cb_t)(void *pdata, void *buffer, int size)
Definition: tiny_proto_types.h:125
Tiny Light protocol API.