EL_dev_arduino 2.6.0
読み取り中…
検索中…
一致する文字列を見つけられません
/Users/sugimura/EL_dev_arduino/EL.h
[詳解]
1
8#ifndef __EL_H__
9#define __EL_H__
10#pragma once
11
12// #define EL_DEBUG
13#include <Arduino.h>
14#include <WiFi.h>
15#include <WiFiUDP.h>
16#include "ELOBJ.h"
17
18// defined
19#define EL_PORT 3610
20#define EL_EHD1 0
21#define EL_EHD2 1
22#define EL_TID 2
23#define EL_SEOJ 4
24#define EL_DEOJ 7
25#define EL_ESV 10
26#define EL_OPC 11
27#define EL_EPC 12
28#define EL_PDC 13
29#define EL_EDT 14
30#define EL_SETI_SNA 0x50
31#define EL_SETC_SNA 0x51
32#define EL_GET_SNA 0x52
33#define EL_INF_SNA 0x53
34#define EL_SETGET_SNA 0x5e
35#define EL_SETI 0x60
36#define EL_SETC 0x61
37#define EL_GET 0x62
38#define EL_INF_REQ 0x63
39#define EL_SETGET 0x6e
40#define EL_SET_RES 0x71
41#define EL_GET_RES 0x72
42#define EL_INF 0x73
43#define EL_INFC 0x74
44#define EL_INFC_RES 0x7a
45#define EL_SETGET_RES 0x7e
46#define EL_BUFFER_SIZE 1500
47
48// Device Object
49// センサ関連機器
50#define EL_GasLeakSensor 0x00, 0x01
51#define EL_CrimePreventionSensor 0x00, 0x02
52#define EL_EmergencyButton 0x00, 0x03
53#define EL_FirstAidSensor 0x00, 0x04
54#define EL_EarthquakeSensor 0x00, 0x05
55#define EL_ElectricLeakSensor 0x00, 0x06
56#define EL_HumanDetectionSensor 0x00, 0x07
57#define EL_VisitorSensor 0x00, 0x08
58#define EL_CallSensor 0x00, 0x09
59#define EL_CondensationSensor 0x00, 0x0A
60#define EL_AirPollutionSensor 0x00, 0x0B
61#define EL_OxygenSensor 0x00, 0x0C
62#define EL_IlluminanceSensor 0x00, 0x0D
63#define EL_SoundSensor 0x00, 0x0E
64#define EL_MailingSensor 0x00, 0x0F
65#define EL_WeightSensor 0x00, 0x10
66#define EL_TemperatureSensor 0x00, 0x11
67#define EL_HumiditySensor 0x00, 0x12
68#define EL_RainSensor 0x00, 0x13
69#define EL_WaterLevelSensor 0x00, 0x14
70#define EL_BathWaterLevelSensor 0x00, 0x15
71#define EL_BathHeatingStatusSensor 0x00, 0x16
72#define EL_WaterLeakSensor 0x00, 0x17
73#define EL_WaterOverflowSensor 0x00, 0x18
74#define EL_FireSensor 0x00, 0x19
75#define EL_CigaretteSmokeSensor 0x00, 0x1A
76#define EL_CO2Sensor 0x00, 0x1B
77#define EL_GasSensor 0x00, 0x1C
78#define EL_VOCSensor 0x00, 0x1D
79#define EL_DifferentialPressureSensor 0x00, 0x1E
80#define EL_AirSpeedSensor 0x00, 0x1F
81#define EL_OdorSensor 0x00, 0x20
82#define EL_FlameSensor 0x00, 0x21
83#define EL_ElectricEnergySensor 0x00, 0x22
84#define EL_CurrentValueSensor 0x00, 0x23
85#define EL_WaterFlowRateSensor 0x00, 0x25
86#define EL_MicromotionSensor 0x00, 0x26
87#define EL_PassageSensor 0x00, 0x27
88#define EL_BedPresenceSensor 0x00, 0x28
89#define EL_OpenCloseSensor 0x00, 0x29
90#define EL_ActivityAmountSensor 0x00, 0x2A
91#define EL_HumanBodyLocationSensor 0x00, 0x2B
92#define EL_SnowSensor 0x00, 0x2C
93// 空調関連機器
94#define EL_HomeAirConditioner 0x01, 0x30
95#define EL_VentilationFan 0x01, 0x32
96#define EL_AirConditionerVentilationFan 0x01, 0x34
97#define EL_AirCleaner 0x01, 0x35
98#define EL_Humidifier 0x01, 0x39
99#define EL_ElectricHeater 0x01, 0x42
100#define EL_FanHeater 0x01, 0x43
101#define EL_PackageTypeCommercialAirConditionerIndoorUnit 0x01, 0x56
102#define EL_PackageTypeCommercialAirConditionerOutdoorUnit 0x01, 0x57
103// 住宅・設備関連機器
104#define EL_ElectricallyOperatedShade 0x02, 0x60
105#define EL_ElectricShutter 0x02, 0x61
106#define EL_ElectricStormWindow 0x02, 0x63
107#define EL_Sprinkler 0x02, 0x67
108#define EL_ElectricWaterHeater 0x02, 0x6B
109#define EL_ElectricToiletSeat 0x02, 0x6E
110#define EL_ElectricLock 0x02, 0x6F
111#define EL_InstantaneousWaterHeater 0x02, 0x72
112#define EL_BathroomHeaterAndDryer 0x02, 0x73
113#define EL_HouseholdSolarPowerGeneration 0x02, 0x79
114#define EL_ColdOrHotWaterHeatSourceEquipment 0x02, 0x7A
115#define EL_FloorHeater 0x02, 0x7B
116#define EL_FuelCell 0x02, 0x7C
117#define EL_Battery 0x02, 0x7D
118#define EL_ElectricVehicle 0x02, 0x7E
119#define EL_EngineCogeneration 0x02, 0x7F
120#define EL_WattHourMeter 0x02, 0x80
121#define EL_WaterFlowmeter 0x02, 0x81
122#define EL_GasMeter 0x02, 0x82
123#define EL_LPGasMeter 0x02, 0x83
124#define EL_PowerDistributionBoardMetering 0x02, 0x87
125#define EL_SmartElectricEnergyMeter 0x02, 0x88
126#define EL_SmartGasMeter 0x02, 0x89
127#define EL_GeneralLighting 0x02, 0x90
128#define EL_Buzzer 0x02, 0xA0
129// 調理・家事関連機器
130#define EL_ElectricHotWaterPot 0x03, 0xB2
131#define EL_Refrigerator 0x03, 0xB7
132#define EL_CombinationMicrowaveOven 0x03, 0xB8
133#define EL_CookingHeater 0x03, 0xB9
134#define EL_RiceCooker 0x03, 0xBB
135#define EL_WashingMachine 0x03, 0xC5
136#define EL_ClothesDryer 0x03, 0xC6
137#define EL_WasherAndDryer 0x03, 0xD3
138// 健康関連機器
139#define EL_Weighing 0x04, 0x01
140// 管理・操作関連機器
141#define EL_Switch 0x05, 0xFD
142#define EL_Controller 0x05, 0xFF
143// AV関連機器
144#define EL_Display 0x06, 0x01
145#define EL_Television 0x06, 0x02
146
151class EL
152{
153private:
154 IPAddress ip;
155 IPAddress _multi;
156 IPAddress _broad;
157 byte* _eojs;
158 int deviceCount;
159 int _sendPacketSize = 0;
160 int _readPacketSize = 0;
161 byte _sBuffer[EL_BUFFER_SIZE];
162 WiFiUDP* _udp;
163
164
165protected:
166 int parsePacket(void); // 受信データを読む
167 void commonConstructor(WiFiUDP& udp, byte eojs[][3], int count); // コンストラクタで共通にコールされる
168 void tidAutoIncrement(void); // データ送信時にTIDを自動的にインクリメントの再計算する(シンプルに+1するとオーバーフローするのでこれ使う)
169
170public:
174 byte _tid[2];
175
177 EL(WiFiUDP& udp, byte classGroupCode, byte classCode, byte instanceNumber);
178 EL(WiFiUDP& udp, byte eojs[][3], int count);
179 void begin(void);
180
181 // details change
182 void update(const byte epc, byte pdcedt[]);
183 byte* at(const byte epc);
184 void update(const int devId, const byte epc, byte pdcedt[]);
185 byte* at(const int devId, const byte epc);
186
187 // sender
188 void send(IPAddress toip, byte sBuffer[], int size);
189 void sendOPC1(const IPAddress toip, const byte tid[], const byte seoj[], const byte* deoj, const byte esv, const byte epc, const byte edt[]);
190 void sendOPC1(const IPAddress toip, const byte seoj[], const byte deoj[], const byte esv, const byte epc, const byte edt[]);
191 void sendOPC1(const IPAddress toip, const byte deoj[], const byte esv, const byte epc, const byte* edt);
192 void sendOPC1(const IPAddress toip, const int devId, const byte deoj[], const byte esv, const byte epc, const byte* pdcedt);
193 void sendBroad(byte sBuffer[], int size);
194 void sendMulti(byte sBuffer[], int size);
195 void sendMultiOPC1(const byte tid[], const byte seoj[], const byte deoj[], const byte esv, const byte epc, const byte edt[]);
196 void sendMultiOPC1(const byte seoj[], const byte deoj[], const byte esv, const byte epc, const byte edt[]);
197 void sendMultiOPC1(const byte deoj[], const byte esv, const byte epc, const byte edt[]);
198 void sendMultiOPC1(const int devId, const byte deoj[], const byte esv, const byte epc, const byte* pdcedt);
199 // multi opc
200 void sendDetails(const IPAddress toip, const byte tid[], const byte seoj[], const byte deoj[], const byte esv, const byte opc, const byte detail[], const byte detailSize);
201 // return
202 // void replyOPC1(const IPAddress toip, const unsigned short tid, const byte *seoj, const byte* deoj, const byte esv, const byte epc, const byte* edt);
203 void replyGetDetail(const IPAddress toip);
204 boolean replyGetDetail_sub(const byte eoj[], const byte epc, byte& devId );
205 void replySetDetail(const IPAddress toip);
206 boolean replySetDetail_sub(const byte eoj[], const byte epc, byte& devId );
207
208 // reseiver
209 int read();
210 IPAddress remoteIP(void);
211 void returner(void);
212
213 // display, debug
214 void printAll(void);
215
217 // inline function
218 // byte[] を安全にdeleteする
219 void delPtr(byte ptr[]);
220
221};
222
223#endif
225// EOF
#define EL_BUFFER_SIZE
Definition: EL.h:46
Subclasses for ECHONET Lite protocol
Main class for EL
Definition: EL.h:152
void update(const byte epc, byte pdcedt[])
EPCの値を変更する, eojが1個の場合(複数の場合は0番に相当)
Definition: EL.cpp:176
void replySetDetail(const IPAddress toip)
Setに対して複数OPCにも対応して返答する内部関数
Definition: EL.cpp:643
boolean replySetDetail_sub(const byte eoj[], const byte epc, byte &devId)
EOJとEPCを指定したとき、そのプロパティ(EDT)があるかチェックする内部関数
Definition: EL.cpp:726
boolean replyGetDetail_sub(const byte eoj[], const byte epc, byte &devId)
EOJとEPCを指定したとき、そのプロパティ(EDT)があるかチェックする内部関数
Definition: EL.cpp:608
void begin(void)
通信の開始、受信開始
Definition: EL.cpp:135
void sendMultiOPC1(const byte tid[], const byte seoj[], const byte deoj[], const byte esv, const byte epc, const byte edt[])
void delPtr(byte ptr[])
byte[] を安全にdeleteするinline関数
Definition: EL.cpp:912
void sendMulti(byte sBuffer[], int size)
マルチキャストによる送信(default: 192.168.1.255)
Definition: EL.cpp:252
int parsePacket(void)
受信データを読む
Definition: EL.cpp:763
void returner(void)
Definition: EL.cpp:801
void sendDetails(const IPAddress toip, const byte tid[], const byte seoj[], const byte deoj[], const byte esv, const byte opc, const byte detail[], const byte detailSize)
複数のEPCで送信する場合はこれを使う
Definition: EL.cpp:492
void send(IPAddress toip, byte sBuffer[], int size)
IP指定による送信
Definition: EL.cpp:374
ELOBJ profile
profile object (for specialist)
Definition: EL.h:171
void sendMultiOPC1(const int devId, const byte deoj[], const byte esv, const byte epc, const byte *pdcedt)
void replyGetDetail(const IPAddress toip)
Getに対して複数OPCにも対応して返答する内部関数
Definition: EL.cpp:528
byte _rBuffer[EL_BUFFER_SIZE]
receive buffer
Definition: EL.h:173
byte * at(const byte epc)
EPCの値を取得する, eojが1個の場合(複数の場合は0番に相当)
Definition: EL.cpp:186
void sendMultiOPC1(const byte seoj[], const byte deoj[], const byte esv, const byte epc, const byte edt[])
void sendOPC1(const IPAddress toip, const int devId, const byte deoj[], const byte esv, const byte epc, const byte *pdcedt)
ELOBJ * devices
device objects (for multi eoj)
Definition: EL.h:172
void tidAutoIncrement(void)
TIDの自動インクリメント、オーバーフロー対策
Definition: EL.cpp:118
void sendOPC1(const IPAddress toip, const byte deoj[], const byte esv, const byte epc, const byte *edt)
void sendOPC1(const IPAddress toip, const byte tid[], const byte seoj[], const byte *deoj, const byte esv, const byte epc, const byte edt[])
void commonConstructor(WiFiUDP &udp, byte eojs[][3], int count)
コンストラクタ共通処理
Definition: EL.cpp:47
int read()
受信データを受け取る
Definition: EL.cpp:784
byte _tid[2]
TID (semi-auto incremented)
Definition: EL.h:174
void printAll(void)
インスタンスの情報を表示
Definition: EL.cpp:885
void sendMultiOPC1(const byte deoj[], const byte esv, const byte epc, const byte edt[])
void sendBroad(byte sBuffer[], int size)
ブロードキャストによる送信(default: 192.168.1.255)
Definition: EL.cpp:228
IPAddress remoteIP(void)
受信データの送信元を取得する
Definition: EL.cpp:773
EL Object
Definition: ELOBJ.h:74
byte * pdcedt
Definition: main.cpp:56