inventoryd

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

README

inventoryd

ソラコム社のデバイス管理サービスSORACOM Inventoryにアクセスするためのツールです。SORACOM Inventoryの説明はこちら

https://soracom.jp/services/inventory/

出来るだけ簡単に使用できるようにするため、リソースは全てファイルとして扱います。以下の機能に対応しています。

  • SIM経由のブートストラップ
  • デバイスIDとデバイスシークレットを利用した接続
  • READ / WRITE / EXECUTE / OBSERVE オペレーションの対応
  • オブジェクト定義ファイルの認識とデフォルトリソースファイルの自動生成

取得方法

go getコマンドで取得できます。

go get github.com/1stship/inventoryd/cmd/inventoryd

使用方法

以下のコマンドを実行して、初期設定を実施します。

inventoryd --init

デフォルトではカレントディレクトリに設定ファイルと定義ファイルディレクトリ、リソースディレクトリを生成します。自動初期設定モードで初期設定すると、Object ID:0〜9までのインスタンス1つとそのリソースの一式が自動生成されます。

初期設定が終了したら、以下のいずれかで接続を開始します

  • SIM経由のブートストラップ(要SORACOM Air通信)
inventoryd -b
  • デバイスIDとデバイスシークレットを利用した接続(要デバイスID、シークレットキー)
inventoryd --identity <払い出されたデバイスID> --psk <払い出されたシークレットキー(base64)>

デバイスIDとシークレットキーについては、以下のページをご覧ください。

https://dev.soracom.io/jp/start/inventory_registration_with_keys/

接続が開始されると、SORACOM Consoleからリソースの操作ができます。

なお、2回目以降はブートストラップおよびデバイスクID、シークレットキーの指定は不要です。

リソースファイルについて

このツールではリソースは全てファイルとして扱っています。設定ファイルが配置された場所(デフォルトではカレントディレクトリ)にresourcesフォルダがあり、その中のファイルがリソースの実体です。

(例)ディレクトリを/home/1stshipとすると、/home/1stship/3/0/9はバッテリレベルを示すリソースのファイル

各オペレーションとは以下のように結びつけられています。

  • READ : 対象のリソースファイルを読み出す
  • WRITE : 対象のリソースファイルを更新する
  • EXECUTE : 対象のリソースファイル(実行可能ファイル)を実行する
  • OBSERVE : 対象のリソースファイルを定期的(デフォルト5秒ごと)に読み出し、更新があれば通知する

インスタンスに対するREADやOBSERVEは、配下のリソース全てを読み出します。従って、対象のリソースファイルを参照/更新することでデバイス管理ができます。

実行可能リソースについて

実行可能なリソースファイルはEXECUTEにて実行することが出来ます。サービスからの入力は標準入力から入ります。

基本的には実行はEXECUTEですが、動的に値を読み出したい場合、READを何らかの実行ファイルと結びつけたい場合があります。たとえば、/3/0/13のCurrent Timeは現在の時間を出力するプログラムとしたいなどの場合、/3/0/13.readという名前で実行可能なファイルを配置することで対応可能です。

たとえば、/3/0/13.readを実行可能な以下のbashスクリプトとすると、/3/0/13へのアクセスが現在時間を返すようになります。

#/bin/bash
date +%s

同様にリソースファイル.writeという名前で実行可能ファイルを配置すると、WRITE動作も実行させることが出来ます。

追加オブジェクトの対応について

設定ファイルが配置されたディレクトリ以下にあるmodelsフォルダにLWM2Mのオブジェクト定義ファイルを配置すると、起動時に認識します。

新しい定義ファイルが入った状態で再度初期化(inventoryd --init)を実行することで、追加モデルのデフォルトリソースを生成できます。(既存のリソースは影響しません)

OMAに規定されていないモデルについては、以下のURLを参考に、SORACOM コンソールにてカスタムオブジェクトをご登録ください。

https://dev.soracom.io/jp/start/inventory_custom_object/

Documentation

Index

Constants

View Source
const (
	CoapTypeConfirmable     = 0
	CoapTypeNonConfirmable  = 1
	CoapTypeAcknowledgement = 2
	CoapTypeReset           = 3
)

