• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang lorawan.EUI64类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/brocaar/lorawan.EUI64的典型用法代码示例。如果您正苦于以下问题:Golang EUI64类的具体用法?Golang EUI64怎么用?Golang EUI64使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了EUI64类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: FlushTXPayloadQueue

// FlushTXPayloadQueue flushes the tx payload queue for the given DevEUI.
func (a *NodeAPI) FlushTXPayloadQueue(ctx context.Context, req *pb.FlushTXPayloadQueueRequest) (*pb.FlushTXPayloadQueueResponse, error) {
	var eui lorawan.EUI64
	if err := eui.UnmarshalText([]byte(req.DevEUI)); err != nil {
		return nil, err
	}
	if err := storage.FlushTXPayloadQueue(a.ctx.RedisPool, eui); err != nil {
		return nil, err
	}
	return &pb.FlushTXPayloadQueueResponse{}, nil
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:11,代码来源:node.go


示例2: Update

// Update updates the given Application.
func (a *ApplicationAPI) Update(ctx context.Context, req *pb.UpdateApplicationRequest) (*pb.UpdateApplicationResponse, error) {
	var eui lorawan.EUI64
	if err := eui.UnmarshalText([]byte(req.AppEUI)); err != nil {
		return nil, err
	}

	if err := storage.UpdateApplication(a.ctx.DB, models.Application{AppEUI: eui, Name: req.Name}); err != nil {
		return nil, err
	}

	return &pb.UpdateApplicationResponse{}, nil
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:13,代码来源:application.go


示例3: Delete

// Delete deletes the application for the given AppEUI.
func (a *ApplicationAPI) Delete(ctx context.Context, req *pb.DeleteApplicationRequest) (*pb.DeleteApplicationResponse, error) {
	var eui lorawan.EUI64
	if err := eui.UnmarshalText([]byte(req.AppEUI)); err != nil {
		return nil, err
	}

	if err := storage.DeleteApplication(a.ctx.DB, eui); err != nil {
		return nil, err
	}

	return &pb.DeleteApplicationResponse{}, nil
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:13,代码来源:application.go


示例4: UnSubscribeGatewayTX

// UnSubscribeGatewayTX unsubscribes the backend from the gateway TXPacket
// topic.
func (b *Backend) UnSubscribeGatewayTX(mac lorawan.EUI64) error {
	defer b.mutex.Unlock()
	b.mutex.Lock()

	topic := fmt.Sprintf("gateway/%s/tx", mac.String())
	log.WithField("topic", topic).Info("backend/mqttpubsub: unsubscribing from topic")
	if token := b.conn.Unsubscribe(topic); token.Wait() && token.Error() != nil {
		return token.Error()
	}
	delete(b.gateways, mac)
	return nil
}
开发者ID:RedBeardLab,项目名称:lora-semtech-bridge,代码行数:14,代码来源:backend.go


示例5: SubscribeGatewayTX

// SubscribeGatewayTX subscribes the backend to the gateway TXPacket
// topic (packets the gateway needs to transmit).
func (b *Backend) SubscribeGatewayTX(mac lorawan.EUI64) error {
	defer b.mutex.Unlock()
	b.mutex.Lock()

	topic := fmt.Sprintf("gateway/%s/tx", mac.String())
	log.WithField("topic", topic).Info("backend/mqttpubsub: subscribing to topic")
	if token := b.conn.Subscribe(topic, 0, b.txPacketHandler); token.Wait() && token.Error() != nil {
		return token.Error()
	}
	b.gateways[mac] = struct{}{}
	return nil
}
开发者ID:RedBeardLab,项目名称:lora-semtech-bridge,代码行数:14,代码来源:backend.go


示例6: GetByDevEUI

// GetByDevEUI returns the node-session matching the given DevEUI.
func (a *NodeSessionAPI) GetByDevEUI(ctx context.Context, req *pb.GetNodeSessionByDevEUIRequest) (*pb.GetNodeSessionResponse, error) {
	var eui lorawan.EUI64
	if err := eui.UnmarshalText([]byte(req.DevEUI)); err != nil {
		return nil, err
	}

	ns, err := storage.GetNodeSessionByDevEUI(a.ctx.RedisPool, eui)
	if err != nil {
		return nil, err
	}

	return a.nodeSessionToResponse(ns)
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:14,代码来源:node_session.go


示例7: ListByAppEUI

// GetListByAppEUI returns a list of nodes (given an AppEUI, limit and offset).
func (a *NodeAPI) ListByAppEUI(ctx context.Context, req *pb.ListNodeByAppEUIRequest) (*pb.ListNodeResponse, error) {
	var eui lorawan.EUI64
	if err := eui.UnmarshalText([]byte(req.AppEUI)); err != nil {
		return nil, err
	}

	nodes, err := storage.GetNodesForAppEUI(a.ctx.DB, eui, int(req.Limit), int(req.Offset))
	if err != nil {
		return nil, err
	}
	count, err := storage.GetNodesForAppEUICount(a.ctx.DB, eui)
	if err != nil {
		return nil, err
	}
	return a.returnList(count, nodes)
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:17,代码来源:node.go


示例8: Get

// Get returns the Application for the given AppEUI.
func (a *ApplicationAPI) Get(ctx context.Context, req *pb.GetApplicationRequest) (*pb.GetApplicationResponse, error) {
	var eui lorawan.EUI64
	if err := eui.UnmarshalText([]byte(req.AppEUI)); err != nil {
		return nil, err
	}

	app, err := storage.GetApplication(a.ctx.DB, eui)
	if err != nil {
		return nil, err
	}
	b, err := app.AppEUI.MarshalText()
	if err != nil {
		return nil, err
	}
	return &pb.GetApplicationResponse{
		AppEUI: string(b),
		Name:   app.Name,
	}, nil
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:20,代码来源:application.go


示例9: Create

// Create creates the given Node.
func (a *NodeAPI) Create(ctx context.Context, req *pb.CreateNodeRequest) (*pb.CreateNodeResponse, error) {
	var appEUI, devEUI lorawan.EUI64
	var appKey lorawan.AES128Key

	if err := appEUI.UnmarshalText([]byte(req.AppEUI)); err != nil {
		return nil, err
	}
	if err := devEUI.UnmarshalText([]byte(req.DevEUI)); err != nil {
		return nil, err
	}
	if err := appKey.UnmarshalText([]byte(req.AppKey)); err != nil {
		return nil, err
	}

	node := models.Node{
		DevEUI: devEUI,
		AppEUI: appEUI,
		AppKey: appKey,

		RXDelay:     uint8(req.RxDelay),
		RX1DROffset: uint8(req.Rx1DROffset),
	}
	if req.ChannelListID > 0 {
		node.ChannelListID = &req.ChannelListID
	}

	if err := storage.CreateNode(a.ctx.DB, node); err != nil {
		return nil, err
	}

	return &pb.CreateNodeResponse{}, nil
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:33,代码来源:node.go


示例10: Update

// Update updates the node matching the given DevEUI.
func (a *NodeAPI) Update(ctx context.Context, req *pb.UpdateNodeRequest) (*pb.UpdateNodeResponse, error) {
	var appEUI, devEUI lorawan.EUI64
	var appKey lorawan.AES128Key

	if err := appEUI.UnmarshalText([]byte(req.AppEUI)); err != nil {
		return nil, err
	}
	if err := devEUI.UnmarshalText([]byte(req.DevEUI)); err != nil {
		return nil, err
	}
	if err := appKey.UnmarshalText([]byte(req.AppKey)); err != nil {
		return nil, err
	}

	node, err := storage.GetNode(a.ctx.DB, devEUI)
	if err != nil {
		return nil, err
	}

	node.AppEUI = appEUI
	node.AppKey = appKey
	node.RXDelay = uint8(req.RxDelay)
	node.RX1DROffset = uint8(req.Rx1DROffset)
	if req.ChannelListID > 0 {
		node.ChannelListID = &req.ChannelListID
	} else {
		node.ChannelListID = nil
	}

	if err := storage.UpdateNode(a.ctx.DB, node); err != nil {
		return nil, err
	}

	return &pb.UpdateNodeResponse{}, nil
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:36,代码来源:node.go


示例11: Get

// Get returns the Node for the given DevEUI.
func (a *NodeAPI) Get(ctx context.Context, req *pb.GetNodeRequest) (*pb.GetNodeResponse, error) {
	var eui lorawan.EUI64
	if err := eui.UnmarshalText([]byte(req.DevEUI)); err != nil {
		return nil, err
	}

	node, err := storage.GetNode(a.ctx.DB, eui)
	if err != nil {
		return nil, err
	}

	devEUI, err := node.DevEUI.MarshalText()
	if err != nil {
		return nil, err
	}
	appEUI, err := node.AppEUI.MarshalText()
	if err != nil {
		return nil, err
	}
	appKey, err := node.AppKey.MarshalText()
	if err != nil {
		return nil, err
	}

	resp := pb.GetNodeResponse{
		DevEUI:      string(devEUI),
		AppEUI:      string(appEUI),
		AppKey:      string(appKey),
		RxDelay:     uint32(node.RXDelay),
		Rx1DROffset: uint32(node.RX1DROffset),
	}

	if node.ChannelListID != nil {
		resp.ChannelListID = *node.ChannelListID
	}

	return &resp, nil
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:39,代码来源:node.go


示例12: Create

// Create creates the given node-session. The DevAddr must contain the same NwkID as the configured NetID. Node-sessions will expire automatically after the configured TTL.
func (a *NodeSessionAPI) Create(ctx context.Context, req *pb.CreateNodeSessionRequest) (*pb.CreateNodeSessionResponse, error) {
	var appEUI, devEUI lorawan.EUI64
	var appSKey, nwkSKey lorawan.AES128Key
	var devAddr lorawan.DevAddr

	if err := appEUI.UnmarshalText([]byte(req.AppEUI)); err != nil {
		return nil, err
	}
	if err := devEUI.UnmarshalText([]byte(req.DevEUI)); err != nil {
		return nil, err
	}
	if err := appSKey.UnmarshalText([]byte(req.AppSKey)); err != nil {
		return nil, err
	}
	if err := nwkSKey.UnmarshalText([]byte(req.NwkSKey)); err != nil {
		return nil, err
	}
	if err := devAddr.UnmarshalText([]byte(req.DevAddr)); err != nil {
		return nil, err
	}

	var cFList *lorawan.CFList
	if len(req.CFList) > len(cFList) {
		return nil, fmt.Errorf("max CFList channels is %d", len(cFList))
	}
	if len(req.CFList) > 0 {
		cFList = &lorawan.CFList{}
		for i, f := range req.CFList {
			cFList[i] = f
		}
	}

	ns := models.NodeSession{
		DevAddr:     devAddr,
		AppEUI:      appEUI,
		DevEUI:      devEUI,
		AppSKey:     appSKey,
		NwkSKey:     nwkSKey,
		FCntUp:      req.FCntUp,
		FCntDown:    req.FCntDown,
		RXDelay:     uint8(req.RxDelay),
		RX1DROffset: uint8(req.Rx1DROffset),
		CFList:      cFList,
	}

	if err := a.validateNodeSession(ns); err != nil {
		return nil, err
	}

	if err := storage.CreateNodeSession(a.ctx.RedisPool, ns); err != nil {
		return nil, err
	}

	return &pb.CreateNodeSessionResponse{}, nil
}
开发者ID:yuseunghyuk,项目名称:loraserver,代码行数:56,代码来源:node_session.go


示例13: PublishGatewayStats

// PublishGatewayStats publishes a GatewayStatsPacket to the MQTT broker.
func (b *Backend) PublishGatewayStats(mac lorawan.EUI64, stats models.GatewayStatsPacket) error {
	topic := fmt.Sprintf("gateway/%s/stats", mac.String())
	return b.publish(topic, stats)
}
开发者ID:RedBeardLab,项目名称:lora-semtech-bridge,代码行数:5,代码来源:backend.go


示例14: PublishGatewayRX

// PublishGatewayRX publishes a RX packet to the MQTT broker.
func (b *Backend) PublishGatewayRX(mac lorawan.EUI64, rxPacket models.RXPacket) error {
	topic := fmt.Sprintf("gateway/%s/rx", mac.String())
	return b.publish(topic, rxPacket)
}
开发者ID:RedBeardLab,项目名称:lora-semtech-bridge,代码行数:5,代码来源:backend.go



注:本文中的github.com/brocaar/lorawan.EUI64类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang lorawan.PHYPayload类代码示例发布时间:2022-05-24
下一篇:
Golang assert.Equal函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap