コード例 #1
0
  @Override
  public void sendMessage(IridiumMessage msg) throws Exception {
    VehicleType vt = VehiclesHolder.getVehicleWithImc(new ImcId16(msg.getDestination()));
    if (vt == null) {
      throw new Exception("Cannot send message to an unknown destination");
    }
    IridiumArgs args = (IridiumArgs) vt.getProtocolsArgs().get("iridium");
    if (askRockBlockPassword || rockBlockPassword == null || rockBlockUsername == null) {
      Pair<String, String> credentials =
          GuiUtils.askCredentials(
              ConfigFetch.getSuperParentFrame(),
              "Enter RockBlock Credentials",
              getRockBlockUsername(),
              getRockBlockPassword());
      if (credentials == null) return;
      setRockBlockUsername(credentials.first());
      setRockBlockPassword(credentials.second());
      PluginUtils.saveProperties("conf/rockblock.props", this);
      askRockBlockPassword = false;
    }

    String result =
        sendToRockBlockHttp(
            args.getImei(), getRockBlockUsername(), getRockBlockPassword(), msg.serialize());

    if (result != null) {
      if (!result.split(",")[0].equals("OK")) {
        throw new Exception("RockBlock server failed to deliver the message: '" + result + "'");
      }
    }
  }
コード例 #2
0
 private IridiumMessage process(byte[] data, String from) {
   try {
     return IridiumMessage.deserialize(data);
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }