Repository navigation
feat(identify): identify a device from the cloud and from its button - #12
Merged
Merged
Conversation
With several identical boards it was hard to tell which cloud device is which board. Every tedge-* image can now be matched both ways: - Cloud to device: `tedge identify [seconds]` (a shell subcommand, run through c8y_Command) blinks the status LED in the identify pattern for 30 s by default, at most 300 s, and returns at once. It is on the shell-diagnostics allow-list. - Device to cloud: two quick presses of sw0 send a zephyr_Identify event naming the hostname (at most one per 5 s), acknowledged on the LED. The device keeps serving. The new tedge-zephyr-events Smart Function maps te/device/*///e/* to Cumulocity events, which nothing did before. The sw0 watcher moves out of the provisioning hand-off into button.c, so it runs with either feature; the gesture classifier gains the identify count, and each gesture can be switched off. Also fixes tedge-zephyr leaving a failed shell command EXECUTING: the shell wraps shell_error() text in ANSI colour codes, and Cumulocity refuses a status message that carries them. Captured output is now stripped of escape sequences, and SmartREST quoting drops any other control character (line breaks stay inside the quoted field). Tested on an S3-DevKitC, a QT Py S3, an ESP32-C6 and an ESP32-CAM. Image +463 B / dram0 +32 B on the S3 modbus full build against main; release/size-baseline.json updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With several identical boards on a bench, the device list in Cumulocity doesn't say which board is which. This makes every
tedge-*image identifiable both ways.Changes
tedge identify [seconds], a new shell subcommand under the client'stedgeroot (lib/common/identify.c), blinks the status LED in the existing identify pattern (fast 5 Hz, white on an RGB LED). Default 30 s, capped at 300 s; it returns at once, so the operation succeeds immediately. The cloud runs it throughc8y_Command(Shell tab). It is added to the allow-list inextras/shell-diagnostics.conf, so it works wherever the cloud shell ships.sw0(BOOT) send azephyr_Identifyevent (Identify button pressed on <hostname>, at most one per 5 s) and flash the LED. The device keeps serving; the provisioning triple-press and erase hold are unchanged, and the build fails if the two press counts are equal.cumulocity/smart-functions/tedge-zephyr-events/: mapste/device/*///e/*to Cumulocity events. Nothing mapped device events on the MQTT Service before, so notedge-zephyrevent reached the tenant. Deployed to eu-latest.sw0refactor: GPIO/debounce move fromprov_handoff.ctobutton.c(CONFIG_APP_BUTTON), so the button works with either feature. The gesture classifier gets an identify count, and any gesture can be switched off; host tests cover the new cases.shell_error()left its operation EXECUTING forever, because the shell's ANSI colour codes ended up in the505status and Cumulocity rejected it ("contains invalid characters"). Captured output is now stripped of escape sequences (tedge_shell_clean_output()), and SmartREST quoting drops any remaining control character. Line breaks stay inside the quoted field.APP_IDENTIFY(default y withTEDGE),APP_IDENTIFY_DURATION_S(30),APP_IDENTIFY_PRESS_COUNT(2). No publictedge_*API change.device-identifyarchived (newdevice-identifyspec;tedge-diagnosticsandwifi-provisioningupdated).Cloud identify needs the cloud shell, so today it is on the S3-DevKitC and QT Py modbus/agent full images only. The button works on every
tedge-*image withsw0.Testing
check-independence.py.release/devices.ymlbuilds plus native_sim;release/size-baseline.jsonrewritten. Againstmainbuilt the same way: S3 modbus full + shell +463 B image / +32 B dram0; WROOM agent ota +336 B / +24 B.tedge identify,10,3600(→ 300) succeed in 1–3 s;0,soon,1 2andkernel uptime too many argsnow end FAILED with the reason (they stayed EXECUTING before the fix);helplists the command.c8y_Commandis not advertised, and atedge identifysent anyway fails with "no handler (511)".zephyr_Identifyevent on the right device within ~2 s; LED behaviour confirmed by eye on all four.🤖 Generated with Claude Code