Check return value before calling addDevice()
Only increment the java o-o layer shadow copy of the
device index if the C library oc_add_device() call is
successful.
@@ -59,8 +59,10 @@ public class OcPlatform {
ret = OCMain.addDevice(device.getUri(), device.getRt(), device.getName(), device.getSpecVersion(),
device.getDataModelVersion());
+ if (ret >= 0) {
deviceIndex.getAndIncrement(); // get ready for next device
}
+ }
return ret;
}
