@Override public final String toString() { return String.format("DiscoverRequest [%s]", getPath()); } }
/** * Create a request for discovering the attributes of a particular object/instance/resource targeted by a specific * path. * * @param path the path of the LWM2M node to discover * @exception InvalidRequestException if the path is not valid. */ public DiscoverRequest(String path) throws InvalidRequestException { this(newPath(path)); }
if (registration != null) { DiscoverRequest request = new DiscoverRequest(target); DiscoverResponse cResponse = server.send(registration, request, TIMEOUT); processDeviceResponse(req, resp, cResponse);
return new DeleteRequest(path); case "discover": return new DiscoverRequest(path); case "create": { int format = o.getInt("contentFormat", ContentFormat.TLV.getCode());
@Override public void visit(DiscoverRequest request) { coapRequest = Request.newGet(); setTarget(coapRequest, destination, request.getPath()); coapRequest.getOptions().setAccept(MediaTypeRegistry.APPLICATION_LINK_FORMAT); }
return new DeleteRequest(path); case "discover": return new DiscoverRequest(path); case "create": { int format = o.getInt("contentFormat", ContentFormat.TLV.getCode());
@Override public void visit(DiscoverRequest request) { coapRequest = Request.newGet(); setTarget(coapRequest, request.getPath()); coapRequest.getOptions().setAccept(MediaTypeRegistry.APPLICATION_LINK_FORMAT); }
DiscoverResponse response = nodeEnabler.discover(identity, new DiscoverRequest(URI)); if (response.getCode().isError()) { exchange.respond(toCoapResponseCode(response.getCode()), response.getErrorMessage());
protected DiscoverResponse doDiscover(DiscoverRequest request) { LwM2mPath path = request.getPath(); if (path.isObject()) { // Manage discover on object Link[] ObjectLinks = LinkFormatHelper.getObjectDescription(this, null); return DiscoverResponse.success(ObjectLinks); } else if (path.isObjectInstance()) { // Manage discover on instance if (!getAvailableInstanceIds().contains(path.getObjectInstanceId())) return DiscoverResponse.notFound(); Link[] instanceLink = LinkFormatHelper.getInstanceDescription(this, path.getObjectInstanceId(), null); return DiscoverResponse.success(instanceLink); } else if (path.isResource()) { // Manage discover on resource if (!getAvailableInstanceIds().contains(path.getObjectInstanceId())) return DiscoverResponse.notFound(); ResourceModel resourceModel = getObjectModel().resources.get(path.getResourceId()); if (resourceModel == null) return DiscoverResponse.notFound(); if (!getAvailableResourceIds(path.getObjectInstanceId()).contains(path.getResourceId())) return DiscoverResponse.notFound(); Link resourceLink = LinkFormatHelper.getResourceDescription(this, path.getObjectInstanceId(), path.getResourceId(), null); return DiscoverResponse.success(new Link[] { resourceLink }); } return DiscoverResponse.badRequest(null); }