Coap Type RFC7252 3. Message Format Type(T)参照

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func CreateDefaultConfig

func CreateDefaultConfig(configPath string) error

CreateDefaultConfig : デフォルトの設定ファイルを生成する

func DtlsClientRandom

func DtlsClientRandom() []byte

DtlsClientRandom : ClientRandomを生成する 先頭4byteをUNIX timestamp そのあとの28byteをランダムのbyteとする RFC5246 7.4.1.2 ClientHello参照

func DtlsPreMasterSecretFromPSK

func DtlsPreMasterSecretFromPSK(psk []byte) []byte

DtlsPreMasterSecretFromPSK : PSKからPreMasterSecretを生成する 生成方法 : PSKのバイト長をNとすると、uint16(N) || 0をNバイト || uint16(N) || PSK RFC4279 2. PSK Key Exchange Algorithmの以下の記述より The premaster secret is formed as follows: if the PSK is N octets long, concatenate a uint16 with the value N, N zero octets, a second uint16 with the value N, and the PSK itself.

func LoadLwm2mDefinitions

func LoadLwm2mDefinitions(modelsPath string) (lwm2mObjectDefinitions, error)

LoadLwm2mDefinitions : 定義ファイルから定義構造体を生成する

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func SaveConfig

func SaveConfig(configPath string, config *Config) error

func SetSecurityParams

func SetSecurityParams(config *Config, handler Lwm2mHandler, identity string, pskOpaque string) error

SetSecurityParams : コマンドラインで指定されたデバイスID、PSKを設定する 既存のデバイスID、PSKは削除する

Types

type Coap

type Coap struct {
	Connection    net.Conn // 接続
	NextMessageID uint16
	ChInProcess   map[uint16]chan int
	RecvHandler   func(*CoapMessage)
	// contains filtered or unexported fields
}

Coap : Coap接続に関わるパラメータ

func (*Coap) Close

func (coap *Coap) Close()

Close : Coap接続を閉じる メッセージ受信に関わるgorutineを止める

func (*Coap) Initialize

func (coap *Coap) Initialize(conn net.Conn, recvHandler func(*CoapMessage))

Initialize : Coap構造体を初期化する

func (*Coap) ParseMessage

func (coap *Coap) ParseMessage(raw []byte) *CoapMessage

ParseMessage : 受信生データを解析してCoapMessageを生成する 生成できない場合はnilを返す

func (*Coap) ReadCoapMessage

func (coap *Coap) ReadCoapMessage(stopCh chan bool)

ReadCoapMessage : メッセージを受信する stopChを受信すると受信動作を停止する

func (*Coap) SendRelatedMessage

func (coap *Coap) SendRelatedMessage(code CoapCode, token []byte, options []CoapOption, payload []byte) uint16

SendRelatedMessage : 関連メッセージ(新規メッセージだがトークンが同じ)を送信する Lwm2m Notifyメッセージで使用する メッセージIDを返す

func (*Coap) SendRequest

func (coap *Coap) SendRequest(code CoapCode, options []CoapOption, payload []byte, ch chan int) uint16

SendRequest : リクエスト(CON)を送信する ACKが返ってきたらチャネルに1を送る メッセージIDを返す

func (*Coap) SendResponse

func (coap *Coap) SendResponse(request *CoapMessage, code CoapCode, options []CoapOption, payload []byte)

SendResponse : レスポンス(ACK)を送信する

type CoapCode

type CoapCode byte
const (
	CoapCodeGet    CoapCode = 1
	CoapCodePost   CoapCode = 2
	CoapCodePut    CoapCode = 3
	CoapCodeDelete CoapCode = 4
)

Coap Method Code RFC7252 12.1.1 Method Codes参照

