0%

kInteractiveProtocol 协议

kInteractiveProtocol 协议 为双向协议,主要用于双方主动发送数据识别在接收时期寻回发送来源,即消息ID。

双向自定义协议

协议说明

协议头

协议头为四个固定字节:0xFF0x270x710xFF;用于标记数据头部

消息ID

目前消息ID支持4字节8字节,双方事先约定,默认8字节长度。如果不需要消息ID,则全填充为 FF

注意:当存在消息ID的时候,需要在对该消息返回的时候,将该消息ID原样返回: 发送的消息ID为: 0x01000001 则返回的消息ID 也需要为 0x01000001;则发送者可以根据消息ID找到发送来源。

可依据实际业务,令消息ID单次有效或多次有效。

自定义消息

自定义消息包含一个自定义消息长度字节,以及长度字节的 自定义消息。

举个例子:

  • 表示没有自定义消息 : 00
  • 表示自定义消息长度为4,且数据为 0x123456780412345678

类型

类型包含一个类型长度字节,以及长度字节的 类型。

举个例子:

  • 表示没有类型 : 00
  • 表示类型长度为4,且数据为 json046A736F6E

数据

数据包含四个数据长度字节,以及长度字节的 数据。

举个例子:

  • 表示没有数据 : 00000000
  • 表示数据长度为00000004,且数据为 data0000000464617461

校验

校验长度为 4;校验方式为 CRC32;

如果弱设备做不了 crc32 的话,就全填入00表示不做校验

协议示例

  • 发送不需要消息ID自定义消息类型的数据;数据内容为: 0x12345678
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    FF2771FFFFFFFFFF0000000000041234567800000000
    --------
    --------
    --
    --
    --------
    --------
    --------
    消息头
    消息ID
    自定义数据长度
    类型长度
    消息长度
    消息内容
    校验(此处没有计算)
  • 发送不需要自定义消息类型的数据;数据内容为: 0x12345678

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    FF2771FF000000010000000000041234567800000000
    --------
    --------
    --
    --
    --------
    --------
    --------
    消息头
    消息ID:1
    自定义数据长度
    类型长度
    消息长度
    消息内容
    校验(此处没有计算)
  • 举个例子:原本简单数据:1A250101,可以使用当前协议改为:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    FF2771FFFFFFFFFF000000000002010100000000
    --------
    --------
    --
    --
    --------
    ----
    --------
    消息头
    不需要 消息ID
    不需要 自定义数据
    不需要 类型
    消息长度 2
    消息内容 0101
    校验(此处没有计算)

C/C++ 实现

kInteractiveProtocol.hpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
//
// Created by caesar kekxv on 2022/2/27.
// Copyright [2022/2/27] <caesar kekxv>
//

#ifndef BASIC_KINTERACTIVEPROTOCOL_KINTERACTIVEPROTOCOL_HPP_
#define BASIC_KINTERACTIVEPROTOCOL_KINTERACTIVEPROTOCOL_HPP_

#include <vector>
#include <plog/plog.h>
#include "tools.h"

