19EL::EL(WiFiUDP &udp,
byte eoj0,
byte eoj1,
byte eoj2)
30 _multi = IPAddress(224, 0, 23, 0);
46EL::EL(WiFiUDP &udp,
byte eoj[][3],
int count)
55 _eojs[i * 3 + 0] = eoj[i][0];
56 _eojs[i * 3 + 1] = eoj[i][1];
57 _eojs[i * 3 + 2] = eoj[i][2];
64 _multi = IPAddress(224, 0, 23, 0);
78 Serial.printf(
"eojs[%d] = %02x%02x%02x", i, *(
_eojs + i * 3 + 0), *(
_eojs + i * 3 + 1), *(
_eojs + i * 3 + 2));
85 Serial.println(
"EL.udp.begin successful.");
89 Serial.println(
"Reseiver udp.begin failed.");
94 Serial.println(
"EL.udp.beginMulticast successful.");
98 Serial.println(
"Reseiver EL.udp.beginMulticast failed.");
102 profile[0x80] =
new byte[2]{0x01, 0x30};
103 profile[0x81] =
new byte[2]{0x01, 0x00};
104 profile[0x82] =
new byte[5]{0x04, 0x01, 0x0a, 0x01, 0x00};
105 profile[0x83] =
new byte[19]{0x12, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
106 profile[0x88] =
new byte[4]{0x01, 0x42};
107 profile[0x8a] =
new byte[4]{0x03, 0x00, 0x00, 0x77};
108 profile[0x9d] =
new byte[3]{0x02, 0x01, 0x80};
109 profile[0x9e] =
new byte[3]{0x02, 0x01, 0x80};
110 profile[0x9f] =
new byte[16]{0x0f, 0x0e, 0x80, 0x81, 0x82, 0x83, 0x88, 0x8a, 0x9d, 0x9e, 0x9f, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7};
118 memcpy(&
profile[0xd5][2 + i *
sizeof(
byte[3])], &
_eojs[i *
sizeof(
byte[3])],
sizeof(
byte[3]));
119 memcpy(&
profile[0xd6][2 + i *
sizeof(
byte[3])], &
_eojs[i *
sizeof(
byte[3])],
sizeof(
byte[3]));
120 memcpy(&
profile[0xd7][2 + i *
sizeof(
byte[2])], &
_eojs[i *
sizeof(
byte[3])],
sizeof(
byte[2]));
124 details[0x80] =
new byte[2]{0x01, 0x30};
125 details[0x81] =
new byte[2]{0x01, 0x00};
126 details[0x82] =
new byte[5]{0x04, 0x00, 0x00, 0x4b, 0x00};
127 details[0x83] =
new byte[19]{0x12, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
128 details[0x88] =
new byte[4]{0x01, 0x42};
129 details[0x8a] =
new byte[4]{0x03, 0x00, 0x00, 0x77};
130 details[0x9d] =
new byte[4]{0x03, 0x02, 0x80, 0xd6};
131 details[0x9e] =
new byte[3]{0x02, 0x01, 0xe0};
132 details[0x9f] =
new byte[11]{0x0a, 0x09, 0x80, 0x81, 0x82, 0x83, 0x88, 0x8a, 0x9d, 0x9e, 0x9f};
155byte *
EL::at(
const int devId,
const byte epc)
172 _udp->write(sBuffer, size);
175 if (
_udp->endPacket())
181 Serial.println(
"UDP endPacket(B) failed.");
191 if (
_udp->beginMulticastPacket())
194 _udp->write(sBuffer, size);
197 if (
_udp->endPacket())
203 Serial.println(
"UDP endPacket(M) failed.");
208void EL::sendMultiOPC1(
const byte *tid,
const byte *seoj,
const byte *deoj,
const byte esv,
const byte epc,
const byte *
pdcedt)
237 Serial.print(
"sendMultiOPC1 packet: ");
250 const byte tid[] = {0x00, 0x00};
257 const byte tid[] = {0x00, 0x00};
264 const byte tid[] = {0x00, 0x00};
265 const byte seoj[] = {
266 _eojs[devId * 3 + 0],
267 _eojs[devId * 3 + 1],
268 _eojs[devId * 3 + 2],
275void EL::send(IPAddress toip,
byte sBuffer[],
int size)
281 _udp->write(sBuffer, size);
285 Serial.println(
"UDP beginPacket failed.");
288 if (
_udp->endPacket())
294 Serial.println(
"UDP endPacket failed.");
299void EL::sendOPC1(
const IPAddress toip,
const byte *tid,
const byte *seoj,
const byte *deoj,
const byte esv,
const byte epc,
const byte *
pdcedt)
328 Serial.print(
"sendOPC1 packet: ");
339void EL::sendOPC1(
const IPAddress toip,
const byte *seoj,
const byte *deoj,
const byte esv,
const byte epc,
const byte *
pdcedt)
341 const byte tid[] = {0x00, 0x00};
346void EL::sendOPC1(
const IPAddress toip,
const byte *deoj,
const byte esv,
const byte epc,
const byte *
pdcedt)
348 const byte tid[] = {0x00, 0x00};
351void EL::sendOPC1(
const IPAddress toip,
const int devId,
const byte *deoj,
const byte esv,
const byte epc,
const byte *
pdcedt)
353 const byte tid[] = {0x00, 0x00};
354 const byte seoj[] = {
355 _eojs[devId * 3 + 0],
356 _eojs[devId * 3 + 1],
357 _eojs[devId * 3 + 2],
366 return _udp->parsePacket();
371 return _udp->remoteIP();
399 if (deoj[0] == 0x0e && deoj[1] == 0xf0)
404 else if (deoj[0] ==
_eoj[0] && deoj[1] ==
_eoj[1])
411 boolean noDevice =
true;
414 const byte eoj0 =
_eojs[i *
sizeof(
byte[3]) + 0];
415 const byte eoj1 =
_eojs[i *
sizeof(
byte[3]) + 1];
416 Serial.printf(
"%d, esv:%02x, epc:%02x, eoj0:%02x == %02x, eoj1:%02x == %02x", i, esv, epc, eoj0, deoj[0], eoj1, deoj[1]);
418 if (deoj[0] == eoj0 && deoj[1] == eoj1)
422 Serial.printf(
"pdcedt: %p",
pdcedt);
440 Serial.print(
"SETC or GET: ");
441 Serial.println(epc, HEX);
451 sendOPC1(remIP, tid, deoj, seoj, (esv - 0x10), epc,
nullptr);
457 Serial.print(
"INF_REQ: ");
458 Serial.println(epc, HEX);
466 sendOPC1(remIP, tid, deoj, seoj, (esv - 0x10), epc,
nullptr);
ECHONET Lite protocol for Arduino
#define EL_PORT
ECHONET Lite port
Subclasses for ECHONET Lite protocol
void update(const byte epc, byte pdcedt[])
void sendMulti(byte sBuffer[], int size)
void send(IPAddress toip, byte sBuffer[], int size)
ELOBJ profile
profile object (for specialist)
void sendMultiOPC1(const byte *tid, const byte *seoj, const byte *deoj, const byte esv, const byte epc, const byte *edt)
byte _rBuffer[EL_BUFFER_SIZE]
receive buffer
byte _broad[4]
broadcast address
byte * at(const byte epc)
ELOBJ details
device object (for simple eoj)
byte _sBuffer[EL_BUFFER_SIZE]
send buffer
byte * _eojs
for multi eojs obj
ELOBJ * devices
device objects (for multi eoj)
void sendOPC1(const IPAddress toip, const byte *tid, const byte *seoj, const byte *deoj, const byte esv, const byte epc, const byte *edt)
EL(WiFiUDP &udp, byte eoj0, byte eoj1, byte eoj2)
オブジェクトを一つだけサポートする場合のコンストラクタ
void sendBroad(byte sBuffer[], int size)
IPAddress _multi
multicast address
byte _eoj[3]
for simple eoj obj
const PDCEDT SetPDCEDT(const byte epc, const PDCEDT pdcedt)
const PDCEDT GetPDCEDT(const byte epc) const