const (
	CoapCodeEmpty      CoapCode = 0   // 0.00 Empty
	CoapCodeCreated    CoapCode = 65  // 2.01 Created
	CoapCodeDeleted    CoapCode = 66  // 2.02 Deleted
	CoapCodeChanged    CoapCode = 68  // 2.04 Changed
	CoapCodeContent    CoapCode = 69  // 2.05 Content
	CoapCodeBadRequest CoapCode = 128 // 4.00 Bad Request
	CoapCodeNotFound   CoapCode = 132 // 4.04 Not Found
	CoapCodeNotAllowed CoapCode = 133 // 4.05 Method Not Allowed
)

Coap Response Code RFC7252 12.1.2 Response Codes参照

type CoapMessage

type CoapMessage struct {
	Version     byte
	Type        byte
	TokenLength byte
	Code        CoapCode
	MessageID   uint16
	Token       []byte
	Options     []CoapOption
	Payload     []byte
}

CoapMessage : Coapのメッセージ RFC7252 3. Message Format参照

func (*CoapMessage) BuildOptions

func (message *CoapMessage) BuildOptions() []byte

BuildOptions : Coapのオプション部を生成する

func (*CoapMessage) ConvertToBytes

func (message *CoapMessage) ConvertToBytes() []byte

ConvertToBytes : Messageを[]byteに変換する

func (*CoapMessage) IsObserve

func (message *CoapMessage) IsObserve() bool

IsObserve : Observeメッセージかを判定する

func (*CoapMessage) ParseOptions

func (message *CoapMessage) ParseOptions(raw []byte) int

ParseOptions : 生データのオプション部以降を解析しオプションをセットする 戻り値:オプション部の長さ

type CoapOption

type CoapOption struct {
	No    uint
	Value []byte
}

CoapOption : Coapのオプション RFC7252 5.10参照

func (*CoapOption) BuildOption

func (option *CoapOption) BuildOption(base uint) []byte

BuildOption : Coapの各オプション部を生成する RFC7252 3.1 Option Format参照

func (*CoapOption) ParseOption

func (option *CoapOption) ParseOption(raw []byte, base uint) int

ParseOption : 生データの各オプションをセットする 戻り値:オプションの長さ

type Config

type Config struct {
	RootPath           string `json:"rootPath"`
	ObserveInterval    int    `json:"observeInterval"`
	BootstrapServer    string `json:"bootstrapServer"`
	EndpointClientName string `json:"endpointClientName"`
}

Config : inventorydの設定

func LoadInventorydConfig

func LoadInventorydConfig(configPath string) (*Config, error)

LoadInventorydConfig : 設定ファイルから設定を読み出す

type Dtls

type Dtls struct {
	Connection     net.Conn // 接続
	ServerEpoch    uint16
	ClientEpoch    uint16
	ServerSequence uint64
	ClientSequence uint64
	ServerWriteKey []byte
	ClientWriteKey []byte
	ServerIV       []byte
	ClientIV       []byte
	ClientEncrypt  bool
	ServerEncrypt  bool
	Handshake      *DtlsHandshakeParams
}

Dtls : Dtls接続管理

func DtlsDial

func DtlsDial(host string, identity []byte, psk []byte) (*Dtls, error)

DtlsDial : DLTSの初期化

func (*Dtls) Close

func (dtls *Dtls) Close() error

Close : 接続を閉じる

func (*Dtls) GenerateSecurityParams

func (dtls *Dtls) GenerateSecurityParams()

GenerateSecurityParams : Master Secret / KeyBlockを生成する

func (*Dtls) GetCookie

func (dtls *Dtls) GetCookie() error

GetCookie : stateless cookieを取得する RFC6347 4.2.1 Denial-of-Service Contermeasures参照 Cookie 取得までのHandshakeはFinishedの際のVerify Data算出には含めない If HelloVerifyRequest is used, the initial ClientHello and HelloVerifyRequest are not included in the calculation of the handshake_messages (for the CertificateVerify message) and verify_data (for the Finished message).

func (*Dtls) GetSession

func (dtls *Dtls) GetSession() error

GetSession : Session IDを取得する

func (*Dtls) LocalAddr

func (dtls *Dtls) LocalAddr() net.Addr

LocalAddr : 接続元アドレス

func (*Dtls) ParsePacket

func (dtls *Dtls) ParsePacket(raw []byte) *DtlsPacket

ParsePacket : パケット生データからDTLSパケットを生成する

func (*Dtls) Read

func (dtls *Dtls) Read(data []byte) (int, error)

func (*Dtls) RemoteAddr

func (dtls *Dtls) RemoteAddr() net.Addr

RemoteAddr : 接続元先アドレス

func (*Dtls) SendChangeCipherSpec

func (dtls *Dtls) SendChangeCipherSpec() error

SendChangeCipherSpec : Change Cipher Specを送信する Change Cipher Specの際にEpochを加算し、Sequenceはクリアする The epoch number is initially zero and is incremented each time a ChangeCipherSpec message is sent. Sequence numbers are maintained separately for each epoch, with each sequence_number initially being 0 for each epoch. 詳細はRFC6347 4.1 Record Layer参照 なお、Change Cipher SpecはHandshakeではないため、Finishedの際のVerify Dataの算出には含めない

func (*Dtls) SendClientKeyExchange

func (dtls *Dtls) SendClientKeyExchange() error

SendClientKeyExchange : Client Key Exchangeを送信する

func (*Dtls) SendFinished

func (dtls *Dtls) SendFinished() error

SendFinished : Finishedを送信する

func (*Dtls) SetDeadline

func (dtls *Dtls) SetDeadline(t time.Time) error

SetDeadline : デッドラインの設定

func (*Dtls) SetReadDeadline

func (dtls *Dtls) SetReadDeadline(t time.Time) error

SetReadDeadline : 読み出しデッドラインの設定

func (*Dtls) SetWriteDeadline

func (dtls *Dtls) SetWriteDeadline(t time.Time) error

SetWriteDeadline : 書き込みデッドラインの設定

func (*Dtls) Write

func (dtls *Dtls) Write(data []byte) (int, error)

type DtlsHandshake

type DtlsHandshake struct {
	Type     byte
	Sequence uint16
	Params   *DtlsHandshakeParams
}

DtlsHandshake : Dtlsのハンドシェイク

func (*DtlsHandshake) Parse

func (handshake *DtlsHandshake) Parse(raw []byte)

Parse : 生データのハンドシェイク部を解析する

func (*DtlsHandshake) ToBytes

func (handshake *DtlsHandshake) ToBytes() []byte

ToBytes : DTLSのハンドシェイクをバイトスライスに変換する

type DtlsHandshakeParams

type DtlsHandshakeParams struct {
	ServerSequence  uint16
	ClientSequence  uint16
	Identity        []byte
	Cookie          []byte
	Session         []byte
	ClientRandom    []byte
	ServerRandom    []byte
	PreMasterSecret []byte
	MasterSecret    []byte
	Messages        []byte
	Verified        bool
}

DtlsHandshakeParams : Dtlsのハンドシェイクパラメータ

func (*DtlsHandshakeParams) GenerateClientVerifyData

func (handshake *DtlsHandshakeParams) GenerateClientVerifyData() []byte

GenerateClientVerifyData : ClientからのFinishedのVerify Dataを生成する

func (*DtlsHandshakeParams) GenerateServerVerifyData

func (handshake *DtlsHandshakeParams) GenerateServerVerifyData() []byte

GenerateServerVerifyData : ServerからのFinishedのVerify Dataを生成する

type DtlsPacket

type DtlsPacket struct {
	Type          byte
	Epoch         uint16
	Sequence      uint64
	ContentLength uint16
	Content       []byte
}

DtlsPacket : DTLSのパケット

func (*DtlsPacket) Length

func (packet *DtlsPacket) Length() uint16

Length : DTLSパケット全体の長さ

func (*DtlsPacket) ToBytes

func (packet *DtlsPacket) ToBytes() []byte

ToBytes : DTLSのパケットをバイトスライスに変換する

type HandlerFile

type HandlerFile struct {
	ResourceDirPath string
}

HandlerFile : ファイルベースのハンドラ

func (*HandlerFile) CreateInstance

func (handler *HandlerFile) CreateInstance(instance *Lwm2mInstance) CoapCode

