Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [leshan-dev] Registration Listener

Hi  All,
   During Registration  I am getting the following information and able to push to an Enterprise   Platform.
{
"endpoint": "ccccc",
"registrationId": "crtLar6TES",
"registrationDate": "2016-03-26T16:50:43+05:30",
"lastUpdate": "2016-03-26T16:51:37+05:30",
"address": "127.0.0.1:57653",
"lwM2mVersion": "1.0",
"lifetime": 30,
"bindingMode": "U",
"rootPath": "/",
"objectLinks": [{
"url": "/",
"attributes": {
"rt": "oma.lwm2m"
}
}, {
"url": "/1/0",
"attributes": {},
"objectId": 1,
"objectInstanceId": 0
}, {
"url": "/3/0",
"attributes": {},
"objectId": 3,
"objectInstanceId": 0
}, {
"url": "/6/0",
"attributes": {},
"objectId": 6,
"objectInstanceId": 0
}],
"secure": false,
"additionalRegistrationAttributes": {}
}


     But where are the attributes ?why it is null?

Thanks
Subhash

On Wed, Mar 9, 2016 at 3:24 PM, Simon Bernard <contact@xxxxxxxxxxxxxxx> wrote:
The Leshan Java API expose a listener on ClientRegistry (as I explained before), so if you need PUSH notification you can implement it easily.
The examples[1] that I gave in my previous email, use this listener to push new registration/update/deregistration as a "Server-sent events"[2]. (This API is used by our demo UI [3])
Up to you to implement it with the technology adapted to your use case. (e.g. AMQP ..)

[1]https://github.com/eclipse/leshan/blob/master/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/EventServlet.java
[2]https://en.wikipedia.org/wiki/Server-sent_events
[3]https://github.com/eclipse/leshan/blob/master/leshan-server-demo/src/main/resources/webapp/js/client-controllers.js#L88
 

Le 09/03/2016 07:08, Subhash Nair p a écrit :
Hi,
      Thanks all for the suggestions.
      
      To clarify more about my question-      Many OMA DM servers will implement  a PUSH Notification about the registration info  to  Enterprise Platforms so that Enterprises  can easily integrate a  external OMA DM server. 

 Similar way say  Enterprise will have its on User interface  to do Device management. An Enterprise Platform Connects to a Boot Strap Server and this server Provision the  LwM2M field device to Register to a  Leshan Server.  And Once the registration is done ,Leshan should PUSH this Info to the Enterprise platform  .
    
         I understood from previous replies that either a Enterprise platform have to periodically poll the Lesahn  or PULL the info from Leshan.  But I think for Platform Integration point of view  Leshan should have a PUSH Notification implementation.

thanks and regards
Subhash Nair
      



On Tue, Mar 8, 2016 at 10:57 PM, Simon Bernard <contact@xxxxxxxxxxxxxxx> wrote:
Leshan is just java libraries which help people to develop their own Lightweight M2M server.
It only provides a Java API (for now).
In that case, the clean way should be to use Leshan to develop your Lightweight M2M server and implements your remote API. (e.g. using REST or any other protocols ...)
The leshan-server-demo is an example of this. You could have a look at ClientServlet[1] and EventServlet[2].

Simon

[1]https://github.com/eclipse/leshan/blob/master/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/ClientServlet.java
[2]https://github.com/eclipse/leshan/blob/master/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/EventServlet.java


Le 08/03/2016 18:07, Pablo Punal a écrit :
In that case you need to embedded leshan in your application. But if leshan is running in other machine. How can you use the API?

//pablo


-------- Original message --------
From: Simon Bernard <contact@xxxxxxxxxxxxxxx>
Date: 3/8/2016 18:02 (GMT+01:00)
To: leshan developer discussions <leshan-dev@xxxxxxxxxxx>
Subject: Re: [leshan-dev] Registration Listener

...

Please consider using the Leshan API instead of using this kind of hack.

        // create a server
        LeshanServer server = new LeshanServerBuilder().build();
        server.start();

        // get current registered clients
        Collection<Client> allClients = server.getClientRegistry().allClients();

        // be notified of new registration
        server.getClientRegistry().addListener(new ClientRegistryListener() {
            public void updated(Client client) {
            }

            public void unregistered(Client client) {
            }

            public void registered(Client newClient) {
                System.out.println("New registration:" + newClient);
            }
        });

