Hi there,
I’m taking my first steps in Go and am trying to use the SDK. I am following the examples in the quick start and am getting these errors which ends with Too many errors:
# github.com/TheThingsNetwork/api/protocol/lorawan ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:57:26: cannot use cmd.MACCommand() (type lorawan.MACCommand) as type lorawan.Payload in append: lorawan.MACCommand does not implement lorawan.Payload (UnmarshalBinary method has pointer receiver) ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:83:58: cannot use cmd (type lorawan.Payload) as type lorawan.MACCommand in argument to MACCommandFromMACCommand ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:101:5: mac.AppEUI undefined (type lorawan.JoinRequestPayload has no field or method AppEUI) ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:103:33: cannot convert m.DevNonce (type "github.com/TheThingsNetwork/ttn/core/types".DevNonce) to type lorawan.DevNonce ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:110:40: payload.AppEUI undefined (type *lorawan.JoinRequestPayload has no field or method AppEUI) ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:112:36: cannot convert payload.DevNonce (type lorawan.DevNonce) to type "github.com/TheThingsNetwork/ttn/core/types".DevNonce ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:124:5: mac.AppNonce undefined (type lorawan.JoinAcceptPayload has no field or method AppNonce) ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:124:17: undefined: lorawan.AppNonce ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:125:5: mac.NetID undefined (type lorawan.JoinAcceptPayload has no field or method NetID) ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:132:17: cannot use m.CFList.Freq[0] (type uint32) as type lorawan.Payload in field value: uint32 does not implement lorawan.Payload (missing MarshalBinary method) ..\..\TheThingsNetwork\api\protocol\lorawan\message_conversion.go:132:17: too many errors
Using govendor (as per quick start guide) gave errors so I installed go-sdk-app using vgo (as per repo readme). My code is below. Grateful for any help!
Thanks, Mark
package main
import (
"encoding/hex"
"fmt"
ttnsdk "github.com/TheThingsNetwork/go-app-sdk"
ttnlog "github.com/TheThingsNetwork/go-utils/log"
"github.com/TheThingsNetwork/go-utils/log/apex"
)
const (
sdkClientName = "thingitude-is-go"
)
func main() {
log := apex.Stdout()
ttnlog.Set(log)
appID := "MY-UNIQUE-APP-ID"
appAccessKey := "ttn-account-v2.MY-SECRET-KEY"
config := ttnsdk.NewCommunityConfig(sdkClientName)
config.ClientVersion = "2.0.5"
client := config.NewClient(appID, appAccessKey)
defer client.Close()
//subscribe to activations for our application
pubsub, err := client.PubSub()
if err != nil {
log.WithError(err).Fatalf("%s: could not get application pub/sub", sdkClientName)
}
// subscribe to uplink messages
myNewDevicePubSub := pubsub.Device("elsys-01")
uplink, err := myNewDevicePubSub.SubscribeUplink()
if err != nil {
log.WithError(err).Fatalf("%s: could not subscribe to uplink messages", sdkClientName)
}
go func() {
for message := range uplink {
hexPayload := hex.EncodeToString(message.PayloadRaw)
log.WithField("data", hexPayload).Infof("%s: received uplink", sdkClientName)
}
}()
}