You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
I'd like to modify the console to support standard gnu/posix options like in the below example.
In order to support this I need to slightly modify the ZigBeeConsole, ZigBeeApi and ZigBeeNetworkManagerImpl to allow for more parameters to be passed to the constructors.
In order to avoid constructors with so many parameters I was thinking to the Builder pattern.
Do you think this is worthwhile to add?
Cheers,
Cristiano
usage: java -jar zigbee4java-serialPort.jar [OPTION]... DEVICE
-c,--channel <channel> add the specified channel (11-26)
to the list of channels scanned on
establishing the network. The
default channel list is 11, 14,
15, 19, 20, 24, 25. This option
may be repeated multiple times.
-d,--distribute-network-key distribute the network key in
clear to devices joining the
network. If not specified the
default behaviour is to not
distribute the network key.
-e,--epid <epid> the extended PAN ID (EPID) in
hexadecimal format
(0-0xfffffffffffffffe). The
default value is 0 which means
that stack will set the EPID to
the value of the IEEE address.
-k,--network-key <network-key> the network key in hexadecimal
format (1-0xfffffffffffffffe). If
not set the dongle will use a
preconfigured value.
-m,--discovery-mode <discovery-mode> the method used to discover
devices. Valid values are
`announce', `addressing', `lqi'
and `all' as a shortcut for the
first tree. This option can be
repeated multiple times.
-p,--panid <panid> the PAN ID in hexadecimal format
(0-0xffff). The default PAN ID is
0xffff which means that stack will
generate a random, nonconflicting
PAN ID.
-r,--reset-network start with a clean network state
and configuration. If not
specified the network will resume
using the last state and
configuration.
-s,--no-security disable security.
The text was updated successfully, but these errors were encountered:
I'm wondering the same thing. I've started with the builder but I don't like it. The above options and possibly more need to be passed from the outermost class to the innermost one. Some options are consumed by classes in between. With Builder we need to create a parallel hierarchy of builders one for every class so that adding a new option might require to change every builder in the hierarchy. A dictionary might be simpler especially if the above configuration is read from a file. However, simply passing the dictionary to every constructor in the hierarchy is not that safe. You don't know who is using what configuration.
I've spent more time on this... Why don't we move the instantiation of the ZigBeeApi outside of ZigBeeConsole and pass it a reference to the instance?
Pros
we remove one layer to the hierarchy (less parameters to pass through)
given that the ZigBeeApi instance is not owned by the ZigBeeConsole, we can enhance the application adding logic that otherwise would require modifying the ZigBeeConsole class. The ZigBeeConsole class is just a useful and pluggable "View" on the ZigBee network.
Cons
The ZigBeeApi instantiation code must be duplicated in the javase and android console. However this code is just twenty lines or so.
I'd like to modify the console to support standard gnu/posix options like in the below example.
In order to support this I need to slightly modify the ZigBeeConsole, ZigBeeApi and ZigBeeNetworkManagerImpl to allow for more parameters to be passed to the constructors.
In order to avoid constructors with so many parameters I was thinking to the Builder pattern.
Do you think this is worthwhile to add?
Cheers,
Cristiano
The text was updated successfully, but these errors were encountered: