@Override public ValueResponse read(int resourceid) { try { switch (resourceid) { case 0: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource(resourceid, Value.newIntegerValue(attacker.getFly_mode()))); case 1: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource(resourceid, Value.newIntegerValue(attacker.getIndex()))); case 2: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource( resourceid, Value.newStringValue(gson.toJson(attacker.getTarget_indicated_by_role())))); case 3: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource(resourceid, Value.newBooleanValue(attacker.isVisible()))); case 4: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource( resourceid, Value.newStringValue(gson.toJson(attacker.getCenter_coordinates())))); case 5: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource( resourceid, Value.newStringValue( gson.toJson(World.assignUAVPortInBase(attacker.getIndex()))))); case 9: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource(resourceid, Value.newBooleanValue(attacker.isLockedToThreat()))); case 12: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource(resourceid, Value.newFloatValue(attacker.getRemained_energy()))); case 13: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource( resourceid, Value.newStringValue(attacker.getAttackerType().toString()))); case 14: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource(resourceid, Value.newBooleanValue(attacker.isThreatDestroyed()))); case 15: return new ValueResponse( ResponseCode.CONTENT, new LwM2mResource( resourceid, Value.newIntegerValue(attacker.getJustDestroyedThreatIndex()))); default: return super.read(resourceid); } } catch (Exception e) { logger.error("ERROR: {}", e.getMessage()); return super.read(resourceid); } }
protected Value<String> createDefaultStringValue( ObjectModel objectModel, ResourceModel resourceModel) { return Value.newStringValue(resourceModel.name); }