mirror of https://github.com/arendst/Tasmota.git
Add Zigbee command ``ZbConfig`` and configuration in Settings
This commit is contained in:
parent
ca6553cbfc
commit
9addde235a
|
@ -25,6 +25,7 @@
|
|||
- Add support for an iAQ sensor (#8107)
|
||||
- Add support for Seven Segment display using HT16K33 (#8116)
|
||||
- Add support for AS3935 Lightning Sensor by device111 (#8130)
|
||||
- Add Zigbee command ``ZbConfig`` and configuration in Settings
|
||||
|
||||
### 8.2.0.2 20200328
|
||||
|
||||
|
|
|
@ -522,6 +522,8 @@
|
|||
#define D_CMND_ZIGBEE_LIGHT "Light"
|
||||
#define D_JSON_ZIGBEE_LIGHT "Light"
|
||||
#define D_CMND_ZIGBEE_RESTORE "Restore"
|
||||
#define D_CMND_ZIGBEE_CONFIG "Config"
|
||||
#define D_JSON_ZIGBEE_CONFIG "Config"
|
||||
|
||||
// Commands xdrv_25_A4988_Stepper.ino
|
||||
#define D_CMND_MOTOR "MOTOR"
|
||||
|
|
|
@ -627,7 +627,6 @@
|
|||
#define USE_ZIGBEE_CHANNEL 11 // Zigbee Channel (11-26)
|
||||
#define USE_ZIGBEE_PRECFGKEY_L 0x0F0D0B0907050301L // note: changing requires to re-pair all devices
|
||||
#define USE_ZIGBEE_PRECFGKEY_H 0x0D0C0A0806040200L // note: changing requires to re-pair all devices
|
||||
#define USE_ZIGBEE_PERMIT_JOIN false // don't allow joining by default
|
||||
#define USE_ZIGBEE_COALESCE_ATTR_TIMER 350 // timer to coalesce attribute values (in ms)
|
||||
|
||||
// -- Other sensors/drivers -----------------------
|
||||
|
|
|
@ -1332,6 +1332,7 @@ void SettingsDelta(void)
|
|||
}
|
||||
if (Settings.version < 0x08020003) {
|
||||
SettingsUpdateText(SET_TEMPLATE_NAME, Settings.user_template_name);
|
||||
Settings.zb_channel = 0; // set channel to zero to force reinit of zigbee parameters
|
||||
}
|
||||
#endif // ESP8266
|
||||
|
||||
|
|
|
@ -148,6 +148,9 @@ SBuffer *zigbee_buffer = nullptr;
|
|||
#define Z_B7(a) (uint8_t)( ((a) >> 56) & 0xFF )
|
||||
// Macro to define message to send and receive
|
||||
#define ZBM(n, x...) const uint8_t n[] PROGMEM = { x };
|
||||
// For commands that need to be changed with configuration, ZBR stores in RAM, and ZBW write new values
|
||||
#define ZBR(n, x...) uint8_t n[] = { x }; // same but in RAM to be modified
|
||||
#define ZBW(n, x...) { const uint8_t n##t[] = { x }; memcpy(n, n##t, sizeof(n)); } // re-write content in RAM
|
||||
|
||||
#define USE_ZIGBEE_CHANNEL_MASK (1 << (USE_ZIGBEE_CHANNEL))
|
||||
|
||||
|
@ -165,24 +168,24 @@ ZBM(ZBR_ZNPHC, Z_SRSP | Z_SYS, SYS_OSAL_NV_READ, Z_SUCCESS, 0x01 /* len */, 0x55
|
|||
// If not set, the response is 61-08-02-00 = Z_SRSP | Z_SYS, SYS_OSAL_NV_READ, Z_INVALIDPARAMETER, 0x00 /* len */
|
||||
|
||||
ZBM(ZBS_PAN, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_PANID ) // 260483
|
||||
ZBM(ZBR_PAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PANID, 0x02 /* len */,
|
||||
ZBR(ZBR_PAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PANID, 0x02 /* len */,
|
||||
Z_B0(USE_ZIGBEE_PANID), Z_B1(USE_ZIGBEE_PANID) ) // 6604008302xxxx
|
||||
|
||||
ZBM(ZBS_EXTPAN, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_EXTENDED_PAN_ID ) // 26042D
|
||||
ZBM(ZBR_EXTPAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_EXTENDED_PAN_ID,
|
||||
ZBR(ZBR_EXTPAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_EXTENDED_PAN_ID,
|
||||
0x08 /* len */,
|
||||
Z_B0(USE_ZIGBEE_EXTPANID), Z_B1(USE_ZIGBEE_EXTPANID), Z_B2(USE_ZIGBEE_EXTPANID), Z_B3(USE_ZIGBEE_EXTPANID),
|
||||
Z_B4(USE_ZIGBEE_EXTPANID), Z_B5(USE_ZIGBEE_EXTPANID), Z_B6(USE_ZIGBEE_EXTPANID), Z_B7(USE_ZIGBEE_EXTPANID),
|
||||
) // 6604002D08xxxxxxxxxxxxxxxx
|
||||
|
||||
ZBM(ZBS_CHANN, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_CHANLIST ) // 260484
|
||||
ZBM(ZBR_CHANN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_CHANLIST,
|
||||
ZBR(ZBR_CHANN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_CHANLIST,
|
||||
0x04 /* len */,
|
||||
Z_B0(USE_ZIGBEE_CHANNEL_MASK), Z_B1(USE_ZIGBEE_CHANNEL_MASK), Z_B2(USE_ZIGBEE_CHANNEL_MASK), Z_B3(USE_ZIGBEE_CHANNEL_MASK),
|
||||
) // 6604008404xxxxxxxx
|
||||
|
||||
ZBM(ZBS_PFGK, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_PRECFGKEY ) // 260462
|
||||
ZBM(ZBR_PFGK, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PRECFGKEY,
|
||||
ZBR(ZBR_PFGK, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PRECFGKEY,
|
||||
0x10 /* len */,
|
||||
Z_B0(USE_ZIGBEE_PRECFGKEY_L), Z_B1(USE_ZIGBEE_PRECFGKEY_L), Z_B2(USE_ZIGBEE_PRECFGKEY_L), Z_B3(USE_ZIGBEE_PRECFGKEY_L),
|
||||
Z_B4(USE_ZIGBEE_PRECFGKEY_L), Z_B5(USE_ZIGBEE_PRECFGKEY_L), Z_B6(USE_ZIGBEE_PRECFGKEY_L), Z_B7(USE_ZIGBEE_PRECFGKEY_L),
|
||||
|
@ -203,20 +206,20 @@ ZBM(ZBR_WNV_OK, Z_SRSP | Z_SYS, SYS_OSAL_NV_WRITE, Z_SUCCESS ) // 610900 - NV
|
|||
// Factory reset
|
||||
ZBM(ZBS_FACTRES, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_STARTUP_OPTION, 0x01 /* len */, 0x02 ) // 2605030102
|
||||
// Write PAN ID
|
||||
ZBM(ZBS_W_PAN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_PANID, 0x02 /* len */, Z_B0(USE_ZIGBEE_PANID), Z_B1(USE_ZIGBEE_PANID) ) // 26058302xxxx
|
||||
ZBR(ZBS_W_PAN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_PANID, 0x02 /* len */, Z_B0(USE_ZIGBEE_PANID), Z_B1(USE_ZIGBEE_PANID) ) // 26058302xxxx
|
||||
// Write EXT PAN ID
|
||||
ZBM(ZBS_W_EXTPAN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_EXTENDED_PAN_ID, 0x08 /* len */,
|
||||
ZBR(ZBS_W_EXTPAN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_EXTENDED_PAN_ID, 0x08 /* len */,
|
||||
Z_B0(USE_ZIGBEE_EXTPANID), Z_B1(USE_ZIGBEE_EXTPANID), Z_B2(USE_ZIGBEE_EXTPANID), Z_B3(USE_ZIGBEE_EXTPANID),
|
||||
Z_B4(USE_ZIGBEE_EXTPANID), Z_B5(USE_ZIGBEE_EXTPANID), Z_B6(USE_ZIGBEE_EXTPANID), Z_B7(USE_ZIGBEE_EXTPANID)
|
||||
) // 26052D086263151D004B1200
|
||||
// Write Channel ID
|
||||
ZBM(ZBS_W_CHANN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_CHANLIST, 0x04 /* len */,
|
||||
ZBR(ZBS_W_CHANN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_CHANLIST, 0x04 /* len */,
|
||||
Z_B0(USE_ZIGBEE_CHANNEL_MASK), Z_B1(USE_ZIGBEE_CHANNEL_MASK), Z_B2(USE_ZIGBEE_CHANNEL_MASK), Z_B3(USE_ZIGBEE_CHANNEL_MASK),
|
||||
/*0x00, 0x08, 0x00, 0x00*/ ) // 26058404xxxxxxxx
|
||||
// Write Logical Type = 00 = coordinator
|
||||
ZBM(ZBS_W_LOGTYP, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_LOGICAL_TYPE, 0x01 /* len */, 0x00 ) // 2605870100
|
||||
// Write precfgkey
|
||||
ZBM(ZBS_W_PFGK, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_PRECFGKEY,
|
||||
ZBR(ZBS_W_PFGK, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_PRECFGKEY,
|
||||
0x10 /* len */,
|
||||
Z_B0(USE_ZIGBEE_PRECFGKEY_L), Z_B1(USE_ZIGBEE_PRECFGKEY_L), Z_B2(USE_ZIGBEE_PRECFGKEY_L), Z_B3(USE_ZIGBEE_PRECFGKEY_L),
|
||||
Z_B4(USE_ZIGBEE_PRECFGKEY_L), Z_B5(USE_ZIGBEE_PRECFGKEY_L), Z_B6(USE_ZIGBEE_PRECFGKEY_L), Z_B7(USE_ZIGBEE_PRECFGKEY_L),
|
||||
|
@ -301,6 +304,53 @@ ZBM(ZBS_PERMITJOINREQ_CLOSE, Z_SREQ | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_REQ, 0x02 /* A
|
|||
ZBM(ZBR_PERMITJOINREQ, Z_SRSP | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_REQ, Z_SUCCESS) // 653600
|
||||
ZBM(ZBR_PERMITJOIN_AREQ_RSP, Z_AREQ | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_RSP, 0x00, 0x00 /* srcAddr*/, Z_SUCCESS ) // 45B6000000
|
||||
|
||||
// Update the relevant commands with Settings
|
||||
void Z_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) {
|
||||
uint32_t zb_channel_mask = (1 << zb_channel);
|
||||
|
||||
ZBW(ZBR_PAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PANID, 0x02 /* len */,
|
||||
Z_B0(zb_pan_id), Z_B1(zb_pan_id) ) // 6604008302xxxx
|
||||
|
||||
ZBW(ZBR_EXTPAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_EXTENDED_PAN_ID,
|
||||
0x08 /* len */,
|
||||
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),
|
||||
) // 6604002D08xxxxxxxxxxxxxxxx
|
||||
|
||||
ZBW(ZBR_CHANN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_CHANLIST,
|
||||
0x04 /* len */,
|
||||
Z_B0(zb_channel_mask), Z_B1(zb_channel_mask), Z_B2(zb_channel_mask), Z_B3(zb_channel_mask),
|
||||
) // 6604008404xxxxxxxx
|
||||
|
||||
ZBW(ZBR_PFGK, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PRECFGKEY,
|
||||
0x10 /* len */,
|
||||
Z_B0(zb_precfgkey_l), Z_B1(zb_precfgkey_l), Z_B2(zb_precfgkey_l), Z_B3(zb_precfgkey_l),
|
||||
Z_B4(zb_precfgkey_l), Z_B5(zb_precfgkey_l), Z_B6(zb_precfgkey_l), Z_B7(zb_precfgkey_l),
|
||||
Z_B0(zb_precfgkey_h), Z_B1(zb_precfgkey_h), Z_B2(zb_precfgkey_h), Z_B3(zb_precfgkey_h),
|
||||
Z_B4(zb_precfgkey_h), Z_B5(zb_precfgkey_h), Z_B6(zb_precfgkey_h), Z_B7(zb_precfgkey_h),
|
||||
/*0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
|
||||
0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0D*/ ) // 660400621001030507090B0D0F00020406080A0C0D
|
||||
|
||||
ZBW(ZBS_W_PAN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_PANID, 0x02 /* len */, Z_B0(zb_pan_id), Z_B1(zb_pan_id) ) // 26058302xxxx
|
||||
// Write EXT PAN ID
|
||||
ZBW(ZBS_W_EXTPAN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_EXTENDED_PAN_ID, 0x08 /* len */,
|
||||
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)
|
||||
) // 26052D086263151D004B1200
|
||||
// Write Channel ID
|
||||
ZBW(ZBS_W_CHANN, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_CHANLIST, 0x04 /* len */,
|
||||
Z_B0(zb_channel_mask), Z_B1(zb_channel_mask), Z_B2(zb_channel_mask), Z_B3(zb_channel_mask),
|
||||
/*0x00, 0x08, 0x00, 0x00*/ ) // 26058404xxxxxxxx
|
||||
// Write precfgkey
|
||||
ZBW(ZBS_W_PFGK, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_PRECFGKEY,
|
||||
0x10 /* len */,
|
||||
Z_B0(zb_precfgkey_l), Z_B1(zb_precfgkey_l), Z_B2(zb_precfgkey_l), Z_B3(zb_precfgkey_l),
|
||||
Z_B4(zb_precfgkey_l), Z_B5(zb_precfgkey_l), Z_B6(zb_precfgkey_l), Z_B7(zb_precfgkey_l),
|
||||
Z_B0(zb_precfgkey_h), Z_B1(zb_precfgkey_h), Z_B2(zb_precfgkey_h), Z_B3(zb_precfgkey_h),
|
||||
Z_B4(zb_precfgkey_h), Z_B5(zb_precfgkey_h), Z_B6(zb_precfgkey_h), Z_B7(zb_precfgkey_h),
|
||||
) // 2605621001030507090B0D0F00020406080A0C0D
|
||||
}
|
||||
|
||||
const char kCheckingDeviceConfiguration[] PROGMEM = D_LOG_ZIGBEE "checking device configuration";
|
||||
const char kConfigured[] PROGMEM = "Configured, starting coordinator";
|
||||
const char kStarted[] PROGMEM = "Started";
|
||||
|
|
|
@ -35,7 +35,8 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix
|
|||
D_CMND_ZIGBEE_PROBE "|" D_CMND_ZIGBEE_READ "|" D_CMND_ZIGBEEZNPRECEIVE "|"
|
||||
D_CMND_ZIGBEE_FORGET "|" D_CMND_ZIGBEE_SAVE "|" D_CMND_ZIGBEE_NAME "|"
|
||||
D_CMND_ZIGBEE_BIND "|" D_CMND_ZIGBEE_UNBIND "|" D_CMND_ZIGBEE_PING "|" D_CMND_ZIGBEE_MODELID "|"
|
||||
D_CMND_ZIGBEE_LIGHT "|" D_CMND_ZIGBEE_RESTORE "|" D_CMND_ZIGBEE_BIND_STATE
|
||||
D_CMND_ZIGBEE_LIGHT "|" D_CMND_ZIGBEE_RESTORE "|" D_CMND_ZIGBEE_BIND_STATE "|"
|
||||
D_CMND_ZIGBEE_CONFIG
|
||||
;
|
||||
|
||||
void (* const ZigbeeCommand[])(void) PROGMEM = {
|
||||
|
@ -45,6 +46,7 @@ void (* const ZigbeeCommand[])(void) PROGMEM = {
|
|||
&CmndZbForget, &CmndZbSave, &CmndZbName,
|
||||
&CmndZbBind, &CmndZbUnbind, &CmndZbPing, &CmndZbModelId,
|
||||
&CmndZbLight, &CmndZbRestore, &CmndZbBindState,
|
||||
&CmndZbConfig,
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -145,6 +147,19 @@ void ZigbeeInputLoop(void)
|
|||
// Initialize internal structures
|
||||
void ZigbeeInit(void)
|
||||
{
|
||||
// Check if settings if Flash are set
|
||||
if (0 == Settings.zb_channel) {
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Initializing Zigbee parameters from defaults"));
|
||||
Settings.zb_ext_panid = USE_ZIGBEE_EXTPANID;
|
||||
Settings.zb_precfgkey_l = USE_ZIGBEE_PRECFGKEY_L;
|
||||
Settings.zb_precfgkey_h = USE_ZIGBEE_PRECFGKEY_H;
|
||||
Settings.zb_pan_id = USE_ZIGBEE_PANID;
|
||||
Settings.zb_channel = USE_ZIGBEE_CHANNEL;
|
||||
Settings.zb_free_byte = 0;
|
||||
}
|
||||
// update commands with the current settings
|
||||
Z_UpdateConfig(Settings.zb_channel, Settings.zb_pan_id, Settings.zb_ext_panid, Settings.zb_precfgkey_l, Settings.zb_precfgkey_h);
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem1 = %d"), ESP.getFreeHeap());
|
||||
zigbee.active = false;
|
||||
if ((pin[GPIO_ZIGBEE_RX] < 99) && (pin[GPIO_ZIGBEE_TX] < 99)) {
|
||||
|
@ -1007,6 +1022,77 @@ void CmndZbStatus(void) {
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Command `ZbConfig`
|
||||
//
|
||||
void CmndZbConfig(void) {
|
||||
// ZbConfig
|
||||
// ZbConfig {"Channel":11,"PanID":"0x1A63","ExtPanID":"0xCCCCCCCCCCCCCCCC","KeyL":"0x0F0D0B0907050301L","KeyH":"0x0D0C0A0806040200L"}
|
||||
uint8_t zb_channel = Settings.zb_channel;
|
||||
uint16_t zb_pan_id = Settings.zb_pan_id;
|
||||
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;
|
||||
|
||||
// if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; }
|
||||
RemoveAllSpaces(XdrvMailbox.data);
|
||||
if (strlen(XdrvMailbox.data) > 0) {
|
||||
DynamicJsonBuffer jsonBuf;
|
||||
const JsonObject &json = jsonBuf.parseObject((const char*) XdrvMailbox.data);
|
||||
if (!json.success()) { ResponseCmndChar_P(PSTR(D_JSON_INVALID_JSON)); return; }
|
||||
|
||||
// Channel
|
||||
const JsonVariant &val_channel = getCaseInsensitive(json, PSTR("Channel"));
|
||||
if (nullptr != &val_channel) { zb_channel = strToUInt(val_channel); }
|
||||
// PanID
|
||||
const JsonVariant &val_pan_id = getCaseInsensitive(json, PSTR("PanID"));
|
||||
if (nullptr != &val_pan_id) { zb_pan_id = strToUInt(val_pan_id); }
|
||||
// ExtPanID
|
||||
const JsonVariant &val_ext_pan_id = getCaseInsensitive(json, PSTR("ExtPanID"));
|
||||
if (nullptr != &val_ext_pan_id) { zb_ext_panid = strtoull(val_ext_pan_id.as<const char*>(), nullptr, 0); }
|
||||
// KeyL
|
||||
const JsonVariant &val_key_l = getCaseInsensitive(json, PSTR("KeyL"));
|
||||
if (nullptr != &val_key_l) { zb_precfgkey_l = strtoull(val_key_l.as<const char*>(), nullptr, 0); }
|
||||
// KeyH
|
||||
const JsonVariant &val_key_h = getCaseInsensitive(json, PSTR("KeyH"));
|
||||
if (nullptr != &val_key_h) { zb_precfgkey_h = strtoull(val_key_h.as<const char*>(), nullptr, 0); }
|
||||
|
||||
// Check if a parameter was changed after all
|
||||
if ( (zb_channel != Settings.zb_channel) ||
|
||||
(zb_pan_id != Settings.zb_pan_id) ||
|
||||
(zb_ext_panid != Settings.zb_ext_panid) ||
|
||||
(zb_precfgkey_l != Settings.zb_precfgkey_l) ||
|
||||
(zb_precfgkey_h != Settings.zb_precfgkey_h) ) {
|
||||
Settings.zb_channel = zb_channel;
|
||||
Settings.zb_pan_id = zb_pan_id;
|
||||
Settings.zb_ext_panid = zb_ext_panid;
|
||||
Settings.zb_precfgkey_l = zb_precfgkey_l;
|
||||
Settings.zb_precfgkey_h = zb_precfgkey_h;
|
||||
restart_flag = 2; // save and reboot
|
||||
}
|
||||
}
|
||||
|
||||
// display the current or new configuration
|
||||
char hex_ext_panid[20] = "0x";
|
||||
Uint64toHex(zb_ext_panid, &hex_ext_panid[2], 64);
|
||||
char hex_precfgkey_l[20] = "0x";
|
||||
Uint64toHex(zb_precfgkey_l, &hex_precfgkey_l[2], 64);
|
||||
char hex_precfgkey_h[20] = "0x";
|
||||
Uint64toHex(zb_precfgkey_h, &hex_precfgkey_h[2], 64);
|
||||
|
||||
// {"ZbConfig":{"Channel":11,"PanID":"0x1A63","ExtPanID":"0xCCCCCCCCCCCCCCCC","KeyL":"0x0F0D0B0907050301L","KeyH":"0x0D0C0A0806040200L"}}
|
||||
Response_P(PSTR("{\"" D_PRFX_ZB D_JSON_ZIGBEE_CONFIG "\":{"
|
||||
"\"Channel\":%d"
|
||||
",\"PanID\":\"0x%04X\""
|
||||
",\"ExtPanID\":\"%s\""
|
||||
",\"KeyL\":\"%s\""
|
||||
",\"KeyH\":\"%s\""
|
||||
"}}"),
|
||||
zb_channel, zb_pan_id,
|
||||
hex_ext_panid,
|
||||
hex_precfgkey_l, hex_precfgkey_h);
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue