message := types.DownlinkMessage{ AppID: appID, DevID: devID, FPort: uint8(fPort), } if args[1] == "" { ctx.Info("Invalid command") cmd.UsageFunc()(cmd) return } if jsonflag { // Valid payload provided + json flag _, err := types.ParseHEX(args[1], len(args[1])/2) if err == nil { ctx.WithError(err).Fatal("You are providing a valid HEX payload while sending payload in JSON.") } err = json.Unmarshal([]byte(args[1]), &message.PayloadFields) if err != nil { ctx.WithError(err).Fatal("Invalid json string") return } } else { // Payload provided payload, err := types.ParseHEX(args[1], len(args[1])/2) if err != nil { ctx.WithError(err).Fatal("Invalid Payload") }
appEUI, err := types.ParseAppEUI(args[0]) if err != nil { ctx.WithError(err).Fatal("Could not parse AppEUI") } devEUI, err := types.ParseDevEUI(args[1]) if err != nil { ctx.WithError(err).Fatal("Could not parse DevEUI") } appKey, err := types.ParseAppKey(args[2]) if err != nil { ctx.WithError(err).Fatal("Could not parse AppKey") } devNonceSlice, err := types.ParseHEX(args[3], 2) if err != nil { ctx.WithError(err).Fatal("Could not parse DevNonce") } devNonce := [2]byte{devNonceSlice[0], devNonceSlice[1]} rtrConn, rtrClient := util.GetRouter(ctx) defer rtrConn.Close() gatewayID := viper.GetString("gateway-id") gatewayToken := viper.GetString("gateway-token") if gatewayID != "dev" { account := util.GetAccount(ctx) token, err := account.GetGatewayToken(gatewayID) if err != nil {
nwkSKey, err := types.ParseNwkSKey(args[1]) if err != nil { ctx.WithError(err).Fatal("Invalid NwkSKey") } appSKey, err := types.ParseAppSKey(args[2]) if err != nil { ctx.WithError(err).Fatal("Invalid AppSKey") } fCnt, err := strconv.Atoi(args[3]) if err != nil { ctx.WithError(err).Fatal("Invalid FCnt") } payload, err := types.ParseHEX(args[4], len(args[4])/2) if err != nil { ctx.WithError(err).Fatal("Invalid Payload") } withDownlink, _ := cmd.Flags().GetBool("downlink") confirmed, _ := cmd.Flags().GetBool("confirmed") if confirmed { withDownlink = true } rtrConn, rtrClient := util.GetRouter(ctx) defer rtrConn.Close() gatewayID := viper.GetString("gateway-id")