class kInteractiveProtocol {
public:
/**
* 数据方式
*/
enum BinaryMode {
/**
* 高位
*/
high,
/**
* 低位
*/
low
};
public:
/**
* 读取数据回调
* @param data 数据存放位置
* @param data_len 数据大小
* @param timeout 超时时间
* @param arg 用户参数
*/
typedef int64_t (*read_callback)(unsigned char *data, unsigned int offset, unsigned int data_len,
unsigned int timeout, void *arg);

/**
* 发送数据回调
* @param data 数据
* @param data_len 数据大小
* @param arg 用户参数
*/
typedef int64_t (*send_callback)(const unsigned char *data, unsigned int offset, unsigned int data_len, void *arg);

private:
/**
* 低位在前 高位在后
*/
BinaryMode binaryMode = BinaryMode::low;
/**
* 关闭检验
*/
bool disable_crc32 = false;
/**
* 头部数据
*/
unsigned char head[4]{0xFF, 0x27, 0x71, 0xFF};
/**
* 消息ID的长度
*/
long message_id_length = 8;
/**
* 消息ID
*/
int64_t message_id = 0;
/**
* 是否开启自定义消息
*/
bool enable_custom_param = true;
/**
* 自定义数据长度
*/
unsigned char custom_param_len = 0;
/**
* 自定义数据
*/
std::string custom_param;
/**
* 是否开启类型配置
*/
bool enable_type = true;
/**
* 类型长度
*/
unsigned char type_len = 0;
/**
* 类型
*/
std::string type;
/**
* 数据长度
*/
unsigned int data_len = 0;
/**
* 数据
*/
std::vector<unsigned char> data;
/**
* crc 计算
*/
unsigned char crc32[4]{0x00, 0x00, 0x00, 0x00};
/**
* crc32 默认值
*/
unsigned int crc32_init = 0;
/**
* 不包含数据以及类型的长度
*/
unsigned int no_date_size = 4 + 1 + 1 + sizeof(unsigned int) + 4;
public:

inline int64_t get_pack_size() {
return no_date_size + get_data_size() + custom_param_len + type_len;
}

/**
* 初始化
* @param _message_id_length 消息长度
* @param binary_mode 数据位高地位
* @param _enable_custom_param 是否开启自定义参数
* @param _enable_type 是否开启类型
* @param _disable_crc32 是否关闭crc32
*/
inline explicit kInteractiveProtocol(long _message_id_length = 8,
BinaryMode binary_mode = BinaryMode::low,
bool _enable_custom_param = true,
bool _enable_type = true,
bool _disable_crc32 = false) {
this->message_id_length = _message_id_length;
this->binaryMode = binary_mode;
this->enable_custom_param = _enable_custom_param;
this->enable_type = _enable_type;
this->disable_crc32 = _disable_crc32;
};

/**
* 检查最小大小
* @param size
* @return
*/
inline bool check_mini_size(int64_t size) const {
return no_date_size < size;
}

/**
* 获取消息ID
* @return
*/
inline int64_t get_message_id() {
return message_id;
}

/**
* 设置消息ID
* @param id
*/
inline void set_message_id(int64_t id) {
message_id = id;
}

/**
* 获取 自定义参数
* @return
*/
inline std::string get_custom_param() {
return custom_param;
}

/**
* 设置 自定义参数
* @return
*/
inline void set_custom_param(const std::string &param) {
custom_param = param;
custom_param_len = custom_param.size();
}

/**
* 获取类型
* @return
*/
inline std::string get_type() {
return type;
}

/**
* 获取数据长度
* @return
*/
inline unsigned int get_data_size() {
return data.size();
}

/**
* 将数据作为字符串返回
* @return
*/
inline std::string get_data_string() {
std::string str;
str.insert(str.end(), data.begin(), data.end());
str.push_back(0x00);
return str;
}

/**
* 获取数据 作为二进制数据
* @return
*/
inline const std::vector<unsigned char> &get_data() {
return data;
}

/**
* 获取校验
* @return 校验
*/
inline unsigned int get_crc() {
unsigned int crc = 0;
memcpy((unsigned char *) &crc, crc32, 4);
return crc;
}

/**
* 获取校验
* @param crc 校验
*/
inline void get_crc(unsigned char crc[4]) {
memcpy(crc, crc32, 4);
}

/**
* 设置数据
* @param _data 数据内容
* @param _data_len 数据长度
* @param _type 数据类型
*/
inline void set_data(unsigned char *_data, unsigned int _data_len, const std::string &_type = "binary") {
this->type = _type;
if (type.empty()) {
type_len = 0;
} else {
type_len = (type[type.size() - 1] == 0x00) ? (type.size() - 1) : (type.size());
}
data.clear();
data.insert(data.end(), _data, _data + _data_len);
data_len = data.size();
}

/**
* 设置 二进制 数据
* @param _data 数据
* @param _type 类型
*/
inline void set_data(std::vector<unsigned char> _data, const std::string &_type = "binary") {
set_data(_data.data(), _data.size(), _type);
}

/**
* 设置字符串数据
* @param _data 数据
* @param _type 类型
*/
inline void set_data(const std::string &_data, const std::string &_type = "text") {
set_data((unsigned char *) _data.data(), _data.size(), _type);
}


/**
* 解包数据
* @param _data 数据
* @param len 数据长度
* @return
*/
inline bool unpack(const unsigned char *_data, unsigned int len) {
unsigned int offset = 0;
if (len < no_date_size) {
LOG(WARNING) << "not long enough [" << len << "][" << (5 + sizeof(unsigned int) + 4) << "]";
return false;
}
for (int i = 0; i < 4; i++) {
if (_data[i] != head[i]) {
LOG(WARNING) << "head is wrong";
return false;
}
}
offset += 4;
if (message_id_length == 8) {
memcpy((unsigned char *) &message_id, &_data[offset], 8);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &message_id, 8);
}
offset += 8;
} else {
message_id = 0;
memcpy(((unsigned char *) &message_id) + 0, &_data[offset], 4);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &message_id, 4);
}
offset += 4;
}

