| | |
| | | String token = this.getToken(); |
| | | res = (String) requestMethod.invoke(this.uavClient, this.host + url, token, data); |
| | | } catch (IllegalAccessException e) { |
| | | System.out.println("doUavRequest 访问失败" + e.getMessage()); |
| | | log.error("doUavRequest 访问失败" + e.getMessage()); |
| | | } catch (InvocationTargetException e) { |
| | | System.out.println("doUavRequest 执行失败" + e.getMessage()); |
| | | log.error("doUavRequest 执行失败" + e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | |
| | | //验证token有效性 |
| | | try { |
| | | String res = uavClient.GET(this.host+"manage/api/v1/devices", token, "{}"); |
| | | System.out.println(res); |
| | | //System.out.println(res); |
| | | } catch (ForestNetworkException fe) { |
| | | if (fe.getStatusCode() == 401) {//token失效,重新登录 |
| | | this.login(); |
| | |
| | | log.debug("登录无人机外部接口"); |
| | | String codedPassword = this.Encrypt(password, salt); |
| | | String body = "{\"username\":\"" + username + "\",\"password\":\"" + codedPassword + "\"}"; |
| | | System.out.println("body:" + body); |
| | | log.debug("body:" + body); |
| | | try { |
| | | //uavClient.GET("logout", null, "{}"); |
| | | String res = uavClient.POST(this.host+"login", null, body); |