112 lines
2.1 KiB
C
112 lines
2.1 KiB
C
#pragma once
|
|
|
|
//message type Note : '[' + Note + ']'
|
|
struct Note {
|
|
//
|
|
int32_t id;
|
|
float pitch;
|
|
float velocity;
|
|
float onoff;
|
|
float x1;
|
|
float x2;
|
|
float x3;
|
|
float x4;
|
|
float ps;
|
|
//
|
|
Note() {
|
|
id = 0;
|
|
pitch = 0;
|
|
velocity = 0;
|
|
onoff = 0;
|
|
x1 = 0;
|
|
x2 = 0;
|
|
x3 = 0;
|
|
x4 = 0;
|
|
ps = 0;
|
|
}
|
|
Note(int32_t id_, float pitch_, float velocity_, float onoff_, float x1_, float x2_, float x3_, float x4_, float ps_)
|
|
{
|
|
id = id_;
|
|
pitch = pitch_;
|
|
velocity = velocity_;
|
|
onoff = onoff_;
|
|
x1 = x1_;
|
|
x2 = x2_;
|
|
x3 = x3_;
|
|
x4 = x4_;
|
|
ps = ps_;
|
|
}
|
|
//
|
|
void clear() {
|
|
id = 0;
|
|
pitch = 0;
|
|
velocity = 0;
|
|
onoff = 0;
|
|
x1 = 0;
|
|
x2 = 0;
|
|
x3 = 0;
|
|
x4 = 0;
|
|
ps = 0;
|
|
}
|
|
//
|
|
String to_string() {
|
|
String str = "";
|
|
str += "( id=" + String(id);
|
|
str += ", pitch=" + String(pitch);
|
|
str += ", velocity=" + String(velocity);
|
|
str += ", onoff=" + String(onoff);
|
|
str += ", x1=" + String(x1);
|
|
str += ", x2=" + String(x2);
|
|
str += ", x3=" + String(x3);
|
|
str += ", x4=" + String(x4);
|
|
str += ", ps=" + String(ps);
|
|
str += " )";
|
|
return str;
|
|
}
|
|
};
|
|
|
|
//message type Hello : '{' + Hello + '}'
|
|
#define SIGNATURE_LENGTH (20)
|
|
#define SIGNATURE_BUFF_LEN (SIGNATURE_LENGTH + 1)
|
|
struct Hello {
|
|
char sign[SIGNATURE_BUFF_LEN];
|
|
int32_t id;
|
|
uint32_t mac32;
|
|
float h1;
|
|
float h2;
|
|
float h3;
|
|
float h4;
|
|
//
|
|
Hello(String sign_, int32_t id_ = 0, uint32_t mac32_ = 0, float h1_ = 0, float h2_ = 0, float h3_ = 0, float h4_ = 0) {
|
|
id = id_;
|
|
mac32 = mac32_;
|
|
h1 = h1_;
|
|
h2 = h2_;
|
|
h3 = h3_;
|
|
h4 = h4_;
|
|
sign_.toCharArray(sign, SIGNATURE_BUFF_LEN);
|
|
}
|
|
void clear() {
|
|
id = 0;
|
|
mac32 = 0;
|
|
h1 = 0;
|
|
h2 = 0;
|
|
h3 = 0;
|
|
h4 = 0;
|
|
sign[0] = '\0';
|
|
}
|
|
//
|
|
String to_string() {
|
|
String str = "";
|
|
str += "( id=" + String(id);
|
|
str += ", mac32=0x" + String(mac32, HEX);
|
|
str += ", sign=\"" + String(sign) + "\"";
|
|
str += ", h1=" + String(h1);
|
|
str += ", h2=" + String(h2);
|
|
str += ", h3=" + String(h3);
|
|
str += ", h4=" + String(h4);
|
|
str += " )";
|
|
return str;
|
|
}
|
|
};
|