mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Added ZbReset 2
This commit is contained in:
parent
81cd344beb
commit
241843d384
@ -513,6 +513,7 @@
|
||||
#define D_CMND_ZIGBEE_STATUS "Status"
|
||||
#define D_CMND_ZIGBEE_RESET "Reset"
|
||||
#define D_JSON_ZIGBEE_CC2530 "CC2530"
|
||||
#define D_JSON_ZIGBEE_EZSP "EZSP"
|
||||
#define D_CMND_ZIGBEEZNPRECEIVE "ZNPReceive" // only for debug
|
||||
#define D_CMND_ZIGBEE_EZSP_RECEIVE "EZSPReceive" // only for debug
|
||||
#define D_CMND_ZIGBEE_EZSP_RECEIVE_RAW "EZSPReceiveRaw" // only for debug
|
||||
|
@ -615,7 +615,7 @@ struct {
|
||||
uint64_t zb_precfgkey_h; // F28
|
||||
uint16_t zb_pan_id; // F30
|
||||
uint8_t zb_channel; // F32
|
||||
uint8_t zb_txradio_dbm; // F33
|
||||
int8_t zb_txradio_dbm; // F33
|
||||
uint16_t pms_wake_interval; // F34
|
||||
uint8_t config_version; // F36
|
||||
uint8_t windmeter_pulses_x_rot; // F37
|
||||
|
@ -183,6 +183,7 @@ const char kStarted[] PROGMEM = "Started";
|
||||
const char kZigbeeStarted[] PROGMEM = D_LOG_ZIGBEE "Zigbee started";
|
||||
const char kResetting[] PROGMEM = "Resetting configuration";
|
||||
const char kResettingDevice[] PROGMEM = D_LOG_ZIGBEE "Resetting EZSP device";
|
||||
const char kReconfiguringDevice[] PROGMEM = D_LOG_ZIGBEE "Factory reset EZSP device";
|
||||
const char kZNP12[] PROGMEM = "Only ZNP 1.2 is currently supported";
|
||||
const char kEZ8[] PROGMEM = "Only EZSP protocol v8 is currently supported";
|
||||
const char kAbort[] PROGMEM = "Abort";
|
||||
@ -767,10 +768,10 @@ ZBM(ZBR_GET_KEY_NWK, EZSP_getKey, 0x00 /*high*/, 0x00 /*status*/) // 6A00
|
||||
//
|
||||
uint64_t ezsp_key_low, ezsp_key_high;
|
||||
|
||||
void EZ_UpdateConfig(uint8_t zb_channel, uint16_t zb_pan_id, uint64_t zb_ext_panid, uint64_t zb_precfgkey_l, uint64_t zb_precfgkey_h, uint8_t zb_txradio_dbm) {
|
||||
uint8_t txradio = zb_txradio_dbm;
|
||||
void EZ_UpdateConfig(uint8_t zb_channel, uint16_t zb_pan_id, uint64_t zb_ext_panid, uint64_t zb_precfgkey_l, uint64_t zb_precfgkey_h, int8_t zb_txradio_dbm) {
|
||||
int8_t txradio = zb_txradio_dbm;
|
||||
// restrict txradio to acceptable range, and use default otherwise
|
||||
if (txradio == 0) { txradio = USE_ZIGBEE_TXRADIO_DBM; }
|
||||
if (txradio < 0) { txradio = USE_ZIGBEE_TXRADIO_DBM; }
|
||||
if (txradio > 20) { txradio = USE_ZIGBEE_TXRADIO_DBM; }
|
||||
ezsp_key_low = zb_precfgkey_l;
|
||||
ezsp_key_high = zb_precfgkey_h;
|
||||
@ -792,7 +793,7 @@ void EZ_UpdateConfig(uint8_t zb_channel, uint16_t zb_pan_id, uint64_t zb_ext_pan
|
||||
Z_B0(zb_ext_panid), Z_B1(zb_ext_panid), Z_B2(zb_ext_panid), Z_B3(zb_ext_panid),
|
||||
Z_B4(zb_ext_panid), Z_B5(zb_ext_panid), Z_B6(zb_ext_panid), Z_B7(zb_ext_panid),
|
||||
Z_B0(zb_pan_id), Z_B1(zb_pan_id),
|
||||
txradio /*radioTxPower*/,
|
||||
(uint8_t)txradio /*radioTxPower*/,
|
||||
zb_channel /*channel*/,
|
||||
EMBER_USE_MAC_ASSOCIATION,
|
||||
0xFF,0xFF, /*nwkManagerId, unused*/
|
||||
@ -806,7 +807,7 @@ void EZ_UpdateConfig(uint8_t zb_channel, uint16_t zb_pan_id, uint64_t zb_ext_pan
|
||||
Z_B0(zb_ext_panid), Z_B1(zb_ext_panid), Z_B2(zb_ext_panid), Z_B3(zb_ext_panid),
|
||||
Z_B4(zb_ext_panid), Z_B5(zb_ext_panid), Z_B6(zb_ext_panid), Z_B7(zb_ext_panid),
|
||||
Z_B0(zb_pan_id), Z_B1(zb_pan_id),
|
||||
txradio /*radioTxPower*/,
|
||||
(uint8_t)txradio /*radioTxPower*/,
|
||||
zb_channel /*channel*/,
|
||||
) // 2800...
|
||||
}
|
||||
@ -814,14 +815,14 @@ void EZ_UpdateConfig(uint8_t zb_channel, uint16_t zb_pan_id, uint64_t zb_ext_pan
|
||||
static const Zigbee_Instruction zb_prog[] PROGMEM = {
|
||||
ZI_LABEL(0)
|
||||
ZI_NOOP()
|
||||
ZI_CALL(EZ_Set_ResetConfig, 0) // for the firt pass, don't do a reset_config
|
||||
// ZI_CALL(EZ_Set_ResetConfig, 0) // for the firt pass, don't do a reset_config
|
||||
ZI_LABEL(ZIGBEE_LABEL_RESTART)
|
||||
ZI_ON_ERROR_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
ZI_ON_TIMEOUT_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
ZI_ON_RECV_UNEXPECTED(&EZ_Recv_Default)
|
||||
ZI_WAIT(10500) // wait for 10 seconds for Tasmota to stabilize
|
||||
|
||||
// Hardware reset
|
||||
// Hardware reset
|
||||
ZI_LOG(LOG_LEVEL_INFO, kResettingDevice) // Log Debug: resetting EZSP device
|
||||
ZI_CALL(&EZ_Reset_Device, 0) // LOW = reset
|
||||
ZI_WAIT(100) // wait for .1 second
|
||||
@ -893,6 +894,7 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
|
||||
|
||||
ZI_LABEL(ZIGBEE_LABEL_CONFIGURE_EZSP)
|
||||
// Set back normal error handlers
|
||||
ZI_LOG(LOG_LEVEL_INFO, kReconfiguringDevice) // Log Debug: reconfiguring EZSP device
|
||||
ZI_ON_TIMEOUT_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
ZI_ON_ERROR_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
// set encryption keys
|
||||
|
@ -406,7 +406,7 @@ int32_t EZ_ReceiveCheckVersion(int32_t res, class SBuffer &buf) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool EZ_reset_config = false;
|
||||
bool EZ_reset_config = false;
|
||||
|
||||
// Set or clear reset_config
|
||||
int32_t EZ_Set_ResetConfig(uint8_t value) {
|
||||
|
@ -589,6 +589,7 @@ int32_t ZigbeeProcessInputEZSP(class SBuffer &buf) {
|
||||
case EZSP_setConcentrator: // 1000
|
||||
case EZSP_networkInit: // 1700
|
||||
case EZSP_stackStatusHandler: // 1900
|
||||
case EZSP_formNetwork: // 1E00
|
||||
case EZSP_permitJoining: // 2200
|
||||
case EZSP_getEui64: // 2600
|
||||
case EZSP_getNodeId: // 2700
|
||||
|
@ -84,6 +84,12 @@ void ZigbeeInit(void)
|
||||
Settings.zb_channel = USE_ZIGBEE_CHANNEL;
|
||||
Settings.zb_txradio_dbm = USE_ZIGBEE_TXRADIO_DBM;
|
||||
}
|
||||
|
||||
if (Settings.zb_txradio_dbm < 0) {
|
||||
Settings.zb_txradio_dbm = -Settings.zb_txradio_dbm;
|
||||
EZ_reset_config = true; // force reconfigure of EZSP
|
||||
SettingsSave(2);
|
||||
}
|
||||
}
|
||||
|
||||
// update commands with the current settings
|
||||
@ -116,11 +122,18 @@ void CmndZbReset(void) {
|
||||
ZigbeeZNPSend(ZIGBEE_FACTORY_RESET, sizeof(ZIGBEE_FACTORY_RESET));
|
||||
#endif // USE_ZIGBEE_ZNP
|
||||
eraseZigbeeDevices();
|
||||
case 2: // fall through
|
||||
Settings.zb_txradio_dbm = - abs(Settings.zb_txradio_dbm);
|
||||
restart_flag = 2;
|
||||
#ifdef USE_ZIGBEE_ZNP
|
||||
ResponseCmndChar_P(PSTR(D_JSON_ZIGBEE_CC2530 " " D_JSON_RESET_AND_RESTARTING));
|
||||
#endif // USE_ZIGBEE_ZNP
|
||||
#ifdef USE_ZIGBEE_EZSP
|
||||
ResponseCmndChar_P(PSTR(D_JSON_ZIGBEE_EZSP " " D_JSON_RESET_AND_RESTARTING));
|
||||
#endif // USE_ZIGBEE_EZSP
|
||||
break;
|
||||
default:
|
||||
ResponseCmndChar_P(PSTR(D_JSON_ONE_TO_RESET));
|
||||
ResponseCmndChar_P(PSTR("1 or 2 to reset"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1432,7 +1445,7 @@ void CmndZbConfig(void) {
|
||||
uint64_t zb_ext_panid = Settings.zb_ext_panid;
|
||||
uint64_t zb_precfgkey_l = Settings.zb_precfgkey_l;
|
||||
uint64_t zb_precfgkey_h = Settings.zb_precfgkey_h;
|
||||
uint8_t zb_txradio_dbm = Settings.zb_txradio_dbm;
|
||||
int8_t zb_txradio_dbm = Settings.zb_txradio_dbm;
|
||||
|
||||
// if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; }
|
||||
RemoveAllSpaces(XdrvMailbox.data);
|
||||
@ -1447,7 +1460,7 @@ void CmndZbConfig(void) {
|
||||
zb_ext_panid = root.getULong(PSTR("ExtPanID"), zb_ext_panid);
|
||||
zb_precfgkey_l = root.getULong(PSTR("KeyL"), zb_precfgkey_l);
|
||||
zb_precfgkey_h = root.getULong(PSTR("KeyH"), zb_precfgkey_h);
|
||||
zb_txradio_dbm = root.getUInt(PSTR("TxRadio"), zb_txradio_dbm);
|
||||
zb_txradio_dbm = root.getInt(PSTR("TxRadio"), zb_txradio_dbm);
|
||||
|
||||
if (zb_channel < 11) { zb_channel = 11; }
|
||||
if (zb_channel > 26) { zb_channel = 26; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user