Exemplo n.º 1
0
			euis = append(euis, eui)
		}

		account := util.GetAccount(ctx)

		app, err := account.CreateApplication(args[0], args[1], euis)
		if err != nil {
			ctx.WithError(err).Fatal("Could not add application")
		}

		util.ForceRefreshToken(ctx)

		ctx.Info("Added Application")

		skipSelect, _ := cmd.Flags().GetBool("skip-select")
		if !skipSelect {
			util.SetApp(ctx, app.ID, app.EUIs[0])
		}

		ctx.Info("Selected Current Application")

	},
}

func init() {
	applicationsCmd.AddCommand(applicationsAddCmd)
	applicationsAddCmd.Flags().StringSlice("app-eui", []string{}, "LoRaWAN AppEUI to register with application")
	applicationsAddCmd.Flags().Bool("skip-select", false, "Do not select this application (also adds --skip-register)")
	applicationsAddCmd.Flags().Bool("skip-register", false, "Do not register application with the Handler")
}
Exemplo n.º 2
0
			table.MaxColWidth = 70
			table.AddRow("", "EUI")
			for i, eui := range app.EUIs {
				table.AddRow(i+1, eui)
			}

			fmt.Println()
			fmt.Println(table)
			fmt.Println()

			fmt.Println("Which one do you want to use?")
			fmt.Printf("Enter the number (1 - %d) > ", len(app.EUIs))
			fmt.Scanf("%d", &euiIdx)
			euiIdx--
		}

		if euiIdx < 0 || euiIdx >= len(apps) {
			ctx.Fatal("Invalid choice for EUI")
		}
		eui := app.EUIs[euiIdx]

		util.SetApp(ctx, app.ID, eui)

		ctx.Info("Updated configuration")
	},
}

func init() {
	applicationsCmd.AddCommand(applicationsSelectCmd)
}