g1velo / SNAVXbee2

0 stars 0 forks source link

How much time to take binding from initializing to online state in Eclipse smart home #11

Closed amarpulli1994 closed 6 years ago

amarpulli1994 commented 6 years ago

Hello @g1velo ,

I need to know how long SNAVXbee2 binding will take from initializing to online state in Eclipse Smart Home. I did tested different cases. When I could turn off both Eclipse Smart home Server and Xbee Devices at a time. Now I should turn on first ESH Server and then turn on Xbee devices. But here the binding still showing it as a Initializing state. Some cases binding going to be Online State and rest of xbee devices (Co-ordinator and End Devices) still in Initializing State. how much time will wait for binding going to from Initializing to Online State.

Thanks and regards,

Amar Pulli.

g1velo commented 6 years ago

Hi Amar, Not sure I do understand everything. Today's binding behavior : in its initialize() method, the SNAVXbee2BridgeHandler class, makes sure that the select com port is open, launching a discovery. the binding will update the thing ( The coordinator ) to On-line. Then the framework will launch the initialize() methods of each things.

In your comments, you mention the binding being on-line or not.. I think it would be the framework responsibility to bring the binding on-line. Anyway you could try to set the loglevel to trace to get more information about what is happening inside the binding. Hope this helps. cheers !

amarpulli1994 commented 6 years ago

@g1velo ,

I understood at initialize method() in SNAVXbee2BridgeHandler class. As per my understanding I have adding some piece of code in SNAVXbee2Handler class. Below code to represents a thing refresh automatically

 if (thing.getThingTypeUID().equals(THING_TYPE_CAFE1001)) {
            // starting automatic refresh for this device
            startAutomaticRefresh();
        }

So when the power goes off (CAFE1001 devices), it should be changing from online to initializing state. I have one more thing ask to you. When we are getting the data from end devices to co-coordinator, like S1OFF or S1ON. For ex: I will send the S1ON to end device.

18:18:03.651 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'light1' received command ON
18:18:03.662 [INFO ] [smarthome.event.ItemStateChangedEvent] - light1 changed from OFF to ON

Then I will update S1OFF at end device side. So the channel updating at User Interface side only. According to channelActionToPerform.setChannelUIDToUpdate(new ChannelUID(thingUIDToUpdate + ":S1"));

it will be working fine. But i didn't get any log files like below, when I got data from end device side.

17:47:07.426 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'light1' received command OFF
17:47:07.438 [INFO ] [smarthome.event.ItemStateChangedEvent] - light1 changed from ON to OFF 

I am using database to store item state values. When we are giving input (S1ON) from app side, the data stored into database. When I got data (S1OFF) from end device side, it will not stored the data into database. So how we can fix the this thing?

Thanks and Regards,

Amar.

g1velo commented 6 years ago

Hi Amar,

So when the power goes off (CAFE1001 devices), it should be changing from online to initializing state.

As currently designed the Framework has no way to know that your ( remote ) XBee devices has been powered off. So the Framework will keep it ONLINE as long as someone ( the handler ) tells him to put it offline using

updateStatus(ThingStatus.ONLINE);

updateStatus(ThingStatus.OFFLINE);

you could/should use SNAVXbee2Handler startAutomaticRefresh(); methods to periodically check if your (remote) XBee device is alive or not and then use UpdateStatus to tell the Framework that the Thing Has a new status.

Regarding the other question :

I think that storing the data in the database should be the job of a persistence service outside of this binding. The binding job is to inform the framework and it looks to be done as per the log you sent.

Regards.