Versions in this module Expand all Collapse all v0 v0.0.1 May 4, 2019 Changes in this version + const CoapTypeAcknowledgement + const CoapTypeConfirmable + const CoapTypeNonConfirmable + const CoapTypeReset + func Asset(name string) ([]byte, error) + func AssetDir(name string) ([]string, error) + func AssetInfo(name string) (os.FileInfo, error) + func AssetNames() []string + func CreateDefaultConfig(configPath string) error + func DtlsClientRandom() []byte + func DtlsPreMasterSecretFromPSK(psk []byte) []byte + func LoadLwm2mDefinitions(modelsPath string) (lwm2mObjectDefinitions, error) + func MustAsset(name string) []byte + func RestoreAsset(dir, name string) error + func RestoreAssets(dir, name string) error + func SaveConfig(configPath string, config *Config) error + func SetSecurityParams(config *Config, handler Lwm2mHandler, identity string, pskOpaque string) error + type Coap struct + ChInProcess map[uint16]chan int + Connection net.Conn + NextMessageID uint16 + RecvHandler func(*CoapMessage) + func (coap *Coap) Close() + func (coap *Coap) Initialize(conn net.Conn, recvHandler func(*CoapMessage)) + func (coap *Coap) ParseMessage(raw []byte) *CoapMessage + func (coap *Coap) ReadCoapMessage(stopCh chan bool) + func (coap *Coap) SendRelatedMessage(code CoapCode, token []byte, options []CoapOption, payload []byte) uint16 + func (coap *Coap) SendRequest(code CoapCode, options []CoapOption, payload []byte, ch chan int) uint16 + func (coap *Coap) SendResponse(request *CoapMessage, code CoapCode, options []CoapOption, payload []byte) + type CoapCode byte + const CoapCodeBadRequest + const CoapCodeChanged + const CoapCodeContent + const CoapCodeCreated + const CoapCodeDelete + const CoapCodeDeleted + const CoapCodeEmpty + const CoapCodeGet + const CoapCodeNotAllowed + const CoapCodeNotFound + const CoapCodePost + const CoapCodePut + type CoapMessage struct + Code CoapCode + MessageID uint16 + Options []CoapOption + Payload []byte + Token []byte + TokenLength byte + Type byte + Version byte + func (message *CoapMessage) BuildOptions() []byte + func (message *CoapMessage) ConvertToBytes() []byte + func (message *CoapMessage) IsObserve() bool + func (message *CoapMessage) ParseOptions(raw []byte) int + type CoapOption struct + No uint + Value []byte + func (option *CoapOption) BuildOption(base uint) []byte + func (option *CoapOption) ParseOption(raw []byte, base uint) int + type Config struct + BootstrapServer string + EndpointClientName string + ObserveInterval int + RootPath string + func LoadInventorydConfig(configPath string) (*Config, error) + type Dtls struct + ClientEncrypt bool + ClientEpoch uint16 + ClientIV []byte + ClientSequence uint64 + ClientWriteKey []byte + Connection net.Conn + Handshake *DtlsHandshakeParams + ServerEncrypt bool + ServerEpoch uint16 + ServerIV []byte + ServerSequence uint64 + ServerWriteKey []byte + func DtlsDial(host string, identity []byte, psk []byte) (*Dtls, error) + func (dtls *Dtls) Close() error + func (dtls *Dtls) GenerateSecurityParams() + func (dtls *Dtls) GetCookie() error + func (dtls *Dtls) GetSession() error + func (dtls *Dtls) LocalAddr() net.Addr + func (dtls *Dtls) ParsePacket(raw []byte) *DtlsPacket + func (dtls *Dtls) Read(data []byte) (int, error) + func (dtls *Dtls) RemoteAddr() net.Addr + func (dtls *Dtls) SendChangeCipherSpec() error + func (dtls *Dtls) SendClientKeyExchange() error + func (dtls *Dtls) SendFinished() error + func (dtls *Dtls) SetDeadline(t time.Time) error + func (dtls *Dtls) SetReadDeadline(t time.Time) error + func (dtls *Dtls) SetWriteDeadline(t time.Time) error + func (dtls *Dtls) Write(data []byte) (int, error) + type DtlsHandshake struct + Params *DtlsHandshakeParams + Sequence uint16 + Type byte + func (handshake *DtlsHandshake) Parse(raw []byte) + func (handshake *DtlsHandshake) ToBytes() []byte + type DtlsHandshakeParams struct + ClientRandom []byte + ClientSequence uint16 + Cookie []byte + Identity []byte + MasterSecret []byte + Messages []byte + PreMasterSecret []byte + ServerRandom []byte + ServerSequence uint16 + Session []byte + Verified bool + func (handshake *DtlsHandshakeParams) GenerateClientVerifyData() []byte + func (handshake *DtlsHandshakeParams) GenerateServerVerifyData() []byte + type DtlsPacket struct + Content []byte + ContentLength uint16 + Epoch uint16 + Sequence uint64 + Type byte + func (packet *DtlsPacket) Length() uint16 + func (packet *DtlsPacket) ToBytes() []byte + type HandlerFile struct + ResourceDirPath string + func (handler *HandlerFile) CreateInstance(instance *Lwm2mInstance) CoapCode + func (handler *HandlerFile) DeleteObject(object *Lwm2mObject) CoapCode + func (handler *HandlerFile) ExecuteResource(resource *Lwm2mResource, value string) CoapCode + func (handler *HandlerFile) ListInstanceIDs(object *Lwm2mObject) ([]uint16, CoapCode) + func (handler *HandlerFile) ListObjectIDs() ([]uint16, CoapCode) + func (handler *HandlerFile) ListResourceIDs(instance *Lwm2mInstance) ([]uint16, CoapCode) + func (handler *HandlerFile) ReadResource(resource *Lwm2mResource) (string, CoapCode) + func (handler *HandlerFile) WriteResource(resource *Lwm2mResource, value string) CoapCode + type Inventoryd struct + Config *Config + Lwm2m *Lwm2m + func (daemon *Inventoryd) Bootstrap(config *Config, handler Lwm2mHandler) error + func (daemon *Inventoryd) Initialize(config *Config, handler Lwm2mHandler) error + func (daemon *Inventoryd) Prepare(config *Config) error + func (daemon *Inventoryd) Run() error + type Lwm2m struct + Connection *Coap + Location string + func (lwm2m *Lwm2m) CheckSecurityParams() error + func (lwm2m *Lwm2m) ExecuteRequest(message *CoapMessage) error + func (lwm2m *Lwm2m) Initialize(endpointClientName string, definitions lwm2mObjectDefinitions, ...) error + func (lwm2m *Lwm2m) NotifyInstance(observe *Lwm2mObservedInstance) + func (lwm2m *Lwm2m) NotifyResource(observe *Lwm2mObservedResource) + func (lwm2m *Lwm2m) Observe() + func (lwm2m *Lwm2m) ObserveDeregister(message *CoapMessage) + func (lwm2m *Lwm2m) ReadRequest(message *CoapMessage) error + func (lwm2m *Lwm2m) ReceiveMessage(message *CoapMessage) + func (lwm2m *Lwm2m) Register() error + func (lwm2m *Lwm2m) RegisterDone(message *CoapMessage) + func (lwm2m *Lwm2m) StartObserving(interval time.Duration, stopCh chan bool) + func (lwm2m *Lwm2m) StartUpdate(interval time.Duration, stopCh chan bool) + func (lwm2m *Lwm2m) Update() error + func (lwm2m *Lwm2m) UpdateDone(message *CoapMessage) + func (lwm2m *Lwm2m) WriteRequest(message *CoapMessage) error + type Lwm2mDefinitionXML struct + Object *Lwm2mObjectDefinitionXML + XMLName xml.Name + type Lwm2mHandler interface + CreateInstance func(instance *Lwm2mInstance) CoapCode + DeleteObject func(object *Lwm2mObject) CoapCode + ExecuteResource func(resource *Lwm2mResource, value string) CoapCode + ListInstanceIDs func(object *Lwm2mObject) ([]uint16, CoapCode) + ListObjectIDs func() ([]uint16, CoapCode) + ListResourceIDs func(instance *Lwm2mInstance) ([]uint16, CoapCode) + ReadResource func(resource *Lwm2mResource) (string, CoapCode) + WriteResource func(resource *Lwm2mResource, value string) CoapCode + type Lwm2mInstance struct + ID uint16 + type Lwm2mObject struct + Definition *Lwm2mObjectDefinition + ID uint16 + type Lwm2mObjectDefinition struct + ID uint16 + Mandatory bool + Multi bool + Name string + Resources []*Lwm2mResourceDefinition + type Lwm2mObjectDefinitionXML struct + ID string + Mandatory string + Multi string + Name string + Resources []*Lwm2mResourceDefinitionXML + type Lwm2mObservedInstance struct + type Lwm2mObservedResource struct + type Lwm2mResource struct + Definition *Lwm2mResourceDefinition + ID uint16 + type Lwm2mResourceDefinition struct + Excutable bool + ID uint16 + Mandatory bool + Multi bool + Name string + Readable bool + Type byte + Writable bool + type Lwm2mResourceDefinitionXML struct + ID string + Mandatory string + Multi string + Name string + Operations string + Type string + type Lwm2mTLV struct + Contents []*Lwm2mTLV + ID uint16 + Length uint32 + TypeOfID byte + Value []byte + func (tlv *Lwm2mTLV) Marshal() []byte + func (tlv *Lwm2mTLV) TotalLength() int + func (tlv *Lwm2mTLV) Unmarshal(raw []byte) int