@@ -271,6 +271,7 @@ public ClientUpgradeRequest getClientUpgradeRequest() {
271
271
public void registerVin (String vin , VehicleHandler handler ) {
272
272
discoveryService .vehicleRemove (this , vin , handler .getThing ().getThingTypeUID ().getId ());
273
273
activeVehicleHandlerMap .put (vin , handler );
274
+ discovery (vin ); // update properties for added vehicle
274
275
VEPUpdate updateForVin = vepUpdateMap .get (vin );
275
276
if (updateForVin != null ) {
276
277
handler .enqueueUpdate (updateForVin );
@@ -340,7 +341,6 @@ private void handleMessage(byte[] array) {
340
341
PushMessage pm = VehicleEvents .PushMessage .parseFrom (array );
341
342
if (pm .hasVepUpdates ()) {
342
343
boolean distributed = distributeVepUpdates (pm .getVepUpdates ().getUpdatesMap ());
343
- logger .trace ("Distributed VEPUpdate {}" , distributed );
344
344
if (distributed ) {
345
345
AcknowledgeVEPUpdatesByVIN ack = AcknowledgeVEPUpdatesByVIN .newBuilder ()
346
346
.setSequenceNumber (pm .getVepUpdates ().getSequenceNumber ()).build ();
@@ -349,7 +349,7 @@ private void handleMessage(byte[] array) {
349
349
}
350
350
} else if (pm .hasAssignedVehicles ()) {
351
351
for (int i = 0 ; i < pm .getAssignedVehicles ().getVinsCount (); i ++) {
352
- String vin = pm .getAssignedVehicles ().getVins (0 );
352
+ String vin = pm .getAssignedVehicles ().getVins (i );
353
353
discovery (vin );
354
354
}
355
355
AcknowledgeAssignedVehicles ack = AcknowledgeAssignedVehicles .newBuilder ().build ();
@@ -394,6 +394,7 @@ public boolean distributeVepUpdates(Map<String, VEPUpdate> map) {
394
394
}
395
395
});
396
396
notFoundList .forEach (vin -> {
397
+ discovery (vin ); // add vehicle to discovery
397
398
logger .trace ("No VehicleHandler available for VIN {}" , vin );
398
399
});
399
400
return notFoundList .isEmpty ();
@@ -410,13 +411,18 @@ public void commandStatusUpdate(Map<String, AppTwinCommandStatusUpdatesByPID> up
410
411
});
411
412
}
412
413
414
+ /**
415
+ * Updates properties for existing handlers or delivers discovery result
416
+ *
417
+ * @param vin of discovered vehicle
418
+ */
413
419
@ SuppressWarnings ("null" )
414
420
public void discovery (String vin ) {
415
421
if (activeVehicleHandlerMap .containsKey (vin )) {
416
422
VehicleHandler vh = activeVehicleHandlerMap .get (vin );
417
- if ( vh . getThing (). getProperties (). isEmpty ()) {
418
- vh .getThing ().setProperties ( getStringCapabilities ( vin ));
419
- }
423
+ Map < String , String > properties = getStringCapabilities ( vin );
424
+ properties . putAll ( vh .getThing ().getProperties ( ));
425
+ vh . getThing (). setProperties ( properties );
420
426
} else {
421
427
if (!capabilitiesMap .containsKey (vin )) {
422
428
// only report new discovery if capabilities aren't discovered yet
0 commit comments