{t}")); // Insert multi column table
// WSContentSend_PD(PSTR("{s}Device 0x1234 | " D_BATT " 100%% | " D_LQI " 254{e}"));
// WSContentSend_PD(PSTR("{s}Device 0x1234 | " D_BATT " 100%% | " D_LQI " 254{e}"));
// WSContentSend_PD(PSTR("{s}Device 0x1234 | " D_BATT " 100%% | " D_LQI " 254{e}"), px_batt, px_lqi);
char sdevice[33];
char sbatt[20];
char slqi[20];
for (uint32_t i = 0; i < zigbee_num; i++) {
uint16_t shortaddr = zigbee_devices.devicesAt(i).shortaddr;
char *name = (char*)zigbee_devices.getFriendlyName(shortaddr);
if (nullptr == name) {
snprintf_P(sdevice, sizeof(sdevice), PSTR(D_DEVICE " 0x%04X"), shortaddr);
name = sdevice;
}
snprintf_P(slqi, sizeof(slqi), PSTR("-"));
uint8_t lqi = zigbee_devices.getLQI(shortaddr);
if (0xFF != lqi) {
snprintf_P(slqi, sizeof(slqi), PSTR("%d"), lqi);
}
snprintf_P(sbatt, sizeof(sbatt), PSTR(" "));
uint8_t bp = zigbee_devices.getBatteryPercent(shortaddr);
if (0xFF != bp) {
snprintf_P(sbatt, sizeof(sbatt), PSTR(D_BATT " %d%%"), bp);
}
if (!i) { // First row needs style info
WSContentSend_PD(PSTR("{s}%s | %s | " D_LQI " %s{e}"),
name, px_batt, sbatt, px_lqi, slqi);
} else { // Following rows don't need style info so reducing ajax package
WSContentSend_PD(PSTR("{s}%s{m}%s | " D_LQI " %s{e}"), name, sbatt, slqi);
}
}
WSContentSend_P(PSTR("{t}")); // Terminate current multi column table and open new table
// WSContentSend_P(PSTR("{e}")); // Terminate multi column table
#endif
}
}
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
bool Xdrv23(uint8_t function)
{
bool result = false;
if (zigbee.active) {
switch (function) {
case FUNC_EVERY_50_MSECOND:
if (!zigbee.init_phase) {
zigbee_devices.runTimer();
}
break;
case FUNC_LOOP:
#ifdef USE_ZIGBEE_EZSP
if (ZigbeeUploadXmodem()) {
return false;
}
#endif
if (ZigbeeSerial) {
ZigbeeInputLoop();
ZigbeeOutputLoop(); // send any outstanding data
}
if (zigbee.state_machine) {
ZigbeeStateMachine_Run();
}
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
ZigbeeShow(false);
break;
#endif // USE_WEBSERVER
case FUNC_PRE_INIT:
ZigbeeInit();
break;
case FUNC_COMMAND:
result = DecodeCommand(kZbCommands, ZigbeeCommand);
break;
}
}
return result;
}
#endif // USE_ZIGBEE
|