custom_param.clear();
custom_param_len = 0;
if (enable_custom_param) {
custom_param_len = _data[offset];
offset += 1;
if (custom_param_len > 0) {
custom_param.insert(custom_param.end(), &_data[offset], &_data[offset + custom_param_len]);
}
offset += custom_param_len;
}

type.clear();
type_len = 0;
if (enable_type) {
type_len = _data[offset];
offset += 1;
if (type_len > 0) {
type.insert(type.end(), &_data[offset], &_data[offset + type_len]);
type.push_back(0x00);
}
offset += type_len;
}
data.clear();
memcpy((unsigned char *) &data_len, &_data[offset], sizeof(unsigned int));
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &data_len, sizeof(unsigned int));
}
offset += sizeof(unsigned int);
if (len < data_len + no_date_size + message_id_length + type_len) {
LOG(WARNING)
<< "not long enough:[" << len << "<" << (data_len + no_date_size + message_id_length + type_len)
<< "]";
return false;
}
data.insert(data.end(), &_data[offset], &_data[data_len + offset]);
offset += data_len;
unsigned int crc = tools::crc32(_data, offset, crc32_init);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &crc, 4);
}
bool crc_flag = true;
for (int i = 0; i < 4; i++) {
if (_data[offset + i] != ((unsigned char *) &crc)[i]) {
crc_flag = false;
break;
}
}
if (!crc_flag) {
LOG(WARNING) << "crc is wrong";
return false;
}
if (disable_crc32) {
memset(crc32, 0x00, 4);
} else {
memcpy(crc32, (unsigned char *) &crc, 4);
}
offset += 4;
return true;
}

/**
* 解包数据
* @param _data 数据
* @return
*/
inline bool unpack(const std::vector<unsigned char> &_data) {
return unpack(_data.data(), _data.size());
}

/**
* 解包数据
* @param cb 数据回调
* @param timeout 超时时间
* @return
*/
inline bool unpack(read_callback cb, void *arg = nullptr, int timeout = 0) {
std::vector<unsigned char> crc_data;
int64_t offset = 0;
if (cb == nullptr) {
LOG(WARNING) << "read_callback is null";
return false;
}
long long end = tools::get_time_tick() + timeout;
unsigned char d[51];
// read header
do {
int64_t ret = cb(d, 0, 1, 100, arg);
if (ret < 0) {
LOG(WARNING) << "read_callback return :" << ret;
return false;
}
if (ret == 0) {
continue;
}
if (head[offset] != d[0]) {
offset = d[0] == head[0] ? 1 : 0;
} else {
offset++;
}
if (offset == 4) { break; }
} while (timeout <= 0 || end > tools::get_time_tick());
int64_t ret = 0;
// read message_id
if (message_id_length == 8) {
ret = cb((unsigned char *) &message_id, 0, sizeof(int64_t), 200, arg);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &message_id, 8);
}
} else {
message_id = 0;
ret = cb(((unsigned char *) &message_id), 0, 4, 200, arg);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &message_id, 4);
}
}
if (ret != message_id_length) {
LOG(WARNING) << "read_callback message_id return :" << ret;
return false;
}