CreateInstance : 空インスタンスを生成する 親オブジェクトが存在しない場合は生成する

func (*HandlerFile) DeleteObject

func (handler *HandlerFile) DeleteObject(object *Lwm2mObject) CoapCode

DeleteObject : オブジェクトを削除する

func (*HandlerFile) ExecuteResource

func (handler *HandlerFile) ExecuteResource(resource *Lwm2mResource, value string) CoapCode

ExecuteResource : Resourceに対するExecute ResourceにExecuteする 実行可能形式ではないファイル(シェルスクリプトなど)は直接実行できないため、 シェル経由でコマンドを実行する UNIX (Like) OSでの実行は要検討

func (*HandlerFile) ListInstanceIDs

func (handler *HandlerFile) ListInstanceIDs(object *Lwm2mObject) ([]uint16, CoapCode)

ListInstanceIDs : オブジェクト下にあるインスタンスIDを取得する

func (*HandlerFile) ListObjectIDs

func (handler *HandlerFile) ListObjectIDs() ([]uint16, CoapCode)

ListObjectIDs : 利用可能なオブジェクトIDを取得する

func (*HandlerFile) ListResourceIDs

func (handler *HandlerFile) ListResourceIDs(instance *Lwm2mInstance) ([]uint16, CoapCode)

ListResourceIDs : インスタンス下にあるリソースIDを取得する

func (*HandlerFile) ReadResource

func (handler *HandlerFile) ReadResource(resource *Lwm2mResource) (string, CoapCode)

ReadResource : Resourceに対するRead ResourceをReadした結果を返す リソースIDに拡張子.readが付いたファイルが存在し、かつ実行可能であれば、 通常のリソースに優先して実行し、結果を返す

func (*HandlerFile) WriteResource

func (handler *HandlerFile) WriteResource(resource *Lwm2mResource, value string) CoapCode

WriteResource : Resourceに対するWrite ResourceにWriteする リソースIDに拡張子.writeが付いたファイルが存在し、かつ実行可能であれば、 通常のリソースに優先して実行する サーバからの入力値は標準入力に渡す

type Inventoryd

type Inventoryd struct {
	Lwm2m  *Lwm2m
	Config *Config
}

Inventoryd : SORACOM Inventory対応

func (*Inventoryd) Bootstrap

func (daemon *Inventoryd) Bootstrap(config *Config, handler Lwm2mHandler) error

Bootstrap : ブートストラップを実行する

func (*Inventoryd) Initialize

func (daemon *Inventoryd) Initialize(config *Config, handler Lwm2mHandler) error

Initialize : Inventorydの初期化

func (*Inventoryd) Prepare

func (daemon *Inventoryd) Prepare(config *Config) error

Prepare : 使用前準備

func (*Inventoryd) Run

func (daemon *Inventoryd) Run() error

Run : 動作を開始する

type Lwm2m

type Lwm2m struct {
	Connection *Coap
	Location   string
	// contains filtered or unexported fields
}

Lwm2m : Lwm2m対応

func (*Lwm2m) CheckSecurityParams

func (lwm2m *Lwm2m) CheckSecurityParams() error

func (*Lwm2m) ExecuteRequest

func (lwm2m *Lwm2m) ExecuteRequest(message *CoapMessage) error

ExecuteRequest : Executeを処理する

func (*Lwm2m) Initialize

func (lwm2m *Lwm2m) Initialize(
	endpointClientName string,
	definitions lwm2mObjectDefinitions,
	handler Lwm2mHandler) error

Initialize : Lwm2m構造体を初期化する

func (*Lwm2m) NotifyInstance

func (lwm2m *Lwm2m) NotifyInstance(observe *Lwm2mObservedInstance)

NotifyInstance : インスタンスに対するNotifyを実行する OMA-TS-LightweightM2M-V1_0_2-20180209-A 5.5.2 Notify参照

func (*Lwm2m) NotifyResource

func (lwm2m *Lwm2m) NotifyResource(observe *Lwm2mObservedResource)

NotifyResource : リソースに対するNotifyを実行する OMA-TS-LightweightM2M-V1_0_2-20180209-A 5.5.2 Notify参照

