Add NFC enable/disable support; update devices, Sonoff, and Tuya
This commit is contained in:
@@ -24,6 +24,7 @@ GET /nfc/status → {"initialized": bool, "c
|
||||
"pulse_ms": int}
|
||||
GET /nfc/config → {"auth_uid": str, "relay_num": int, "pulse_ms": int}
|
||||
POST /nfc/config?auth_uid=&relay=&pulse_ms= → {"status": "ok", ...}
|
||||
POST /nfc/enable?state=0|1 → {"status": "ok", "nfc_enabled": bool}
|
||||
|
||||
Webhook (board → server)
|
||||
------------------------
|
||||
@@ -213,3 +214,26 @@ class OlimexESP32C6EVBPn532Driver(BoardDriver):
|
||||
else:
|
||||
logger.warning("NFC config push failed for board '%s'", board.name)
|
||||
return result is not None
|
||||
|
||||
def set_nfc_enabled(self, board: "Board", enabled: bool) -> bool:
|
||||
"""Enable or disable the NFC/Mifare access-control module on the board.
|
||||
|
||||
When disabled the board stops polling the PN532, resets any active
|
||||
relay opened by a card, and persists the setting to NVS so it
|
||||
survives power cycles.
|
||||
|
||||
enabled: True = module on, False = module off.
|
||||
"""
|
||||
state = 1 if enabled else 0
|
||||
url = f"{board.base_url}/nfc/enable?state={state}"
|
||||
result = _post(url, _auth(board, "POST", url))
|
||||
if result is not None:
|
||||
logger.info(
|
||||
"NFC module on board '%s' set to: %s",
|
||||
board.name, "ENABLED" if enabled else "DISABLED",
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
"Failed to set NFC module state on board '%s'", board.name
|
||||
)
|
||||
return result is not None
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"register": "POST /register?callback_url={url}",
|
||||
"nfc_status": "GET /nfc/status",
|
||||
"nfc_config": "GET /nfc/config",
|
||||
"nfc_config_set": "POST /nfc/config?auth_uid={uid}&relay={n}&pulse_ms={ms}"
|
||||
"nfc_config_set": "POST /nfc/config?auth_uid={uid}&relay={n}&pulse_ms={ms}",
|
||||
"nfc_enable": "POST /nfc/enable?state={0|1}"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user