|
@@ -42,6 +42,7 @@ import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Properties;
|
|
|
|
|
|
public class BridgeServer {
|
|
@@ -168,18 +169,18 @@ public class BridgeServer {
|
|
|
|
|
|
public void resetVirtualOCFDevices() {
|
|
|
|
|
|
- int dev_count = OCBridge.getVirtualDeviceCount();
|
|
|
- Log.d(TAG, "VOD Nums = ["+dev_count+"], Core Res Nums = ["+OCCoreRes.getNumDevices()+"]");
|
|
|
+ int dev_count = (int)OCCoreRes.getNumDevices();
|
|
|
+ Log.d(TAG, "VOD Nums = ["+OCBridge.getVirtualDeviceCount()+"], Core Res Nums = ["+OCCoreRes.getNumDevices()+"]");
|
|
|
for (int index = 1 ; index <= dev_count; index++) {
|
|
|
- OCVirtualDevice vod = OCBridge.getVirtualDeviceInfo(index);
|
|
|
+ /*OCVirtualDevice vod = OCBridge.getVirtualDeviceInfo(index);
|
|
|
if(vod!=null) continue;
|
|
|
Log.d(TAG, "VODs Device [" + index + ", "+vod.getIndex()+", vod_id="+OCUuidUtil.bytesToString(vod.getId())+ "]");
|
|
|
-
|
|
|
- OCDeviceInfo info = OCCoreRes.getDeviceInfo(index);
|
|
|
- if(info != null) {
|
|
|
- Log.d(TAG, "Core Device [" + index + ", "+vod.getIndex()+" piid="+OCUuidUtil.uuidToString(info.getPiid())+ "]");
|
|
|
- if(info.getName() != null) {
|
|
|
- Log.d(TAG, "VODs Device [" + index + ", " + vod.getIndex() + "], " + vod.getEconame() + ", " + info.getName() + " will be reset!");
|
|
|
+*/
|
|
|
+ OCDeviceInfo dev = OCCoreRes.getDeviceInfo(index);
|
|
|
+ if(dev != null) {
|
|
|
+ Log.d(TAG, "Core OCF Device [" + index +" piid="+OCUuidUtil.uuidToString(dev.getPiid())+ "]");
|
|
|
+ if(dev.getName() != null) {
|
|
|
+ Log.d(TAG, "Core OCF Device [" + index + "] "+dev.getName()+" was reset!");
|
|
|
this.resetDevice(index);
|
|
|
}
|
|
|
}
|
|
@@ -189,7 +190,7 @@ public class BridgeServer {
|
|
|
public void resetVirtualOCFDevice(OCUuid device_uuid) {
|
|
|
int dev_count = (int)OCCoreRes.getNumDevices();
|
|
|
Log.d(TAG, "Core Device Nums = ["+dev_count+"] ");
|
|
|
- for (int index = 1; index < dev_count; index++) {
|
|
|
+ for (int index = 1; index <= dev_count; index++) {
|
|
|
OCDeviceInfo dev = OCCoreRes.getDeviceInfo(index);
|
|
|
if (dev != null && OCUuidUtil.isEqual(dev.getDi(),device_uuid)) {
|
|
|
this.resetDevice(index);
|
|
@@ -201,7 +202,7 @@ public class BridgeServer {
|
|
|
public void resetVirtualOCFDevice(String device_uuid) {
|
|
|
int dev_count = (int)OCCoreRes.getNumDevices();
|
|
|
Log.d(TAG, "Core Device Nums = ["+dev_count+"] ");
|
|
|
- for (int index = 1; index < dev_count; index++) {
|
|
|
+ for (int index = 1; index <= dev_count; index++) {
|
|
|
OCDeviceInfo dev = OCCoreRes.getDeviceInfo(index);
|
|
|
if (dev != null && OCUuidUtil.uuidToString(dev.getDi()).equalsIgnoreCase(device_uuid)) {
|
|
|
this.resetDevice(index);
|
|
@@ -213,7 +214,7 @@ public class BridgeServer {
|
|
|
public void resetVirtualOCFDeviceByDevicePiid(String device_sn) {
|
|
|
int dev_count = (int)OCCoreRes.getNumDevices();
|
|
|
Log.d(TAG, "Core Device Nums = ["+dev_count+"] ");
|
|
|
- for (int index = 1; index < dev_count; index++) {
|
|
|
+ for (int index = 1; index <= dev_count; index++) {
|
|
|
OCDeviceInfo dev = OCCoreRes.getDeviceInfo(index);
|
|
|
if (dev != null && OCUuidUtil.uuidToString(dev.getPiid()).equalsIgnoreCase(device_sn)) {
|
|
|
this.resetDevice(index);
|
|
@@ -406,8 +407,8 @@ public class BridgeServer {
|
|
|
+ ", Device Piid = " + OCUuidUtil.uuidToString(dev_info.getPiid()));
|
|
|
|
|
|
// Add Light OCF Device IDD
|
|
|
- //byte[] idd_bytes = getFileBytes("idds/virtual_ocf_device_light_IDD.cbor"); // example : "virtual_ocf_device_light_IDD.cbor"
|
|
|
- //OCIntrospection.setIntrospectionData(vod_index, idd_bytes);
|
|
|
+ byte[] idd_bytes = getFileBytes("idds/virtual_ocf_device_light_IDD.cbor"); // example : "virtual_ocf_device_light_IDD.cbor"
|
|
|
+ OCIntrospection.setIntrospectionData(vod_index, idd_bytes);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -653,7 +654,7 @@ public class BridgeServer {
|
|
|
baos = new ByteArrayOutputStream();
|
|
|
int length = 0;
|
|
|
while ((length = is.read(buffer)) != -1) {
|
|
|
- Log.d(TAG, "bytes read = " + length);
|
|
|
+ //Log.d(TAG, "bytes read = " + length);
|
|
|
baos.write(buffer, 0, length);
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
@@ -679,7 +680,14 @@ public class BridgeServer {
|
|
|
Log.e(TAG, "Failed to read " + filepath);
|
|
|
}
|
|
|
|
|
|
- return ((baos != null) ? baos.toByteArray() : null);
|
|
|
+ if(baos!=null) {
|
|
|
+ int len = baos.toByteArray().length ;
|
|
|
+ byte[] result = Arrays.copyOf(baos.toByteArray(), len + 1);
|
|
|
+ result[len] = (byte)0x00;
|
|
|
+ Log.d(TAG, "bytes length = " + result.length);
|
|
|
+ return result ;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|
|
|
|