EL
- Description:
- ECHONET Lite プロトコルのメインオブジェクト
- Source:
Methods
(static) ELDATA2Array(eldata) → {Array.<number>}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
eldata |
Object
|
ELDATAオブジェクト |
Returns:
バイト配列
-
Type
-
Array.<number>
(static) bytesShow(bytes)
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
bytes |
Array.<number>
|
Buffer
|
バイト配列 |
(static) bytesToString(bytes) → {string}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
bytes |
Array.<number>
|
バイト配列 |
Returns:
16進数文字列
-
Type
-
string
(static) clearObserveFacilities()
- Description:
- Source:
(static) complementFacilities() → {void}
- Description:
- 機器情報の不足プロパティを補完取得
ネットワーク負荷に注意(頻繁な実行は避ける)
- Source:
Returns:
-
Type
-
void
(static) complementFacilities_sub(ip, eoj, props) → {void}
- Description:
- complementFacilities のサブルーチン - 個別機器のプロパティ補完
- Source:
Parameters:
| Name |
Type |
Description |
ip |
string
|
機器のIPアドレス |
eoj |
string
|
ECHONET Liteオブジェクト(6桁hex) |
props |
Object.<string, string>
|
現在保持しているプロパティ情報 {EPC: EDT} |
Returns:
-
Type
-
void
(static) decreaseWaitings()
- Description:
- Source:
(static) eldataShow(eldata)
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
eldata |
Object
|
パース済みのELDATAオブジェクト |
(static) getClassList(objList) → {Array.<string>}
- Description:
- インスタンスリストからクラスリストを作成(重複削除)
- Source:
Parameters:
| Name |
Type |
Description |
objList |
Array.<string>
|
オブジェクトリスト(例: ['05ff01', '013001']) |
Returns:
クラスリスト(例: ['05ff', '0130'])
-
Type
-
Array.<string>
(static) getPropertyMaps(ip, _eoj) → {void}
- Description:
- 機器のプロパティマップをすべて取得
デバイス負荷を考慮して遅延を入れる
- Source:
Parameters:
| Name |
Type |
Description |
ip |
string
|
Object
|
機器のIPアドレス(文字列 or rinfo) |
_eoj |
string
|
Array.<number>
|
ECHONET Liteオブジェクト(6桁hex or 3バイト配列) |
Returns:
-
Type
-
void
(static) getSeparatedString_ELDATA(eldata) → {string}
- Description:
- ELDATAオブジェクトをスペース区切りの文字列に変換
- Source:
Parameters:
| Name |
Type |
Description |
eldata |
Object
|
ELDATAオブジェクト |
Returns:
スペース区切りの文字列
-
Type
-
string
(static) getSeparatedString_String(str) → {string}
- Description:
- 16進数文字列をECHONET Lite形式で区切られた文字列に変換
- Source:
Parameters:
| Name |
Type |
Description |
str |
string
|
16進数文字列 |
Throws:
-
文字列でない場合
-
-
Type
-
Error
Returns:
スペース区切りの文字列(EHD TID SEOJ DEOJ ESV ...)
-
Type
-
string
(static) increaseWaitings()
- Description:
- Source:
(static) initialize(objList, userfunc, ipVeropt, Optionsopt) → {Object}
- Description:
- ECHONET Lite通信の初期化とソケットのバインド
- Source:
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
objList |
Array.<string>
|
|
|
ECHONET Liteオブジェクトリスト(例: ['05ff01', '0ef001']) |
userfunc |
function
|
|
|
受信時のコールバック関数 (rinfo, els, error) => {} |
ipVer |
number
|
<optional>
|
4
|
IPバージョン (4: IPv4のみ, 6: IPv6のみ, 0: 両方) |
Options |
Object
|
<optional>
|
|
オプション設定
Properties
| Name |
Type |
Attributes |
Default |
Description |
v4 |
string
|
<optional>
|
''
|
IPv4インターフェースのIPアドレス |
v6 |
string
|
<optional>
|
''
|
IPv6インターフェース名またはアドレス |
ignoreMe |
boolean
|
<optional>
|
true
|
自IPからの送信データを無視するか |
autoGetProperties |
boolean
|
<optional>
|
true
|
プロパティの自動取得を行うか |
autoGetDelay |
number
|
<optional>
|
1000
|
自動取得時の遅延時間(ms) |
debugMode |
boolean
|
<optional>
|
false
|
デバッグモードの有効化 |
|
Returns:
作成されたソケット(ipVerに応じてsock4, sock6, または両方)
-
Type
-
Object
(static) myIPaddress(rinfo) → {boolean}
- Description:
- 受信したデータが自分のIPアドレスから送信されたものか判定
- Source:
Parameters:
| Name |
Type |
Description |
rinfo |
Object
|
受信情報 {address, family, port, size} |
Returns:
自IPアドレスの場合true
-
Type
-
boolean
(static) objectSort(obj) → {Object}
- Description:
- オブジェクトをキーでソート(JSON比較用)
オブジェクトの格納順序の違いによる比較エラーを防ぐ
- Source:
Parameters:
| Name |
Type |
Description |
obj |
Object
|
ソート対象のオブジェクト |
Returns:
キーでソート済みのオブジェクト
-
Type
-
Object
(static) parseBytes(bytes) → {Object|null}
- Description:
- バイト配列またはBufferをELDATA形式にパース
- Source:
Parameters:
| Name |
Type |
Description |
bytes |
Array.<number>
|
Buffer
|
string
|
バイト配列、Buffer、または16進数文字列 |
Returns:
パース済みELDATAオブジェクト、無効な場合はnull
-
Type
-
Object
|
null
(static) parseDetail(_opc, str) → {Object}
- Description:
- ECHONET Lite電文の詳細部分(EPC, PDC, EDT)をパース
- Source:
Parameters:
| Name |
Type |
Description |
_opc |
string
|
OPC(プロパティ数)の16進数文字列 |
str |
string
|
詳細部分の16進数文字列 |
Throws:
-
パースエラー時
-
-
Type
-
Error
Returns:
EPCをキーとしたEDTの連想配列 {epc: edt, ...}
-
Type
-
Object
- Description:
- プロパティマップ形式2をパース(形式1に変換)
プロパティ数が16以上の場合に使用される記述形式2を形式1に変換
- Source:
Parameters:
| Name |
Type |
Description |
bitstr |
string
|
Array.<number>
|
EDT部分(数値配列[0x01, 0x30]または16進数文字列"0130") |
Returns:
形式1のバイト配列(先頭バイトはプロパティ数)
-
Type
-
Array.<number>
(static) parseString(str) → {Object}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
str |
string
|
16進数文字列(例: '1081000101ef00110ef00162010a00') |
Throws:
-
不正な形式の場合
-
-
Type
-
Error
Returns:
パース済みELDATAオブジェクト {EHD, TID, SEOJ, DEOJ, EDATA, ESV, OPC, DETAIL, DETAILs}
-
Type
-
Object
(static) release()
- Description:
- ECHONET Liteのリソースを解放し、ソケットを閉じる
- Source:
(static) renewFacilities(address, els) → {void}
- Description:
- ネットワーク内の機器情報を更新(受信時に自動実行)
- Source:
Parameters:
| Name |
Type |
Description |
address |
string
|
機器のIPアドレス |
els |
ELData
|
パース済みELDATA |
Throws:
-
パースエラー時
-
-
Type
-
Error
Returns:
-
Type
-
void
(static) renewNICList() → {Object}
- Description:
- ネットワークインターフェースカード(NIC)のリストを更新
ループバックアドレスは無視される
- Source:
Returns:
NICリスト {v4: [{name, address}], v6: [{name, address}]}
-
Type
-
Object
(static) replyGetDetail_sub(els, dev_details, epc) → {boolean}
- Description:
- replyGetDetailのサブルーチン - 指定EPCが存在するか確認
- Source:
Parameters:
| Name |
Type |
Description |
els |
Object
|
パース済みELDATA |
dev_details |
Object
|
機器詳細情報 |
epc |
string
|
確認するプロパティコード |
Returns:
プロパティが存在する場合true
-
Type
-
boolean
(static) replyOPC1(ip, tid, seoj, deoj, esv, epc, edt) → {Array.<number>}
- Description:
- 受信した電文への返信(OPC=1)
受信したトランザクションIDを使用して返信
- Source:
Parameters:
| Name |
Type |
Description |
ip |
string
|
Object
|
返信先IPアドレス |
tid |
string
|
Array.<number>
|
トランザクションID(受信したものを使用) |
seoj |
string
|
Array.<number>
|
送信元ECHONET Liteオブジェクト |
deoj |
string
|
Array.<number>
|
送信先ECHONET Liteオブジェクト |
esv |
string
|
number
|
ECHONET Liteサービス |
epc |
string
|
number
|
ECHONET Liteプロパティコード |
edt |
string
|
number
|
Array.<number>
|
プロパティ値データ |
Returns:
トランザクションID
-
Type
-
Array.<number>
(static) replySetDetail(rinfo, els, dev_details)
- Description:
- SET要求に対する自動応答(複数プロパティ対応)
値の妥当性チェックとINF処理はreplySetDetail_subで実施
SET_RESの応答にはEDTが含まれない(仕様)
- Source:
Parameters:
| Name |
Type |
Description |
rinfo |
Object
|
受信情報 |
els |
Object
|
パース済みELDATA |
dev_details |
Object
|
機器詳細情報 |
(static) replySetDetail_sub(rinfo, els, dev_details, epc) → {boolean}
- Description:
- replySetDetailのサブルーチン - プロパティ設定の妥当性チェックとINF送信
機器種別とEPCに応じた個別処理を実施
- Source:
Parameters:
| Name |
Type |
Description |
rinfo |
Object
|
受信情報 |
els |
Object
|
パース済みELDATA |
dev_details |
Object
|
機器詳細情報 |
epc |
string
|
設定するプロパティコード |
Returns:
設定成功時true、失敗時false
-
Type
-
boolean
(static) returner(bytes, rinfo, userfunc) → {void}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
bytes |
Buffer
|
Array.<number>
|
受信したバイトデータ |
rinfo |
Rinfo
|
受信メタ情報 |
userfunc |
UserFunc
|
ユーザー定義コールバック(rinfo, els, error) |
Returns:
-
Type
-
void
(static) search() → {void}
- Description:
- ネットワーク内のECHONET Lite機器を検索
マルチキャストで機器情報を要求
- Source:
Returns:
-
Type
-
void
(static) sendArray(ip, array) → {Array.<number>}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
ip |
string
|
Object
|
送信先IPアドレス |
array |
Array.<number>
|
送信するバイト配列 |
Returns:
トランザクションID
-
Type
-
Array.<number>
(static) sendBase(ip, buffer) → {Array.<number>}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
ip |
string
|
Object
|
送信先IPアドレス(文字列)またはrinfoオブジェクト {address, family} |
buffer |
Buffer
|
送信するバッファ |
Returns:
使用したトランザクションID [tid[0], tid[1]]
-
Type
-
Array.<number>
(static) sendDetails(ip, seoj, deoj, esv, DETAILs) → {Array.<number>}
- Description:
- 複数プロパティを含むECHONET Lite電文を送信
トランザクションIDは自動インクリメント
- Source:
Parameters:
| Name |
Type |
Description |
ip |
string
|
Object
|
送信先IPアドレス |
seoj |
string
|
Array.<number>
|
送信元ECHONET Liteオブジェクト |
deoj |
string
|
Array.<number>
|
送信先ECHONET Liteオブジェクト |
esv |
string
|
number
|
ECHONET Liteサービス |
DETAILs |
Object
|
Array.<Object>
|
プロパティの詳細
- オブジェクト形式: {epc: edt, ...} 例: {'80':'31', '8a':'000077'}
- 配列形式: [{epc: edt}, ...] 順序が保証される |
Returns:
トランザクションID
-
Type
-
Array.<number>
(static) sendELDATA(ip, eldata) → {Array.<number>}
- Description:
- Source:
Example
EL.sendELDATA(ip, {
SEOJ: '0ef001',
DEOJ: '029001',
ESV: '61',
DETAILs: {'80':'31', '8a':'000077'}
})
Parameters:
| Name |
Type |
Description |
ip |
string
|
Object
|
送信先IPアドレス |
eldata |
Object
|
ELDATA形式のオブジェクト
Properties
| Name |
Type |
Attributes |
Description |
TID |
string
|
<optional>
|
トランザクションID(省略時は自動採番) |
SEOJ |
string
|
|
送信元ECHONET Liteオブジェクト(6桁) |
DEOJ |
string
|
|
送信先ECHONET Liteオブジェクト(6桁) |
ESV |
string
|
|
ECHONET Liteサービス(2桁) |
DETAILs |
Object
|
|
プロパティ詳細 {epc: edt, ...} |
|
Returns:
トランザクションID
-
Type
-
Array.<number>
(static) sendOPC1(ip, seoj, deoj, esv, epc, edt) → {Array.<number>}
- Description:
- OPC=1(プロパティ1個)のECHONET Lite電文を送信
トランザクションIDは自動インクリメント
- Source:
Parameters:
| Name |
Type |
Description |
ip |
string
|
Object
|
送信先IPアドレス |
seoj |
string
|
Array.<number>
|
送信元ECHONET Liteオブジェクト(6桁の16進数文字列または3バイト配列) |
deoj |
string
|
Array.<number>
|
送信先ECHONET Liteオブジェクト |
esv |
string
|
number
|
ECHONET Liteサービス(例: 0x62=GET, 0x61=SetC) |
epc |
string
|
number
|
ECHONET Liteプロパティコード |
edt |
string
|
number
|
Array.<number>
|
プロパティ値データ |
Returns:
トランザクションID
-
Type
-
Array.<number>
(static) sendString(ip, string) → {Array.<number>}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
ip |
string
|
Object
|
送信先IPアドレス |
string |
string
|
16進数文字列 |
Returns:
トランザクションID
-
Type
-
Array.<number>
(static) setObserveFacilities(interval, onChanged)
- Description:
- 機器情報の変化を監視し、変化時にコールバックを実行
- Source:
Parameters:
| Name |
Type |
Description |
interval |
number
|
監視間隔(ミリ秒) |
onChanged |
function
|
変化検出時のコールバック関数 |
(static) stringShow(str)
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
str |
string
|
16進数文字列(例: '1081000101...') |
(static) toHexArray(string) → {Array.<number>}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
string |
string
|
16進数文字列(例: 'ff0a30') |
Returns:
バイト配列
-
Type
-
Array.<number>
(static) toHexString(byte) → {string}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
byte |
number
|
バイト値(0-255) |
Returns:
2桁の16進数文字列(例: 'ff', '0a')
-
Type
-
string