Skip to content

Commit

Permalink
0.16.1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminiuga authored May 3, 2020
2 parents 68fba66 + 6749d02 commit 210f9c0
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 74 deletions.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,38 @@ $ bellows zcl 00:0d:6f:00:05:7d:2d:34 1 1026 read_attribute 0
0=1806
```

## Port configuration
- To configure usb port path for your EZSP serial device, just specify the TTY (serial com) port, example : `/dev/ttyUSB1`
- It is worth noting that EM3588 devices that have an embedded USB core will likely work with any baud rate, where dongles using external USB interface (eg CP2102 used with an EM3581) will likely require a specific baud rate. Currently there are two main NCP images - one that supports hardware flow control with a baud rate of 115200, and one that supports software flow control with a rate of 57600.

## Testing new releases

Testing a new release of the bellows library before it is released in Home Assistant.

If you are using Supervised Home Assistant (formerly known as the Hassio/Hass.io distro):
- Add https://github.com/home-assistant/hassio-addons-development as "add-on" repository
- Install "Custom deps deployment" addon
- Update config like:
```
pypi:
- bellows==0.16.0
apk: []
```
where 0.16.0 is the new version
- Start the addon

If you are instead using some custom python installation of Home Assistant then do this:
- Activate your python virtual env
- Update package with ``pip``
```
pip install bellows==0.16.0
## Release packages available via PyPI
Packages of tagged versions are also released via PyPI
New packages of tagged versions are also released via the "bellows" project on PyPI
- https://pypi.org/project/bellows/
Older packages of tagged versions are still available on the "bellows-homeassistant" project on PyPI
- https://pypi.org/project/bellows-homeassistant/
## Reference documentation
Expand All @@ -70,6 +99,8 @@ Packages of tagged versions are also released via PyPI
https://www.silabs.com/Support%20Documents/TechnicalDocs/UG101.pdf
* EZSP Reference Guide:
http://www.silabs.com/Support%20Documents/TechnicalDocs/UG100-EZSPReferenceGuide.pdf
* EZSP UART Host Interfacing Reference Guide: https://www.silabs.com/documents/public/application-notes/an706-ezsp-uart-host-interfacing-guide.pdf
* Silicon Labs forum https://www.silabs.com/community/wireless/zigbee-and-thread/forum
## How to contribute
Expand Down
2 changes: 1 addition & 1 deletion bellows/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAJOR_VERSION = 0
MINOR_VERSION = 16
PATCH_VERSION = "0"
PATCH_VERSION = "1"
__short_version__ = "{}.{}".format(MAJOR_VERSION, MINOR_VERSION)
__version__ = "{}.{}".format(__short_version__, PATCH_VERSION)
26 changes: 17 additions & 9 deletions bellows/cli/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,27 @@
@opts.channel
@opts.extended_pan
@opts.pan
@opts.network_key
@opts.network_key_seq
@click.pass_context
def form(ctx, database, channel, pan_id, extended_pan_id):
def form(ctx, database, channel, pan_id, extended_pan_id, network_key, network_key_seq):
"""Form a new ZigBee network"""
ctx.obj["database_file"] = database
extra_config = {
zigpy.config.CONF_NWK: {
zigpy.config.CONF_NWK_CHANNEL: channel,
zigpy.config.CONF_NWK_EXTENDED_PAN_ID: extended_pan_id,
zigpy.config.CONF_NWK_PAN_ID: pan_id,
zigpy.config.CONF_NWK_KEY: network_key,
zigpy.config.CONF_NWK_KEY_SEQ: network_key_seq,
}
}

async def inner(ctx):
app = ctx.obj["app"]
await app.initialize()
await app.form_network(channel, pan_id, extended_pan_id)
await app.startup(auto_form=True)

return util.app(inner, app_startup=False)(ctx)
return util.app(inner, app_startup=False, extra_config=extra_config)(ctx)


@main.command()
Expand Down Expand Up @@ -302,15 +312,13 @@ async def write_attribute(ctx, attribute, value, manufacturer):

@zcl.command()
@click.pass_context
def commands(ctx):
database = ctx.obj["database_file"]
@util.app
async def commands(ctx):
app = ctx.obj["app"]
node = ctx.obj["node"]
endpoint_id = ctx.obj["endpoint"]
cluster_id = ctx.obj["cluster"]

ezsp = bellows.ezsp.EZSP()
app = bellows.zigbee.application.ControllerApplication(ezsp, database)

dev, endpoint, cluster = util.get_in_cluster(app, node, endpoint_id, cluster_id)
if cluster is None:
return
Expand Down
2 changes: 1 addition & 1 deletion bellows/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@click.group()
@click_log.simple_verbosity_option(logging.getLogger())
@click_log.simple_verbosity_option(logging.getLogger(), default="WARNING")
@opts.device
@opts.baudrate
@click.pass_context
Expand Down
28 changes: 28 additions & 0 deletions bellows/cli/ncp.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,31 @@ async def info(ctx):
click.echo(v)

s.close()


@main.command()
@click.pass_context
@util.background
async def bootloader(ctx):
"""Start bootloader"""

ezsp = await util.setup(ctx.obj["device"], ctx.obj["baudrate"], configure=False)
version, plat, micro, phy = await ezsp.getStandaloneBootloaderVersionPlatMicroPhy()
if version == 0xFFFF:
click.echo("No boot loader installed")
ezsp.close()
return

click.echo(
(
f"bootloader version: 0x{version:04x}, nodePlat: 0x{plat:02x}, "
f"nodeMicro: 0x{micro:02x}, nodePhy: 0x{phy:02x}"
)
)

res = await ezsp.launchStandaloneBootloader(0x00)
if res[0] != t.EmberStatus.SUCCESS:
click.echo(f"Couldn't launch bootloader: {res[0]}")
else:
click.echo("bootloader launched successfully")
ezsp.close()
16 changes: 16 additions & 0 deletions bellows/cli/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,19 @@
default=None,
help="send a manufacturer specific command",
)

network_key = click.option(
"-N",
"--network-key",
type=util.CSVParamType(0, 255),
default=None,
help="16 bytes of network key, lsb first",
)

network_key_seq = click.option(
"-s",
"--network-key-seq",
type=click.IntRange(0, 255),
default=0,
help="Network key sequence number",
)
28 changes: 14 additions & 14 deletions bellows/cli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,27 @@ def inner(*args, **kwargs):
return inner


def app(f, app_startup=True):
def app(f, app_startup=True, extra_config=None):
database_file = None
application = None

async def async_inner(ctx, *args, **kwargs):
nonlocal database_file
nonlocal application
database_file = ctx.obj["database_file"]
application = await setup_application(
ctx.obj["device"], ctx.obj["baudrate"], database_file, startup=app_startup
)
app_config = {
config.CONF_DEVICE: {
config.CONF_DEVICE_PATH: ctx.obj["device"],
config.CONF_DEVICE_BAUDRATE: ctx.obj["baudrate"],
},
zigpy_conf.CONF_DATABASE: ctx.obj["database_file"],
}
if extra_config:
app_config.update(extra_config)
application = await setup_application(app_config, startup=app_startup)
ctx.obj["app"] = application
await f(ctx, *args, **kwargs)
await asyncio.sleep(0.5)
await application.shutdown()

def shutdown():
try:
Expand Down Expand Up @@ -124,17 +131,10 @@ async def cfg(config_id, value):
return s


async def setup_application(dev, baudrate, database_file, startup=True):
app_config = {
config.CONF_DEVICE: {
config.CONF_DEVICE_PATH: dev,
config.CONF_DEVICE_BAUDRATE: baudrate,
},
zigpy_conf.CONF_DATABASE: database_file,
}
async def setup_application(app_config, startup=True):
app_config = bellows.zigbee.application.ControllerApplication.SCHEMA(app_config)
app = await bellows.zigbee.application.ControllerApplication.new(
app_config, startup
app_config, start_radio=startup
)
return app

Expand Down
2 changes: 1 addition & 1 deletion bellows/config/ezsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
# Deprecated
# The amount of time a trust center will store a transient key
# with which a device can use to join the network
vol.Optional(c.CONFIG_TRANSIENT_KEY_TIMEOUT_S.name, default=180): vol.All(
vol.Optional(c.CONFIG_TRANSIENT_KEY_TIMEOUT_S.name): vol.All(
int, vol.Range(min=0, max=65535)
),
#
Expand Down
4 changes: 3 additions & 1 deletion bellows/ezsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ async def version(self):
self._ezsp_version = ver
await self._command("version", ver)
LOGGER.debug("Switched to EZSP protocol version %d", self.ezsp_version)
LOGGER.info("EZSP Stack Type: %s, Stack Version: %s", stack_type, stack_version)
LOGGER.debug(
"EZSP Stack Type: %s, Stack Version: %s", stack_type, stack_version
)

def close(self):
self.stop_ezsp()
Expand Down
4 changes: 4 additions & 0 deletions bellows/types/named.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,3 +1664,7 @@ class EmberNetworkInitBitmask(basic.uint16_t):
# Save parent info (node ID and EUI64) in a token during joining/rejoin,
# and restore on reboot.
NETWORK_INIT_PARENT_INFO_IN_TOKEN = 0x0001


class EmberKeyData(basic.fixed_list(16, basic.uint8_t)):
"""A 128-bit key. """
22 changes: 7 additions & 15 deletions bellows/types/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,6 @@ class EmberMulticastTableEntry(EzspStruct):
]


class EmberKeyData(EzspStruct):
# A 128-bit key.
_fields = [
# The key data.
("contents", basic.fixed_list(16, basic.uint8_t))
]


class EmberCertificateData(EzspStruct):
# The implicit certificate used in CBKE.
_fields = [
Expand Down Expand Up @@ -176,7 +168,7 @@ class EmberTransientKeyData(EzspStruct):
# The IEEE address paired with the transient link key.
("eui64", named.EmberEUI64),
# The key data structure matching the transient key.
("keyData", EmberKeyData),
("keyData", named.EmberKeyData),
# The incoming frame counter associated with this key.
("incomingFrameCounter", basic.uint32_t),
# The number of milliseconds remaining before the key
Expand Down Expand Up @@ -314,12 +306,12 @@ class EmberInitialSecurityState(EzspStruct):
# joining the network. The security bitmask must be set with the
# HAVE_PRECONFIGURED_KEY bit to indicate that the key contains valid
# data.
("preconfiguredKey", EmberKeyData),
("preconfiguredKey", named.EmberKeyData),
# The Network Key that should be used by the Trust Center when it forms
# the network, or the Network Key currently in use by a joined device.
# The security bitmask must be set with HAVE_NETWORK_KEY to indicate
# that the key contains valid data.
("networkKey", EmberKeyData),
("networkKey", named.EmberKeyData),
# The sequence number associated with the network key. This is only
# valid if the HAVE_NETWORK_KEY has been set in the security bitmask.
("networkKeySequenceNumber", basic.uint8_t),
Expand Down Expand Up @@ -354,7 +346,7 @@ class EmberKeyStruct(EzspStruct):
# The type of the key.
("type", named.EmberKeyType),
# The actual key data.
("key", EmberKeyData),
("key", named.EmberKeyData),
# The outgoing frame counter associated with the key.
("outgoingFrameCounter", basic.uint32_t),
# The frame counter of the partner device associated with the key.
Expand Down Expand Up @@ -419,10 +411,10 @@ class EmberZllInitialSecurityState(EzspStruct):
# The key encryption algorithm advertised by the application.
("keyIndex", named.EmberZllKeyIndex),
# The encryption key for use by algorithms that require it.
("encryptionKey", EmberKeyData),
("encryptionKey", named.EmberKeyData),
# The pre-configured link key used during classical ZigBee
# commissioning.
("preconfiguredKey", EmberKeyData),
("preconfiguredKey", named.EmberKeyData),
]


Expand Down Expand Up @@ -531,7 +523,7 @@ class EmberRf4cePairingTableEntry(EzspStruct):
# The internal representation of an RF4CE pairing table entry.
_fields = [
# The link key to be used to secure this pairing link.
("securityLinkKey", EmberKeyData),
("securityLinkKey", named.EmberKeyData),
# The IEEE address of the destination device.
("destLongId", named.EmberEUI64),
# The frame counter last received from the recipient node.
Expand Down
Loading

0 comments on commit 210f9c0

Please sign in to comment.