If you're limited by the current API please open an issue[1].

[1]https://github.com/eclipse/leshan/issues/new


Le 08/03/2016 16:59, Pablo Punal a écrit :
Hi,

You can add a Simple CoAP resource on Leshan and request periodically (also you can implement it with observe). 
Modify "leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/RegisterResource.java” and add this:

@Override
    public void handleGET(CoapExchange exchange) {
        Request request = exchange.advanced().getRequest();
        Collection<Client> clients = registrationHandler.clientRegistry.allClients();
        ArrayList<JSONObject> clientsArray = new ArrayList<>();
        Client client;
        JSONObject json;
        for(int i=0; i<clients.size(); i++) {
            client = (Client)clients.toArray()[i];
            json = new JSONObject();
            json.put("endPoint", client.getEndpoint());
            json.put("registrationId", client.getRegistrationId());
            json.put("address", client.getAddress().toString());
            json.put("port", client.getPort());
            json.put("objectLinks", Arrays.toString(client.getObjectLinks()));
            clientsArray.add(json);
        }
        String resp = clientsArray.toString();
        exchange.respond(ResponseCode.CONTENT, resp, MediaTypeRegistry.APPLICATION_LINK_FORMAT);
    }

Now you can request to Leshan server for connected devices. In this example you will receive this:

[
  1. {
    • "endPoint":"mulle-216",
    • "address":"\/fdfd:0:0:0:0:0:0:1",
    • "objectLinks":"[<\/1\/1>, <\/1\/2>, <\/2\/0>, <\/3\/0>, <\/4\/0>, <\/3311\/0>, <\/3311\/1>]",
    • "port":5683,
    • "registrationId":"3KnmBsPJ8T"
    },
  2. {
    • "endPoint":"mulle-248",
    • "address":"\/fdfd:0:0:0:f95e:73b7:a8e7:eeb0",
    • "objectLinks":"[<\/1\/1>, <\/1\/2>, <\/2\/0>, <\/3\/0>, <\/4\/0>, <\/3311\/1>, <\/3311\/2>, <\/3311\/3>, <\/3311\/4>]",
    • "port":5683,
    • "registrationId":"YmDbZUBAph"
    }
]

I implement this on one SCADA system that you can look at: https://github.com/punyal/BlackHole

I hope this help you.


Pablo Puñal Pereira
pablo.punal@xxxxxx





-------- Forwarded Message --------
Subject: Re: [leshan-dev] Registration Listener
Date:  Tue, 8 Mar 2016 11:56:02 +0100
From:  Simon Bernard <contact@xxxxxxxxxxxxxxx>
Reply-To: leshan developer discussions <leshan-dev@xxxxxxxxxxx>
To:  leshan developer discussions <leshan-dev@xxxxxxxxxxx>


You should have a look at ClientRegistry[1] and ClientRegistryListener[2]

[1]https://github.com/eclipse/leshan/blob/master/leshan-server-core/src/main/java/org/eclipse/leshan/server/client/ClientRegistry.java
[2]https://github.com/eclipse/leshan/blob/master/leshan-server-core/src/main/java/org/eclipse/leshan/server/client/ClientRegistryListener.java

Le 08/03/2016 11:08, Subhash Nair p a écrit :
Hi ,

    I have an idea about using Leshan as Device management server .My Platform does not have a Device Management Capability and so  I am looking for a ways where I can keep Leshan as an external entity to which I can redirect the DM operations.

Whenever  LWM2M  clients are getting registered to the Leshan server  I am looking for a mechanism like where I would implement a Registration Listener in my platform ,   and Leshan will notify this Listener about the registered client and its capabilities.
    
   Such kind of Notification service is there currently.?

Thanks in advance for the advcie .


Regards
Subhash Nair


_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev



<Attached Message Part.txt>



_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev



_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev


_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev




_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev


_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev



Back to the top