func (*Lwm2m) Observe

func (lwm2m *Lwm2m) Observe()

Observe : Observe中リソースのチェックおよび変化があった場合のNotifyを実行する OMA-TS-LightweightM2M-V1_0_2-20180209-A 5.5.1 Observe参照 オブジェクトレベルのObserveも可能だが、現時点では対応しない 接続がない場合、Registerが終了していない場合は何もしない

func (*Lwm2m) ObserveDeregister

func (lwm2m *Lwm2m) ObserveDeregister(message *CoapMessage)

ObserveDeregister : Coap Resetを受信したらObserveを解除する OMA-TS-LightweightM2M-V1_0_2-20180209-A 8.2.6 Information Reporting Interface参照 ResetはMessageIDのみ存在するため、メッセージIDとつきあわせて確認する

func (*Lwm2m) ReadRequest

func (lwm2m *Lwm2m) ReadRequest(message *CoapMessage) error

ReadRequest : Readを処理する

func (*Lwm2m) ReceiveMessage

func (lwm2m *Lwm2m) ReceiveMessage(message *CoapMessage)

ReceiveMessage : メッセージ受信ハンドラ

func (*Lwm2m) Register

func (lwm2m *Lwm2m) Register() error

Register : Register Operation OMA-TS-LightweightM2M-V1_0_2-20180209-A 5.3.1 Register参照

func (*Lwm2m) RegisterDone

func (lwm2m *Lwm2m) RegisterDone(message *CoapMessage)

RegisterDone : Register 終了メッセージの処理

func (*Lwm2m) StartObserving

func (lwm2m *Lwm2m) StartObserving(interval time.Duration, stopCh chan bool)

StartObserving : Observe動作を開始する stopChを受信したら停止する

func (*Lwm2m) StartUpdate

func (lwm2m *Lwm2m) StartUpdate(interval time.Duration, stopCh chan bool)

StartUpdate : Update動作を開始する stopChを受信したら停止する

func (*Lwm2m) Update

func (lwm2m *Lwm2m) Update() error

Update : Update Operation OMA-TS-LightweightM2M-V1_0_2-20180209-A 5.3.2 Update参照

func (*Lwm2m) UpdateDone

func (lwm2m *Lwm2m) UpdateDone(message *CoapMessage)

UpdateDone : Update 終了メッセージの処理

func (*Lwm2m) WriteRequest

func (lwm2m *Lwm2m) WriteRequest(message *CoapMessage) error

WriteRequest : Writeを処理する

type Lwm2mDefinitionXML

type Lwm2mDefinitionXML struct {
	XMLName xml.Name                  `xml:"LWM2M"`
	Object  *Lwm2mObjectDefinitionXML `xml:"Object"`
}

Lwm2mDefinitionXML : Lwm2mのオブジェクト定義のXML

type Lwm2mHandler

type Lwm2mHandler interface {

	// 通常CoapCodeDeleteを返す
	DeleteObject(object *Lwm2mObject) CoapCode

	// 通常CoapCodeCreatedを返す
	CreateInstance(instance *Lwm2mInstance) CoapCode

	// 通常CoapCodeContentを返す
	ListObjectIDs() ([]uint16, CoapCode)

	// 通常CoapCodeContentを返す
	ListInstanceIDs(object *Lwm2mObject) ([]uint16, CoapCode)

	// 通常CoapCodeContentを返す
	ListResourceIDs(instance *Lwm2mInstance) ([]uint16, CoapCode)

	// 通常CoapCodeContentを返す
	ReadResource(resource *Lwm2mResource) (string, CoapCode)

	// 通常CoapCodeChangedを返す
	WriteResource(resource *Lwm2mResource, value string) CoapCode

	// 通常CoapCodeChangedを返す
	ExecuteResource(resource *Lwm2mResource, value string) CoapCode
}

