Esempio n. 1
0
	"github.com/TheThingsNetwork/ttn/ttnctl/util"
	"github.com/spf13/cobra"
)

var gatewaysInfoCmd = &cobra.Command{
	Use:   "info [GatewayID]",
	Short: "get info about a gateway",
	Long:  `ttnctl gateways info can be used to get information about a gateway`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			cmd.UsageFunc()(cmd)
			return
		}

		gatewayID := args[0]
		if !api.ValidID(gatewayID) {
			ctx.Fatal("Invalid Gateway ID")
		}

		account := util.GetAccount(ctx)

		gateway, err := account.FindGateway(gatewayID)
		if err != nil {
			ctx.WithError(err).WithField("id", gatewayID).Fatal("Could not find gateway")
		}

		ctx.Info("Found gateway")

		fmt.Println()
		fmt.Printf("Gateway ID:     %s\n", gateway.ID)
		fmt.Printf("Activated:      %v\n", gateway.Activated)
Esempio n. 2
0
           Last seen: 2016-09-20 08:25:27.94138808 +0200 CEST
           Timestamp: 0
       Reported time: 2016-09-20 08:25:26 +0200 CEST
     GPS coordinates: (52.372791 4.900300)
                 Rtt: not available
                  Rx: (in: 0; ok: 0)
                  Tx: (in: 0; ok: 0)
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			cmd.UsageFunc()(cmd)
			return
		}

		gtwID := args[0]
		if !api.ValidID(gtwID) {
			ctx.Fatal("Invalid Gateway ID")
		}

		conn, manager := util.GetRouterManager(ctx)
		defer conn.Close()

		ctx = ctx.WithField("GatewayID", gtwID)

		resp, err := manager.GatewayStatus(util.GetContext(ctx), &router.GatewayStatusRequest{
			GatewayId: gtwID,
		})
		if err != nil {
			ctx.WithError(errors.FromGRPCError(err)).Fatal("Could not get status of gateway.")
		}
Esempio n. 3
0
	Long:  `ttnctl components check is used to check the status of routing services`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 2 {
			cmd.UsageFunc()(cmd)
			return
		}

		serviceType := args[0]
		switch serviceType {
		case "router", "broker", "handler":
		default:
			ctx.Fatalf("Service type %s unknown", serviceType)
		}

		serviceID := args[1]
		if !api.ValidID(serviceID) {
			ctx.Fatalf("Service ID %s invalid", serviceID)
		}

		dscConn, client := util.GetDiscovery(ctx)
		defer dscConn.Close()

		res, err := client.Get(util.GetContext(ctx), &discovery.GetRequest{
			ServiceName: serviceType,
			Id:          serviceID,
		})
		if err != nil {
			ctx.WithError(errors.FromGRPCError(err)).Fatalf("Could not get %s %s", serviceType, serviceID)
		}

		conn, err := res.Dial()
Esempio n. 4
0
     AppKey: <nil>
    AppSKey: D8DD37B4B709BA76C6FEC62CAD0CCE51
    NwkSKey: 3382A3066850293421ED8D392B9BF4DF
     FCntUp: 0
   FCntDown: 0
    Options:
`,
	Run: func(cmd *cobra.Command, args []string) {

		if len(args) == 0 {
			cmd.UsageFunc()(cmd)
			return
		}

		devID := args[0]
		if !api.ValidID(devID) {
			ctx.Fatalf("Invalid Device ID") // TODO: Add link to wiki explaining device IDs
		}

		appID := util.GetAppID(ctx)

		conn, manager := util.GetHandlerManager(ctx, appID)
		defer conn.Close()

		dev, err := manager.GetDevice(appID, devID)
		if err != nil {
			ctx.WithError(err).Fatal("Could not get existing device.")
		}

		byteFormat, _ := cmd.Flags().GetString("format")