V1.1.3 Update
This commit is contained in:
parent
b064df5fe7
commit
03f642c7d9
|
@ -19,6 +19,10 @@ This library is now complete, the remaining work is mainly maintenance and bug f
|
|||
|
||||
# Change Log
|
||||
|
||||
**V1.1.3 2023.5.3**
|
||||
|
||||
+ Bug fix, use minimized vector implementation instead of std::vector to adapt to more boards, the implementation is from [@a6c0424fa083's vector_for_arduino](https://github.com/a6c0424fa083/vector_for_arduino), which I improved slightly on.
|
||||
|
||||
**V1.1.2 2023.4.22**
|
||||
|
||||
+ Modify header files to avoid compilation conflicts, add warnings for certain boards that do not support STL.(If your board are Arduino AVR architecture(like Arduino Uno), you have to comment 'const std::nothrow_t std::nothrow = { };' in 'ArduinoSTL/src/new_handler.cpp')
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
DLLN3X KEYWORD1
|
||||
ZigbeeFrame KEYWORD1
|
||||
Vector KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
name= DLLN3X ZigBee Mesh Module Library
|
||||
version= 1.1.2
|
||||
version= 1.1.3
|
||||
author= Dylan Liu <mentalflow@ourdocs.cn>
|
||||
maintainer= Dylan Liu <mentalflow@ourdocs.cn>
|
||||
sentence= This library allows you to use DLLN3X ZigBee mesh module very easily.
|
||||
paragraph= This library currently allows basic send and receive operations, config read/modify, link quility test, pin control and more.
|
||||
category= Communication
|
||||
architectures= *
|
||||
includes= DLLN3X.h,zigbeeframe.h
|
||||
includes= DLLN3X.h,zigbeeframe.h,zigbee_vector.h
|
||||
license= MIT
|
||||
url= https://github.com/mentalfl0w/DLLN3X_zigbee_mesh_module_library
|
||||
|
|
|
@ -5,10 +5,19 @@ using namespace zigbee_protocol;
|
|||
DLLN3X::DLLN3X() { }
|
||||
DLLN3X::~DLLN3X() { }
|
||||
|
||||
void DLLN3X::init(HardwareSerial* DSerial)
|
||||
void DLLN3X::init(HardwareSerial* DSerial, uint32_t baudrate)
|
||||
{
|
||||
_DSerial = DSerial;
|
||||
DSerial->begin(115200);
|
||||
uint8_t i = 0;
|
||||
for (; i < 13; i++)
|
||||
if (baudrate == _baud_rate_list[i])
|
||||
{
|
||||
i = 20;
|
||||
break;
|
||||
}
|
||||
if (i != 20)
|
||||
return;
|
||||
DSerial->begin(baudrate);
|
||||
DSerial->setTimeout(10000);
|
||||
rled_blink();
|
||||
read_addr();
|
||||
|
@ -18,10 +27,19 @@ void DLLN3X::init(HardwareSerial* DSerial)
|
|||
}
|
||||
|
||||
#if __has_include(<SoftwareSerial.h>)
|
||||
void DLLN3X::init(SoftwareSerial* DSerial)
|
||||
void DLLN3X::init(SoftwareSerial* DSerial, uint32_t baudrate)
|
||||
{
|
||||
_DSerial = DSerial;
|
||||
DSerial->begin(115200);
|
||||
uint8_t i = 0;
|
||||
for (; i < 13; i++)
|
||||
if (baudrate == _baud_rate_list[i])
|
||||
{
|
||||
i = 20;
|
||||
break;
|
||||
}
|
||||
if (i != 20)
|
||||
return;
|
||||
DSerial->begin(baudrate);
|
||||
DSerial->setTimeout(10000);
|
||||
rled_blink();
|
||||
read_addr();
|
||||
|
@ -49,9 +67,11 @@ ZigbeeFrame DLLN3X::recv(bool non_blocked)
|
|||
|
||||
bool DLLN3X::send(ZigbeeFrame zf)
|
||||
{
|
||||
bool status = false;
|
||||
if (zf.getSrcPort() < 0x80)
|
||||
return false;
|
||||
return _DSerial->write(zf.data(), zf.size());
|
||||
status = _DSerial->write(zf.data(),zf.size());
|
||||
return status;
|
||||
}
|
||||
|
||||
bool DLLN3X::send_cmd(uint8_t des_port, uint8_t arg, uint8_t* data, uint8_t data_length)
|
||||
|
@ -106,7 +126,8 @@ uint32_t DLLN3X::read_baudrate()
|
|||
uint8_t DLLN3X::set_baudrate(uint32_t baud_rate)
|
||||
{
|
||||
uint8_t arg = 0;
|
||||
for (uint8_t i = 0; i < 13; i++)
|
||||
uint8_t i = 0;
|
||||
for (; i < 13; i++)
|
||||
{
|
||||
if (baud_rate == _baud_rate_list[i])
|
||||
{
|
||||
|
@ -114,6 +135,8 @@ uint8_t DLLN3X::set_baudrate(uint32_t baud_rate)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (arg != i)
|
||||
return CONFIG_RESPONSE::CMD_ERROR;
|
||||
uint8_t resp = rw_config(CONFIG::BAUDRATE, arg, CONFIG_RW_MASK::WRITE);
|
||||
if (resp == CONFIG_RESPONSE::DONE)
|
||||
{
|
||||
|
@ -180,7 +203,7 @@ uint16_t DLLN3X::rw_config(CONFIG arg, uint16_t data, CONFIG_RW_MASK mask)
|
|||
return 0;
|
||||
switch (arg) {
|
||||
case CONFIG::ADDR: {
|
||||
if (zf.getDataLength() != 3 || zf.getData()[0] != 0x21) {
|
||||
if (zf.getData()[0] != 0x21) {
|
||||
if (zf.getData()[0] != CONFIG_RESPONSE::DONE)
|
||||
{
|
||||
Serial.print("DLLN3X write config error: 0x");
|
||||
|
@ -191,7 +214,7 @@ uint16_t DLLN3X::rw_config(CONFIG arg, uint16_t data, CONFIG_RW_MASK mask)
|
|||
return (zf.getData()[2] << 8) | zf.getData()[1];
|
||||
}
|
||||
case CONFIG::NETWORKID: {
|
||||
if (zf.getDataLength() != 3 || zf.getData()[0] != 0x22) {
|
||||
if (zf.getData()[0] != 0x22) {
|
||||
if (zf.getData()[0] != CONFIG_RESPONSE::DONE)
|
||||
{
|
||||
Serial.print("DLLN3X write config error: 0x");
|
||||
|
@ -202,7 +225,7 @@ uint16_t DLLN3X::rw_config(CONFIG arg, uint16_t data, CONFIG_RW_MASK mask)
|
|||
return (zf.getData()[2] << 8) | zf.getData()[1];
|
||||
}
|
||||
case CONFIG::CHANNEL: {
|
||||
if (zf.getDataLength() != 2 || zf.getData()[0] != 0x23) {
|
||||
if (zf.getData()[0] != 0x23) {
|
||||
if (zf.getData()[0] != CONFIG_RESPONSE::DONE)
|
||||
{
|
||||
Serial.print("DLLN3X write config error: 0x");
|
||||
|
@ -213,7 +236,7 @@ uint16_t DLLN3X::rw_config(CONFIG arg, uint16_t data, CONFIG_RW_MASK mask)
|
|||
return zf.getData()[1];
|
||||
}
|
||||
case CONFIG::BAUDRATE: {
|
||||
if (zf.getDataLength() != 2 || zf.getData()[0] != 0x24) {
|
||||
if (zf.getData()[0] != 0x24) {
|
||||
if (zf.getData()[0] != CONFIG_RESPONSE::DONE)
|
||||
{
|
||||
Serial.print("DLLN3X write config error: 0x");
|
||||
|
|
|
@ -33,9 +33,9 @@ public:
|
|||
enum PIN{ DLLN3X_PIN4 = 0x44, DLLN3X_PIN5 = 0x45};
|
||||
DLLN3X();
|
||||
~DLLN3X();
|
||||
void init(HardwareSerial* DSerial);
|
||||
void init(HardwareSerial* DSerial, uint32_t baudrate = 115200);
|
||||
#if __has_include(<SoftwareSerial.h>)
|
||||
void init(SoftwareSerial* DSerial);
|
||||
void init(SoftwareSerial* DSerial, uint32_t baudrate = 115200);
|
||||
#endif
|
||||
ZigbeeFrame recv(bool non_blocked = true);
|
||||
bool send(ZigbeeFrame zf);
|
||||
|
|
|
@ -0,0 +1,278 @@
|
|||
// include guard for save inclusion
|
||||
#ifndef ZIGBEE_VECTOR_H
|
||||
#define ZIGBEE_VECTOR_H
|
||||
|
||||
// you will need the uncomment this include if you want to use this library in normal C++ (for using the (u)intX_t
|
||||
// datatypes)
|
||||
// #include <cstdint>
|
||||
|
||||
// vector class
|
||||
|
||||
// template for a variety of datatypes (int, char, String, custom classes)
|
||||
namespace zigbee_protocol {
|
||||
template <typename T> class Vector {
|
||||
public:
|
||||
// default constructor
|
||||
Vector<T>() { }
|
||||
/**
|
||||
*@brief constructor with a length and a placeholder
|
||||
*@param i_size: this is the length of the vector you want the start with
|
||||
*@param i_placeholder: the whole vector is filled up with this value...
|
||||
*/
|
||||
Vector<T>(uint16_t i_size, T i_placeholder)
|
||||
{
|
||||
// create a temporary heap array with the specified length
|
||||
T* temp = new T[i_size];
|
||||
|
||||
// loop through the temporary heap array and set each element equal to the placeholder
|
||||
for (uint16_t i = 0; i < i_size; i++) {
|
||||
temp[i] = i_placeholder;
|
||||
}
|
||||
// set the address 'array' is pointing to equal to the address 'temp' is pointing to
|
||||
array = temp;
|
||||
|
||||
// set the size (or length) of the vector equal the the constructor size
|
||||
_size = i_size;
|
||||
}
|
||||
|
||||
// default destructor
|
||||
~Vector<T>() = default;
|
||||
|
||||
public:
|
||||
/**
|
||||
*@brief a function that returns a reference of an element of 'array' at a spesific position (index) of 'array'
|
||||
*@param index: this is the index of 'array' you want get access to...
|
||||
*@return the function returns a reference of an element of 'array'. that way you can either read out the element or
|
||||
*write to it
|
||||
*/
|
||||
T& at(uint16_t index)
|
||||
{
|
||||
// if the specified index is a valid element of 'array' just return it
|
||||
if (index < _size) {
|
||||
return array[index];
|
||||
}
|
||||
// if the specified index to greater than the last index of the last element return the last element of 'array'
|
||||
else {
|
||||
return array[_size - 1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief this function adds an element at the last position (index) of 'array'
|
||||
*@param data: this is the element you want to append the the vector
|
||||
*/
|
||||
void push_back(T data)
|
||||
{
|
||||
// if there is already one or more elements on 'array'
|
||||
if (_size > 0) {
|
||||
// create a temporary heap array with one more element than the current 'array'
|
||||
T* temp = new T[_size + 1];
|
||||
|
||||
// copy all existing elements from 'array' to 'temp'
|
||||
for (uint16_t i = 0; i < _size; i++) {
|
||||
temp[i] = array[i];
|
||||
}
|
||||
// set the last element of 'temp' equal to the value of 'data'
|
||||
temp[_size] = data;
|
||||
|
||||
// delete the values of 'array'
|
||||
delete[] array;
|
||||
|
||||
// set the address 'array' is pointing to equal the the address 'temp' is pointing to
|
||||
array = temp;
|
||||
}
|
||||
// if 'array' has no elements in it create one
|
||||
else {
|
||||
// just allocate a one element large array of 'T' and fill it up with the value in 'data'
|
||||
array = new T[1] { data };
|
||||
}
|
||||
// either way increment the size (or length) of the vector
|
||||
_size++;
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief this function inserts an element at a specific index
|
||||
*@param index: this is the position the new element will be placed at
|
||||
*@param data: this is the element inserted
|
||||
*/
|
||||
void insert(uint16_t index, T data)
|
||||
{
|
||||
// test if the index is in range of the vector
|
||||
if (index <= _size) {
|
||||
// create a temporary heap array with one more element than the current 'array'
|
||||
T* temp = new T[_size + 1];
|
||||
|
||||
// copy all values the the temporary 'array' to 'temp'. stop at index
|
||||
for (uint16_t i = 0; i < index; i++) {
|
||||
temp[i] = array[i];
|
||||
}
|
||||
// insert the new element in 'temp' at desired index
|
||||
temp[index] = data;
|
||||
|
||||
// copy the remaining values from 'array' to 'temp'
|
||||
for (uint16_t i = index + 1; i < _size + 1; i++) {
|
||||
temp[i] = array[i - 1];
|
||||
}
|
||||
// delete the values of 'array'
|
||||
delete[] array;
|
||||
|
||||
// set the address 'array' is pointing to equal the the address 'temp' is pointing to
|
||||
array = temp;
|
||||
|
||||
// increment the size of the vector
|
||||
_size++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief this function inserts a vector at a specific index
|
||||
*@param index: this is the (first) position the new vector will be placed at
|
||||
*@param data: this is the vector inserted
|
||||
*@Note this function is similar the the function above
|
||||
*/
|
||||
void insert(uint16_t index, Vector<T> data)
|
||||
{
|
||||
if (index <= _size && data.size() > 0) {
|
||||
T* temp = new T[_size + data.size()];
|
||||
|
||||
for (uint16_t i = 0; i < index; i++) {
|
||||
temp[i] = array[i];
|
||||
}
|
||||
for (uint16_t i = index; i < index + data.size(); i++) {
|
||||
temp[i] = data.at(i - index);
|
||||
}
|
||||
for (uint16_t i = index + data.size(); i < _size + data.size(); i++) {
|
||||
temp[i] = array[i - data.size()];
|
||||
}
|
||||
|
||||
delete[] array;
|
||||
|
||||
array = temp;
|
||||
|
||||
_size += data.size();
|
||||
}
|
||||
}
|
||||
/**
|
||||
*@brief this function erases a element at a specific index
|
||||
*@param index: this is the position the element will be erased
|
||||
*/
|
||||
|
||||
void erase(uint16_t index)
|
||||
{
|
||||
// test if the index is in range of the vector
|
||||
if (index < _size) {
|
||||
// create a temporary heap array with one more element than the current 'array'
|
||||
T* temp = new T[_size - 1];
|
||||
|
||||
// copy all values the the temporary 'array' to 'temp'. stop at index
|
||||
for (uint16_t i = 0; i < index; i++) {
|
||||
temp[i] = array[i];
|
||||
}
|
||||
// jump over the value at index
|
||||
|
||||
// copy the remaining values from 'array' to 'temp'
|
||||
for (uint16_t i = index + 1; i < _size; i++) {
|
||||
temp[i - 1] = array[i];
|
||||
}
|
||||
// delete the values of 'array'
|
||||
delete[] array;
|
||||
|
||||
// set the address 'array' is pointing to equal the the address 'temp' is pointing to
|
||||
array = temp;
|
||||
|
||||
// decrement the size of the vector
|
||||
_size--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief this function erases a element at a specific index
|
||||
*@param min_index: this is the first position the element will be erased
|
||||
*@param max_index: this is the last position the element will be erased
|
||||
*@Note this function is similar the the function above
|
||||
*/
|
||||
void erase(uint16_t min_index, uint16_t max_index)
|
||||
{
|
||||
if (max_index < _size && min_index <= max_index) {
|
||||
T* temp = new T[_size - 1];
|
||||
|
||||
for (uint16_t i = 0; i < min_index; i++) {
|
||||
temp[i] = array[i];
|
||||
}
|
||||
for (uint16_t i = min_index; i < _size - (max_index - min_index); i++) {
|
||||
temp[i] = array[i - min_index + max_index + 1];
|
||||
}
|
||||
|
||||
delete[] array;
|
||||
|
||||
array = temp;
|
||||
|
||||
_size -= max_index - min_index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// this function will erase the last element of the vector
|
||||
void pop_back()
|
||||
{
|
||||
// test if the vector has at least 1 element
|
||||
if (_size > 0) {
|
||||
// create a temporary heap array with one more element than the current 'array'
|
||||
T* temp = new T[_size - 1];
|
||||
|
||||
// copy all values except the very last the the temporary 'array' to 'temp'
|
||||
for (uint16_t i = 0; i < _size - 1; i++) {
|
||||
temp[i] = array[i];
|
||||
}
|
||||
// delete the values of 'array'
|
||||
delete[] array;
|
||||
|
||||
// set the address 'array' is pointing to equal the the address 'temp' is pointing to
|
||||
array = temp;
|
||||
|
||||
// decrement the size of the vector
|
||||
_size--;
|
||||
}
|
||||
}
|
||||
// instead of using the 'at()' function you can also access elements like you would in an array
|
||||
T& operator[](uint16_t index) { return at(index); }
|
||||
|
||||
T* data()
|
||||
{
|
||||
return array;
|
||||
}
|
||||
|
||||
// this function erases every element in the array. mainly to free up storage
|
||||
void clear()
|
||||
{
|
||||
if (_size > 0) {
|
||||
delete[] array;
|
||||
_size = 0;
|
||||
}
|
||||
}
|
||||
// this function returns the current size (or length) of the vector
|
||||
uint16_t size() const { return _size; }
|
||||
|
||||
private:
|
||||
/*
|
||||
this the the array of the template datatype 'T'.
|
||||
it's the core element of the vector
|
||||
|
||||
|
||||
how the heap array is working:
|
||||
|
||||
when you create a heap array, the computer first assigns you a free address within the heap.
|
||||
if you later want to add elements to the array, you have to "ask" the computer for space in the heap.
|
||||
note that you can only allocate space once.
|
||||
so if you need more or less space or elements in the array,
|
||||
you first have to delete all elements of the array to set a new length.
|
||||
|
||||
that was just a very brief explanation of how this works
|
||||
*/
|
||||
T* array;
|
||||
|
||||
// this is the size (or length) of the vector respectively the array
|
||||
uint16_t _size = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ZIGBEE_VECTOR_H
|
|
@ -1,10 +1,7 @@
|
|||
#ifndef _ZIGBEEFRAME_H_
|
||||
#define _ZIGBEEFRAME_H_
|
||||
#include <Arduino.h>
|
||||
#if __has_include(<vector>)
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include "zigbee_vector.h"
|
||||
|
||||
namespace zigbee_protocol {
|
||||
class ZigbeeFrame {
|
||||
|
@ -13,7 +10,7 @@ private:
|
|||
uint8_t _length = 0, _src_port = 0, _des_port = 0;
|
||||
uint8_t _pack_len = 0;
|
||||
uint16_t _remote_addr = 0;
|
||||
std::vector<uint8_t> _data, _packed_data, _package;
|
||||
Vector<uint8_t> _data, _packed_data, _package;
|
||||
|
||||
public:
|
||||
ZigbeeFrame(char* data) { setData((uint8_t*)data, strlen(data)); };
|
||||
|
@ -73,7 +70,7 @@ public:
|
|||
uint16_t getRemoteAddr() { return _remote_addr; };
|
||||
uint8_t getLength() { return _data.size() + 4; };
|
||||
uint8_t getDataLength() { return _data.size(); };
|
||||
std::vector<uint8_t>& getData() { return _data; };
|
||||
Vector<uint8_t>& getData() { return _data; };
|
||||
void setData(uint8_t* data, uint8_t length)
|
||||
{
|
||||
_data.clear();
|
||||
|
@ -81,7 +78,7 @@ public:
|
|||
};
|
||||
void setData(char* data) { setData((uint8_t*)data, strlen(data)); };
|
||||
void setData(char* data, uint8_t length) { setData((uint8_t*)data, length); };
|
||||
void setData(std::vector<uint8_t> data) { _data = data; };
|
||||
void setData(Vector<uint8_t> data) { _data = data; };
|
||||
void addData(char* data) { addData(data, strlen(data)); };
|
||||
void addData(uint8_t* data, uint8_t length)
|
||||
{
|
||||
|
@ -90,7 +87,7 @@ public:
|
|||
}
|
||||
};
|
||||
void addData(char* data, uint8_t length) { addData((uint8_t*)data, length); };
|
||||
void addData(std::vector<uint8_t> data) { _data.insert(_data.end(), data.begin(), data.end()); };
|
||||
void addData(Vector<uint8_t> data) { _data.insert(_data.size(), data); };
|
||||
void clear()
|
||||
{
|
||||
_package.clear();
|
||||
|
@ -114,7 +111,7 @@ public:
|
|||
_length = _data.size() + 4;
|
||||
};
|
||||
void pack() { pack(_data, _packed_data); };
|
||||
void pack(std::vector<uint8_t> data, std::vector<uint8_t>& pack_data)
|
||||
void pack(Vector<uint8_t> data, Vector<uint8_t>& pack_data)
|
||||
{
|
||||
pack_data.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
|
@ -130,7 +127,7 @@ public:
|
|||
}
|
||||
};
|
||||
void depack() { depack(_data, _packed_data); };
|
||||
void depack(std::vector<uint8_t>& data, std::vector<uint8_t> pack_data)
|
||||
void depack(Vector<uint8_t>& data, Vector<uint8_t> pack_data)
|
||||
{
|
||||
data.clear();
|
||||
for (int i = 0; i < pack_data.size(); i++) {
|
||||
|
@ -145,8 +142,8 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
void make_package(uint8_t src_port, uint8_t des_port, uint16_t remote_addr, std::vector<uint8_t>& package,
|
||||
std::vector<uint8_t> data, std::vector<uint8_t>& pack_data)
|
||||
void make_package(uint8_t src_port, uint8_t des_port, uint16_t remote_addr, Vector<uint8_t>& package,
|
||||
Vector<uint8_t> data, Vector<uint8_t>& pack_data)
|
||||
{
|
||||
pack(data, pack_data);
|
||||
package.clear();
|
||||
|
@ -156,15 +153,15 @@ public:
|
|||
package.push_back(des_port);
|
||||
package.push_back(remote_addr & 0xFF);
|
||||
package.push_back((remote_addr >> 8) & 0xFF);
|
||||
package.insert(package.end(), pack_data.begin(), pack_data.end());
|
||||
package.insert(package.size(), pack_data);
|
||||
package.push_back(tail);
|
||||
};
|
||||
std::vector<uint8_t> get_package()
|
||||
Vector<uint8_t> get_package()
|
||||
{
|
||||
make_package(_src_port, _des_port, _remote_addr, _package, _data, _packed_data);
|
||||
return _package;
|
||||
};
|
||||
void load_package(std::vector<uint8_t>& buf) { load_package(buf.data(), buf.size()); };
|
||||
void load_package(Vector<uint8_t>& buf) { load_package(buf.data(), buf.size()); };
|
||||
void load_package(uint8_t* buf, uint8_t length)
|
||||
{
|
||||
_packed_data.clear();
|
||||
|
@ -189,23 +186,23 @@ public:
|
|||
Serial.print("remote_addr:");
|
||||
Serial.println(_remote_addr, HEX);
|
||||
Serial.print("data:");
|
||||
for (auto byte : _data) {
|
||||
for (uint8_t i = 0; i < _data.size(); i++) {
|
||||
char buf[4];
|
||||
sprintf(buf, "%02X ", byte);
|
||||
sprintf(buf, "%02X ", _data[i]);
|
||||
Serial.print(buf);
|
||||
}
|
||||
Serial.println();
|
||||
Serial.print("packed_data:");
|
||||
for (auto byte : _packed_data) {
|
||||
for (uint8_t i = 0; i < _packed_data.size(); i++) {
|
||||
char buf[4];
|
||||
sprintf(buf, "%02X ", byte);
|
||||
sprintf(buf, "%02X ", _packed_data[i]);
|
||||
Serial.print(buf);
|
||||
}
|
||||
Serial.println();
|
||||
Serial.print("package:");
|
||||
for (auto byte : _package) {
|
||||
for (uint8_t i = 0; i < _package.size(); i++) {
|
||||
char buf[4];
|
||||
sprintf(buf, "%02X ", byte);
|
||||
sprintf(buf, "%02X ", _package[i]);
|
||||
Serial.print(buf);
|
||||
}
|
||||
Serial.println();
|
||||
|
@ -250,21 +247,6 @@ public:
|
|||
addData(data, (uint8_t)strlen(data));
|
||||
get_package();
|
||||
};
|
||||
friend std::ostream& operator<<(std::ostream& os, const ZigbeeFrame& zf)
|
||||
{
|
||||
os << "src_port:" << zf._src_port << '\n'
|
||||
<< "des_port:" << zf._des_port << '\n'
|
||||
<< "remote_addr:" << zf._remote_addr << '\n'
|
||||
<< "packed_data:";
|
||||
for (auto byte : zf._packed_data)
|
||||
os << std::hex << std::uppercase << byte << ' ';
|
||||
os << '\n';
|
||||
return os;
|
||||
}
|
||||
};
|
||||
}
|
||||
#else
|
||||
#error Your Board Didn't support STL, Please install "ArduinoSTL" Library.
|
||||
#error If your board are Arduino AVR architecture(like Arduino Uno), you have to comment 'const std::nothrow_t std::nothrow = { };' in 'ArduinoSTL/src/new_handler.cpp'
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue