Skip to content

Commit

Permalink
getProfile based on registrationid
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslawLegierski committed Mar 15, 2023
1 parent ca1e6bc commit b67d369
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.eclipse.leshan.core.observation.Observation;
import org.eclipse.leshan.core.observation.ObservationIdentifier;
import org.eclipse.leshan.core.observation.SingleObservation;
import org.eclipse.leshan.core.request.Identity;
import org.eclipse.leshan.core.response.AbstractLwM2mResponse;
import org.eclipse.leshan.core.response.ObserveCompositeResponse;
import org.eclipse.leshan.core.response.ObserveResponse;
Expand Down Expand Up @@ -156,8 +155,9 @@ public void onNotification(Request coapRequest, Response coapResponse) {
return;
}
// Get profile
Identity identity = identityHandler.getIdentity(coapResponse);
ClientProfile profile = toolbox.getProfileProvider().getProfile(identity);
// Identity identity = identityHandler.getIdentity(coapResponse);
// ClientProfile profile = toolbox.getProfileProvider().getProfile(identity);
ClientProfile profile = toolbox.getProfileProvider().getProfile(regid);

// create Observe Response
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
public interface ClientProfileProvider {

ClientProfile getProfile(Identity identity);

ClientProfile getProfile(String registrationid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public ClientProfile getProfile(Identity identity) {
return new ClientProfile(registration, model);
}

@Override
public ClientProfile getProfile(String registrationid) {
Registration registration = registrationStore.getRegistration(registrationid);
LwM2mModel model = modelProvider.getObjectModel(registration);
return new ClientProfile(registration, model);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static LeshanServer createLeshanServer(LeshanServerDemoCLI cli) throws Ex
builder.setRegistrationStore(new RedisRegistrationStore(cli.main.redis));
}
builder.setSecurityStore(securityStore);

builder.setUpdateRegistrationOnNotification(true);
if (cli.identity.isx509()) {
// use X.509 mode (+ RPK)
builder.setPrivateKey(cli.identity.getPrivateKey());
Expand Down

0 comments on commit b67d369

Please sign in to comment.