Пример #1
0
 @Override
 public WriteResponse write(int resourceid, LwM2mResource value) {
   LwM2mResource previousValue = resources.get(resourceid);
   resources.put(resourceid, value);
   if (!value.equals(previousValue)) fireResourceChange(resourceid);
   return WriteResponse.success();
 }
Пример #2
0
  @Override
  protected WriteResponse doWrite(WriteRequest request) {
    LwM2mPath path = request.getPath();

    // Manage Instance case
    LwM2mInstanceEnabler instance = instances.get(path.getObjectInstanceId());
    if (instance == null) return WriteResponse.notFound();

    if (path.getResourceId() == null) {
      for (LwM2mResource resource :
          ((LwM2mObjectInstance) request.getNode()).getResources().values()) {
        instance.write(resource.getId(), resource);
      }
      return WriteResponse.success();
    }

    // Manage Resource case
    return instance.write(path.getResourceId(), (LwM2mResource) request.getNode());
  }