// Payload converts the JoinRequestPayload to a lorawan.Payload func (msg *Message_JoinRequestPayload) Payload() lorawan.Payload { m := *msg.JoinRequestPayload var mac lorawan.JoinRequestPayload mac.AppEUI = lorawan.EUI64(m.AppEui) mac.DevEUI = lorawan.EUI64(m.DevEui) mac.DevNonce = m.DevNonce return &mac }
func doTestHandleActivation(h *handler, appEUI types.AppEUI, devEUI types.DevEUI, devNonce [2]byte, appKey types.AppKey) (*pb.DeviceActivationResponse, error) { devAddr := types.DevAddr{1, 2, 3, 4} requestPHY := lorawan.PHYPayload{ MHDR: lorawan.MHDR{ MType: lorawan.JoinRequest, Major: lorawan.LoRaWANR1, }, MACPayload: &lorawan.JoinRequestPayload{ AppEUI: lorawan.EUI64(appEUI), DevEUI: lorawan.EUI64(devEUI), DevNonce: devNonce, }, } requestPHY.SetMIC(lorawan.AES128Key(appKey)) requestBytes, _ := requestPHY.MarshalBinary() responsePHY := lorawan.PHYPayload{ MHDR: lorawan.MHDR{ MType: lorawan.JoinAccept, Major: lorawan.LoRaWANR1, }, MACPayload: &lorawan.JoinAcceptPayload{}, } templateBytes, _ := responsePHY.MarshalBinary() return h.HandleActivation(&pb_broker.DeduplicatedDeviceActivationRequest{ Payload: requestBytes, AppEui: &appEUI, AppId: appEUI.String(), DevEui: &devEUI, DevId: devEUI.String(), ActivationMetadata: &pb_protocol.ActivationMetadata{Protocol: &pb_protocol.ActivationMetadata_Lorawan{ Lorawan: &pb_lorawan.ActivationMetadata{ DevAddr: &devAddr, }, }}, ResponseTemplate: &pb_broker.DeviceActivationResponse{ Payload: templateBytes, }, }) }