MBee Arduino library
MBee.cpp
1 /* "Системы модули и компоненты" ("СМК"). 2020. Москва.
2 Библиотека MBee-Arduino.
3 Распространяется свободно. Надеемся, что программные продукты, созданные
4 с помощью данной библиотеки будут полезными, однако никакие гарантии, явные или
5 подразумеваемые не предоставляются.
6 
7 The MIT License(MIT)
8 
9 MBee-Arduino Library.
10 Copyright © 2020 Systems, modules and components. Moscow. Russia.
11 
12 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13 documentation files(the "Software"), to deal in the Software without restriction, including without limitation
14 the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software,
15 and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
16 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR
19 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 
22 Code adapted from XBee-Arduino library XBee.h. Copyright info below.
23 * @file XBee.h
24 * @author Andrew Rapp
25 * @license This project is released under the GNU License
26 * @copyright Copyright (c) 2009 Andrew Rapp. All rights reserved
27 * @date 2009
28 * @brief Interface to the wireless XBee modules
29 */
30 
31 #include "MBee.h"
32 
33 #if defined(ARDUINO) && ARDUINO >= 100
34  #include "Arduino.h"
35 #else
36  #include "WProgram.h"
37 #endif
38 
39 #include "HardwareSerial.h"
40 
41 
42 /*********************************************************************
43  * Public методы класса MBee.
44  *********************************************************************/
45 void MBee::begin(Stream &serial)
46 {
47  _serial = &serial;
48 }
49 
50 void MBee::setSerial(Stream &serial)
51 {
52  _serial = &serial;
53 }
54 
56 {
57  return _serial->available();
58 }
59 
60 uint8_t MBee::read()
61 {
62  return _serial->read();
63 }
64 
65 void MBee::write(uint8_t val)
66 {
67  _serial->write(val);
68 }
69 
70 
71 
72 
uint8_t read()
Считывает 1 байт из входного буфера UART.
Definition: MBee.cpp:60
void write(uint8_t val)
Передает 1 байт по UART.
Definition: MBee.cpp:65
bool available()
Проверяет наличие принятых данных в буфере UART.
Definition: MBee.cpp:55
void setSerial(Stream &serial)
Назначает последовательный порт.
Definition: MBee.cpp:50
void begin(Stream &serial)
Инициализирует соединение с радиомодулем на заданном COM-порте.
Definition: MBee.cpp:45