8585import pt .lsts .neptus .util .ByteUtil ;
8686import pt .lsts .neptus .util .GuiUtils ;
8787import pt .lsts .neptus .util .conf .ConfigFetch ;
88+ import pt .lsts .neptus .util .conf .GeneralPreferences ;
8889import pt .lsts .neptus .util .http .client .HttpClientConnectionHelper ;
8990
9091import static pt .lsts .neptus .comm .iridium .HubIridiumMessenger .updateVehicleWithLastSeenImei ;
@@ -232,7 +233,8 @@ public void sendMessage(IridiumMessage msg) throws Exception {
232233 if (askCredentials ())
233234 return ;
234235
235- String result = sendToRockBlockHttp (args .getLastSeenImei (), getRockBlockUsername (), getRockBlockPassword (),
236+ String destImei = getImeiToUse (args );
237+ String result = sendToRockBlockHttp (destImei , getRockBlockUsername (), getRockBlockPassword (),
236238 msg .serialize ());
237239 checkResponseFromServer (result );
238240 }
@@ -245,16 +247,33 @@ public void sendMessageRaw(String destinationName, String imeiAddr, byte[] data)
245247 throw new Exception ("Cannot send message to an unknown destination" );
246248 }
247249 IridiumArgs args = (IridiumArgs ) vt .getProtocolsArgs ().get ("iridium" );
248- imeiAddr = args . getLastSeenImei ( );
250+ imeiAddr = getImeiToUse ( args );
249251 }
250252
251- if (askCredentials ())
253+ if (askCredentials ()) {
252254 return ;
255+ }
253256
254257 String result = sendToRockBlockHttp (imeiAddr , getRockBlockUsername (), getRockBlockPassword (), data );
255258 checkResponseFromServer (result );
256259 }
257260
261+ private static String getImeiToUse (IridiumArgs args ) {
262+ String destImei = args .getLastSeenImei ();
263+ int imeiIdx = GeneralPreferences .iridiumModemDefaultIndexToUse ;
264+ if (imeiIdx > 0 ) {
265+ switch (imeiIdx ) {
266+ case 1 :
267+ destImei = args .getImei ();
268+ break ;
269+ case 2 :
270+ default :
271+ destImei = args .getImei1 ();
272+ }
273+ }
274+ return destImei ;
275+ }
276+
258277 public String sendToRockBlockHttp (String destImei , String username , String password , byte [] data )
259278 throws IOException {
260279
0 commit comments