Beispiel #1
0
 def refreshAuthTokenInfo(self):
     arInDTO = AuthRefreshInDTO()
     arInDTO.appId = (Constant().readConfFile())[2]
     arInDTO.secret = (Constant().readConfFile())[3]
     authOutDTO = AuthOutDTO()
     result = Authentication().getAuthToken(Constant().clientInfo())
     authOutDTO.setRefreshToken(json.loads(result)['refreshToken'])
     arInDTO.refreshToken = authOutDTO.getRefreshToken()
     return arInDTO
Beispiel #2
0
def subscribe(notifyType, callbackUrl):
    sb = Subscription(notifyType, callbackUrl)
    authentication = Authentication()
    subscriptionManagement = SubscriptionManagement()

    # get accessToken at first
    result = authentication.getAuthToken(Constant().clientInfo())
    authOutDTO = AuthOutDTO()
    authOutDTO.setAccessToken(json.loads(result)['accessToken'])
    accessToken = authOutDTO.getAccessToken()

    # sub deviceDataChanged notification
    ss = subscriptionManagement.subDeviceBusinessData(sb.subDeviceBusinessData(), accessToken)
    print("====== subscribe to device business data notification ======")
    print("result:", ss + "\n")
    return ss
Beispiel #3
0
def postCommand(method, paras):
    sdTest = PostCommand()
    sdTest.method = method
    sdTest.paras = paras

    authentication = Authentication()
    signalDelivery = SignalDelivery()

    # get accessToken at first
    result = authentication.getAuthToken(Constant().clientInfo())
    authOutDTO = AuthOutDTO()
    authOutDTO.setAccessToken(json.loads(result)['accessToken'])
    accessToken = authOutDTO.getAccessToken()

    # post an NB-IoT device command
    sp = signalDelivery.postDeviceCommand(sdTest.postDeviceCommandInfo(), None, accessToken)
    # print("====== post an NB-IoT device command ======")
    # print("result:", sp + "\n")
    return sp
Beispiel #4
0
    def refreshDeviceKeyInfo(self):
        rdkInDTO = RefreshDeviceKeyInDTO()
        rdkInDTO.deviceId = deviceId
        rdkInDTO.nodeId = "SSSDAWSQAS"
        rdkInDTO.verifyCode = "SSSDAWSQAS11"
        return rdkInDTO


if __name__ == "__main__":
    dmTest = DeviceManagementTest()
    authentication = Authentication()
    deviceManagement = DeviceManagement()

    # get accessToken at first
    result = Authentication().getAuthToken(Constant().clientInfo())
    authOutDTO = AuthOutDTO()
    authOutDTO.setAccessToken(json.loads(result)['accessToken'])
    accessToken = authOutDTO.getAccessToken()

    # register a new device
    dr = deviceManagement.regDirectDevice(dmTest.regDirectDeviceInfo(), None,
                                          accessToken)
    print("====== register a new device ======")
    print("result:", dr + "\n")

    # get deviceId
    rddod = RegDirectDeviceOutDTO()
    rddod.setDeviceId(json.loads(dr)['deviceId'])
    deviceId = rddod.getDeviceId()
    print("deviceId==", deviceId + "\n")