Lwm2mHandler : Lwm2mの各種Operationの処理ハンドラ OMA-TS-LightweightM2M-V1_0_2-20180209-A Read : 5.4.1 Read参照(Objectに対するReadはInventoryのAPIに無いため対象外) Write : 5.4.3 Write参照 Execute : 5.4.5 Execute参照 Discover / Write-Attributes は対象外 Create / DeleteはBootstrapにて限定的に対応

type Lwm2mInstance

type Lwm2mInstance struct {
	ID uint16
	// contains filtered or unexported fields
}

Lwm2mInstance : LWm2mのインスタンス

type Lwm2mObject

type Lwm2mObject struct {
	ID         uint16
	Definition *Lwm2mObjectDefinition
}

Lwm2mObject : Lwm2mのオブジェクト

type Lwm2mObjectDefinition

type Lwm2mObjectDefinition struct {
	ID        uint16
	Name      string
	Multi     bool
	Mandatory bool
	Resources []*Lwm2mResourceDefinition
}

Lwm2mObjectDefinition : Lwm2mのオブジェクト定義

type Lwm2mObjectDefinitionXML

type Lwm2mObjectDefinitionXML struct {
	Name      string                        `xml:"Name"`
	ID        string                        `xml:"ObjectID"`
	Multi     string                        `xml:"MultipleInstances"`
	Mandatory string                        `xml:"Mandatory"`
	Resources []*Lwm2mResourceDefinitionXML `xml:"Resources>Item"`
}

Lwm2mObjectDefinitionXML : Lwm2mのオブジェクト定義のXMLのオブジェクト部

type Lwm2mObservedInstance

type Lwm2mObservedInstance struct {
	// contains filtered or unexported fields
}

Lwm2mObservedInstance : Lwm2mのObserve中のインスタンス ObserveはNotifyの際にObserve時と同じTokenを使用する必要がある OMA-TS-LightweightM2M-V1_0_2-20180209-A 8.2.6 Information Reporting Interface参照

type Lwm2mObservedResource

type Lwm2mObservedResource struct {
	// contains filtered or unexported fields
}

Lwm2mObservedResource : Lwm2mのObserve中のリソース ObserveはNotifyの際にObserve時と同じTokenを使用する必要がある OMA-TS-LightweightM2M-V1_0_2-20180209-A 8.2.6 Information Reporting Interface参照

type Lwm2mResource

type Lwm2mResource struct {
	ID uint16

	Definition *Lwm2mResourceDefinition
	// contains filtered or unexported fields
}

Lwm2mResource : Lwm2mのリソース

type Lwm2mResourceDefinition

type Lwm2mResourceDefinition struct {
	ID        uint16
	Name      string
	Multi     bool
	Mandatory bool
	Readable  bool
	Writable  bool
	Excutable bool
	Type      byte
}

Lwm2mResourceDefinition : Lwm2mのリソース定義

type Lwm2mResourceDefinitionXML

type Lwm2mResourceDefinitionXML struct {
	ID         string `xml:"ID,attr"`
	Name       string `xml:"Name"`
	Operations string `xml:"Operations"`
	Multi      string `xml:"MultipleInstances"`
	Mandatory  string `xml:"Mandatory"`
	Type       string `xml:"Type"`
}

Lwm2mResourceDefinitionXML : Lwm2mのオブジェクト定義のXMLのリソース部

type Lwm2mTLV

type Lwm2mTLV struct {
	TypeOfID byte
	ID       uint16
	Length   uint32
	Value    []byte
	Contents []*Lwm2mTLV
}

Lwm2mTLV : データ形式TLV OMA-TS-LightweightM2M-V1_0_2-20180209-A 6.4.3 TLV参照

func (*Lwm2mTLV) Marshal

func (tlv *Lwm2mTLV) Marshal() []byte

Marshal : TLVデータをバイト配列に変換

func (*Lwm2mTLV) TotalLength

func (tlv *Lwm2mTLV) TotalLength() int

TotalLength : TLVデータの長さを取得する

func (*Lwm2mTLV) Unmarshal

func (tlv *Lwm2mTLV) Unmarshal(raw []byte) int

Unmarshal : バイト配列からTLVデータを取得する 取得出来た場合はtlvデータ長を返す 取得できなかった場合は-1を返す

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL