|
28 | 28 | import bellows.types.struct |
29 | 29 | import bellows.uart as uart |
30 | 30 | import bellows.zigbee.application |
31 | | -from bellows.zigbee.application import ControllerApplication |
| 31 | +from bellows.zigbee.application import DEFAULT_TX_POWER, ControllerApplication |
32 | 32 | import bellows.zigbee.device |
33 | 33 | from bellows.zigbee.device import EZSPEndpoint, EZSPGroupEndpoint |
34 | 34 | from bellows.zigbee.util import map_rssi_to_energy |
@@ -104,7 +104,7 @@ def _create_app_for_startup( |
104 | 104 | nwk_params = bellows.types.struct.EmberNetworkParameters( |
105 | 105 | extendedPanId=t.ExtendedPanId.convert("aa:bb:cc:dd:ee:ff:aa:bb"), |
106 | 106 | panId=t.EmberPanId(0x55AA), |
107 | | - radioTxPower=0, |
| 107 | + radioTxPower=8, |
108 | 108 | radioChannel=25, |
109 | 109 | joinMethod=t.EmberJoinMethod.USE_MAC_ASSOCIATION, |
110 | 110 | nwkManagerId=t.EmberNodeId(0x0000), |
@@ -2032,7 +2032,7 @@ def zigpy_backup() -> zigpy.backups.NetworkBackup: |
2032 | 2032 | channel=t.uint8_t(25), |
2033 | 2033 | channel_mask=t.Channels.ALL_CHANNELS, |
2034 | 2034 | security_level=t.uint8_t(1), |
2035 | | - tx_power=0, |
| 2035 | + tx_power=8, |
2036 | 2036 | network_key=zigpy.state.Key( |
2037 | 2037 | key=t.KeyData.convert( |
2038 | 2038 | "41:63:74:75:61:6c:4e:65:74:77:6f:72:6b:4b:65:79" |
@@ -2251,6 +2251,37 @@ async def test_write_network_info( |
2251 | 2251 | ] |
2252 | 2252 |
|
2253 | 2253 |
|
| 2254 | +async def test_write_network_info_with_none_tx_power( |
| 2255 | + app: ControllerApplication, |
| 2256 | + ieee: zigpy_t.EUI64, |
| 2257 | + zigpy_backup: zigpy.backups.NetworkBackup, |
| 2258 | +) -> None: |
| 2259 | + """Test that write_network_info uses DEFAULT_TX_POWER when tx_power is None.""" |
| 2260 | + network_info = zigpy_backup.network_info.replace(tx_power=None) |
| 2261 | + |
| 2262 | + with patch.object(app, "_reset"): |
| 2263 | + await app.write_network_info( |
| 2264 | + node_info=zigpy_backup.node_info, |
| 2265 | + network_info=network_info, |
| 2266 | + ) |
| 2267 | + |
| 2268 | + # Verify formNetwork was called with DEFAULT_TX_POWER instead of None |
| 2269 | + assert app._ezsp._protocol.formNetwork.mock_calls == [ |
| 2270 | + call( |
| 2271 | + parameters=t.EmberNetworkParameters( |
| 2272 | + panId=network_info.pan_id, |
| 2273 | + extendedPanId=network_info.extended_pan_id, |
| 2274 | + radioTxPower=DEFAULT_TX_POWER, |
| 2275 | + radioChannel=network_info.channel, |
| 2276 | + joinMethod=t.EmberJoinMethod.USE_MAC_ASSOCIATION, |
| 2277 | + nwkManagerId=t.EmberNodeId(0x0000), |
| 2278 | + nwkUpdateId=network_info.nwk_update_id, |
| 2279 | + channels=network_info.channel_mask, |
| 2280 | + ) |
| 2281 | + ) |
| 2282 | + ] |
| 2283 | + |
| 2284 | + |
2254 | 2285 | async def test_write_network_info_restores_route_table( |
2255 | 2286 | app: ControllerApplication, |
2256 | 2287 | ieee: zigpy_t.EUI64, |
|
0 commit comments