if (enable_custom_param) {
// read custom_param_len
ret = cb(d, 0, 1, 200, arg);
if (ret != 1) {
LOG(WARNING) << "read_callback custom_param_len return :" << ret;
return false;
}
custom_param_len = d[0];
if (custom_param_len >= 45) {
PLOGW.printf("custom_param_len is %d", custom_param_len);
return false;
}
// read custom_param
offset = 0;
custom_param.clear();
if (custom_param_len > 0) {
do {
ret = cb(d, 0, custom_param_len - offset, 200, arg);
if (ret <= 0) {
LOG(WARNING) << "read_callback custom_param return :" << ret;
return false;
}
custom_param.insert(custom_param.end(), d, d + ret);
offset += ret;
if (offset == custom_param_len) { break; }
} while (timeout <= 0 || end > tools::get_time_tick());
}
}

if (enable_type) {
// read type_len
ret = cb(d, 0, 1, 200, arg);
if (ret != 1) {
LOG(WARNING) << "read_callback type_len return :" << ret;
return false;
}
type_len = d[0];
if (type_len >= 45) {
PLOGW.printf("type_len is %d", type_len);
return false;
}
// read type
offset = 0;
type.clear();
if (type_len > 0) {
do {
ret = cb(d, 0, type_len - offset, 200, arg);
if (ret <= 0) {
LOG(WARNING) << "read_callback type return :" << ret;
return false;
}
type.insert(type.end(), d, d + ret);
offset += ret;
if (offset == type_len) { break; }
} while (timeout <= 0 || end > tools::get_time_tick());
type.push_back(0x00);
}
}

// read data_len
ret = cb(d, 0, 4, 200, arg);
if (ret != 4) {
LOG(WARNING) << "read_callback data_len return :" << ret;
return false;
}
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &d[0], 4);
}
memcpy((unsigned char *) &data_len, d, 4);
// read data
offset = 0;
data.clear();
if (data_len > 0) {
do {
unsigned int read_len = data_len - offset;
if (read_len >= 50) { read_len = 50; }
ret = cb(d, 0, read_len, 200, arg);
if (ret <= 0) {
LOG(WARNING) << "read_callback data return :" << ret << " ," << read_len;
return false;
}
data.insert(data.end(), d, d + ret);
offset += ret;
if (offset == data_len) { break; }
end = tools::get_time_tick() + timeout;
} while (timeout <= 0 || end > tools::get_time_tick());
}
// read crc32
ret = cb(crc32, 0, 4, 200, arg);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &crc32[0], 4);
}
if (ret != 4) {
LOG(WARNING) << "read_callback crc32 return :" << ret;
return false;
}
if (disable_crc32 && crc32[0] == 0x00 && crc32[1] == 0x00 && crc32[2] == 0x00 && crc32[3] == 0x00) {
return true;
}
crc_data.insert(crc_data.end(), head, head + 4);
if (message_id_length == 8) {
if (binaryMode == BinaryMode::high) {
for (int i = 7; i >= 0; i--) {
crc_data.push_back(((unsigned char *) &message_id)[i]);
}
} else {
crc_data.insert(crc_data.end(), (unsigned char *) &message_id,
((unsigned char *) &message_id) + 8);
}
} else {
if (binaryMode == BinaryMode::high) {
for (int i = 3; i >= 0; i--) {
crc_data.push_back(((unsigned char *) &message_id)[i]);
}
} else {
crc_data.insert(crc_data.end(), ((unsigned char *) &message_id) + 0,
((unsigned char *) &message_id) + 4);
}
}
if (enable_custom_param) {
crc_data.push_back(custom_param_len);
if (custom_param_len > 0) {
crc_data.insert(crc_data.end(), custom_param.begin(), custom_param.begin() + custom_param_len);
}
}
if (enable_type) {
crc_data.push_back(type_len);
if (type_len > 0) {
crc_data.insert(crc_data.end(), type.begin(), type.begin() + type_len);
}
}
if (binaryMode == BinaryMode::high) {
for (int i = 3; i >= 0; i--) {
crc_data.push_back(((unsigned char *) &data_len)[i]);
}
} else {
crc_data.insert(crc_data.end(), (unsigned char *) &data_len, ((unsigned char *) &data_len) + 4);
}
crc_data.insert(crc_data.end(), data.begin(), data.end());
unsigned int crc = 0;
memcpy((unsigned char *) &crc, crc32, 4);

unsigned int _crc = tools::crc32(crc_data.data(), crc_data.size(), crc32_init);
if (_crc == crc) {
return true;
}
LOG(WARNING) << "crc32 is wrong :[" << _crc << "][" << crc << "]";
return false;
}

/**
* 打包数据
* @param _data 数据存储位置
*/
inline void pack(std::vector<unsigned char> &_data) const {
_data.insert(_data.end(), &head[0], &head[4]);
if (message_id_length == 8) {
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &message_id, 8);
}
_data.insert(_data.end(), ((unsigned char *) &message_id) + 0,
((unsigned char *) &message_id) + 8);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &message_id, 8);
}
} else {
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &message_id, 4);
}
_data.insert(_data.end(), ((unsigned char *) &message_id) + 0,
((unsigned char *) &message_id) + 4);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &message_id, 4);
}
}
if (enable_custom_param) {
if (custom_param.empty()) {
_data.push_back(0x00);
} else {
unsigned int _custom_param_len = custom_param.size();
_data.push_back(_custom_param_len);
_data.insert(_data.end(), custom_param.begin(), custom_param.begin() + _custom_param_len);
}
}
if (enable_type) {
if (type.empty()) {
// type_len = 0;
_data.push_back(0x00);
} else {
unsigned char _type_len = (type[type.size() - 1] == 0x00) ? (type.size() - 1) : (type.size());
_data.push_back(_type_len);
_data.insert(_data.end(), type.begin(), type.begin() + _type_len);
}
}
unsigned int _data_len = data.size();
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &_data_len, 4);
}
_data.insert(_data.end(), ((unsigned char *) &_data_len) + 0, ((unsigned char *) &_data_len) + 4);
if (!data.empty()) {
_data.insert(_data.end(), data.begin(), data.end());
}
unsigned int crc = 0;
if (!disable_crc32) {
tools::crc32(_data.data(), _data.size(), crc32_init);
if (binaryMode == BinaryMode::high) {
tools::reverse((unsigned char *) &crc, 4);
}
}
_data.insert(_data.end(), ((unsigned char *) &crc) + 0, ((unsigned char *) &crc) + 4);
}

/**
* 发送数据
* @param cb 数据回调
* @return
*/
inline bool pack(send_callback cb, void *arg, unsigned int data_size = 0) const {
if (cb == nullptr) {
LOG(WARNING) << "read_callback is null";
return false;
}
std::vector<unsigned char> _data;
pack(_data);
if (data_size == 0) {
return _data.size() == cb(_data.data(), 0, _data.size(), arg);
}
unsigned int offset = 0;
do {
int64_t send_len = _data.size() - offset;
if (send_len > data_size) {
send_len = data_size;
}
int64_t ret = cb(_data.data(), offset, send_len, arg);
if (ret <= 0) {
LOG(WARNING) << "send : [" << ret << "," << send_len << "]";
return false;
}
offset += ret;
} while (offset < _data.size());
return true;
}


public:
inline kInteractiveProtocol &operator=(const kInteractiveProtocol &old) {
if (this == &old) { return *this; }
std::vector<unsigned char> _data;
this->message_id_length = old.message_id_length;
old.pack(_data);
unpack(_data);
return (*this);
}

/**
* 获取数据
* @param index
* @return
*/
inline unsigned char &operator[](const unsigned int index) {
if (data.size() <= index) {
static unsigned char error_type = 0xff;
error_type = 0xff;
LOG(WARNING) << "out of bounds";
return error_type;
}
return data[index];
}

/**
* 设置消息长度
* @param i 消息长度,仅支持 8和4
*/
void set_message_id_len(long i) {
message_id_length = i;
}

/**
* 设置 crc32 init
* @param i crc32 init
*/
void set_crc32_init(long i) {
crc32_init = i;
}

/**
* 是否启用 crc32
* @param flag
*/
void set_disable_crc32(bool flag = false) {
disable_crc32 = flag;
}

/**
* 设置数据为的高地位
* @param binary_mode
*/
void set_binary_mode(BinaryMode binary_mode = BinaryMode::low) {
binaryMode = binary_mode;
}
};

#endif //BASIC_KINTERACTIVEPROTOCOL_KINTERACTIVEPROTOCOL_HPP_