Hello Stefano
On 31.10.2014 16:35, Stefano Lenzi wrote:
My goal is to have the following result:
If I start from scratch (no previous run), I want the CC2530 to be
cleaned. If I start again later, I want it to keep the last state
(not clean internal state).
How do you implement this?
Actually, what you are asking is the most common scenario in a real
enviroment, but unfortunately there is no easy way to achieve that,
unless that you build a bundle that track the "first start" and then
it change the value of the configuration.
The only other way to achieve that is replace the property
it.cnr.isti.zigbee.driver.flush to something like
it.cnr.isti.zigbee.driver.bootstrap.mode that is an enumeation with
values like: ALWAYS_CLEAN, LAST_STATE, CLEAN_ONCE
Actually it would not be easy for the user understand when CLEAN_ONCE
is considered as the first run or not
Do you have any idea?
My current solution is as you suggested - track the start and change the
config later on. This works well as you can have a clean=true in the
properties loaded by PaxPropsLoader and the change you do later (setting
to clean=false) is persisted by Felix.ConfigAdmin in a separate file. On
next restart, if Felix.ConfigAdmin find a file with clean=false, no
clening is performed (that's what you want).
If you want to start clean, you remove the Felix.ConfigAdmin persistence
file and so the default properties are loaded instead (with clean=true).
The biggest problem with this is, that no event in the framework informs
us when the SimpleDriver changes Status, which is needed to trigger to
update clean to false.
We should think to either:
1. use EventAdmin to publish the status as an event, or
2. update the simple driver service properties with the status. (so you
can track Service.MODIFIED to get the info)
My current solution is a "polling" solution. In pseudo code it is:
Timer (every 5 seconds) {
get zigbee.api.Constants.MANAGED_SERVICE_PID Config from ConfigAdmin
if(null) return
get SimpleDriver status
if(not NetworkReady) getCurrentPan() // waits for network ready
get SimpleDriver status
if(NetworkReady)
props.put(NETWORK_FLUSH_KEY, false)
config.update()
cancel Timer // do the update at most once
} // else driver was closed, retry in 5 secs
}
NB: this code is in my application code and not part of ZB4O. We should
definitely think about introducing a solution in ZB4O.
Regards Philipp
_______________________________________________
Dev mailing list
[email protected]
http://zb4osgi.aaloa.org/mailman/listinfo/dev