Skip to content

Feature/music play demo - #12

Merged
heshaoqiong-tuya merged 1 commit into
masterfrom
feature/music-play-demo
Aug 11, 2026
Merged

Feature/music play demo#12
heshaoqiong-tuya merged 1 commit into
masterfrom
feature/music-play-demo

Conversation

@sedawwk

@sedawwk sedawwk commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Adds music_play_demo.c: it sends a text query that triggers the server's
music skill, parses the returned audio metadata, prints it, and downloads
the trial clip. Registers the tai_music_play_demo target in the POSIX
CMakeLists, and adds the user guide at docs-site/docs/tutorials/
music-play.md with the copyright notes on trial-clip limits and NetEase
Cloud Music integration.

Three things worth copying if you build on this demo, since example code
tends to be lifted into firmware verbatim:

  • The trial clip is fetched with fork + execvp, never through a shell.
    The URL comes from the server, so passing it as one argv element is
    what makes $(...) in a URL inert; only http(s) schemes are accepted.

  • Credentials from argv are length-checked before they reach
    iot_client_config_t's char[32] fields, which take no length argument
    and would otherwise be overflowed by a long value.

  • "code" is read inside the SKILL envelope's data object. Resolved
    against the whole document, the common
    {"code":0,...,"data":{"code":"music"}} shape matches the outer status
    code first, and the music response is dropped without a word.
    try_parse_music() also distinguishes "not a music response" from "a
    music response whose payload could not be read", so the exit status
    can report the difference.

The metadata box pads by display column rather than by byte: the song
titles this demo exists to show are Chinese, and 开不了口 is 12 bytes but
8 columns, so "%-31s" would wreck the border.

Builds clean under -Wall -Wextra -Wshadow, and verified end to end
against the live service: the query returns a SKILL response, the
metadata parses, and the clip downloads as a valid MP3.

@heshaoqiong-tuya
heshaoqiong-tuya force-pushed the feature/music-play-demo branch 2 times, most recently from efd244f to 096f2fe Compare August 10, 2026 07:49
Adds music_play_demo.c: it sends a text query that triggers the server's
music skill, parses the returned audio metadata, prints it, and downloads
the trial clip. Registers the tai_music_play_demo target in the POSIX
CMakeLists, and adds the user guide at docs-site/docs/tutorials/
music-play.md with the copyright notes on trial-clip limits and NetEase
Cloud Music integration.

Three things worth copying if you build on this demo, since example code
tends to be lifted into firmware verbatim:

- The trial clip is fetched with fork + execvp, never through a shell.
  The URL comes from the server, so passing it as one argv element is
  what makes $(...) in a URL inert; only http(s) schemes are accepted.

- Credentials from argv are length-checked before they reach
  iot_client_config_t's char[32] fields, which take no length argument
  and would otherwise be overflowed by a long value.

- "code" is read inside the SKILL envelope's data object. Resolved
  against the whole document, the common
  {"code":0,...,"data":{"code":"music"}} shape matches the outer status
  code first, and the music response is dropped without a word.
  try_parse_music() also distinguishes "not a music response" from "a
  music response whose payload could not be read", so the exit status
  can report the difference.

The metadata box pads by display column rather than by byte: the song
titles this demo exists to show are Chinese, and 开不了口 is 12 bytes but
8 columns, so "%-31s" would wreck the border.

Builds clean under -Wall -Wextra -Wshadow, and verified end to end
against the live service: the query returns a SKILL response, the
metadata parses, and the clip downloads as a valid MP3.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@heshaoqiong-tuya
heshaoqiong-tuya force-pushed the feature/music-play-demo branch from 096f2fe to 89c23e2 Compare August 11, 2026 02:15
@heshaoqiong-tuya
heshaoqiong-tuya merged commit 656b0a9 into master Aug 11, 2026
8 checks passed
@heshaoqiong-tuya
heshaoqiong-tuya deleted the feature/music-play-demo branch August 11, 2026 02:28
heshaoqiong-tuya added a commit that referenced this pull request Aug 27, 2026
Applies convention 6 to the section that motivated it: 619 lines down to 139.

The entries were commit bodies pasted under a heading — motivation, rejected
alternatives, test counts and internal reasoning, several running past fifty
lines for one change. All of that is still in the commits, which is where a
reader who wants it looks. What is left here is what a reader acts on: the
symbol, the behaviour change, the migration step.

Most entries now carry a PR number. They could not be recovered from git
history because these landed as squash or rebase merges, which leave no
"Merge pull request #N" commit; the closed-PR list on GitHub has them, and each
attribution was confirmed against that PR's own commit list rather than
inferred from a branch name. Four entries carry none because they were pushed
straight to master with no PR to cite.

Two merged PRs turned out to have no entry at all, and are added:

- #21, the APP-confirmed OTA (protocol 15) callback — a public callback on both
  config structs.
- #23, the sizable ATOP response buffer — user-visible, since the sizes are set
  with -D.

Three defects the rewrite surfaced, all from entries being appended rather than
amended as the work continued:

- Added and Fixed each appeared twice, and the second Fixed held Added-type
  material (the generic ATOP call). Merged into one of each, in the order Keep
  a Changelog defines, since release notes are generated from those headings.
- The auto-connect default was documented both ways: Changed said it is now on
  by default, while the connect/disconnect entry still said "The default stays
  false". The later change never revisited the earlier entry.
- The music-play demo was credited to #15, which is the region-wire-codes fix.
  It is #12.

Two entries are dropped rather than shortened: the mqtt_abort_connect()
extraction and a test-only over-read fix. Convention 2 scopes the CHANGELOG to
what SDK users see, and neither is visible outside the repo.

Rebased onto five commits that landed meanwhile, whose entries are folded in at
the new length: the session-token-reason API (#29), the reset scope (#28), the
POSIX binary renaming, and audio_chat_demo's header-shadowing and device-VAD
fixes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@heshaoqiong-tuya heshaoqiong-tuya mentioned this pull request Aug 27, 2026
heshaoqiong-tuya added a commit that referenced this pull request Aug 27, 2026
Applies convention 6 to the section that motivated it: 619 lines down to 139.

The entries were commit bodies pasted under a heading — motivation, rejected
alternatives, test counts and internal reasoning, several running past fifty
lines for one change. All of that is still in the commits, which is where a
reader who wants it looks. What is left here is what a reader acts on: the
symbol, the behaviour change, the migration step.

Most entries now carry a PR number. They could not be recovered from git
history because these landed as squash or rebase merges, which leave no
"Merge pull request #N" commit; the closed-PR list on GitHub has them, and each
attribution was confirmed against that PR's own commit list rather than
inferred from a branch name. Four entries carry none because they were pushed
straight to master with no PR to cite.

Two merged PRs turned out to have no entry at all, and are added:

- #21, the APP-confirmed OTA (protocol 15) callback — a public callback on both
  config structs.
- #23, the sizable ATOP response buffer — user-visible, since the sizes are set
  with -D.

Three defects the rewrite surfaced, all from entries being appended rather than
amended as the work continued:

- Added and Fixed each appeared twice, and the second Fixed held Added-type
  material (the generic ATOP call). Merged into one of each, in the order Keep
  a Changelog defines, since release notes are generated from those headings.
- The auto-connect default was documented both ways: Changed said it is now on
  by default, while the connect/disconnect entry still said "The default stays
  false". The later change never revisited the earlier entry.
- The music-play demo was credited to #15, which is the region-wire-codes fix.
  It is #12.

Two entries are dropped rather than shortened: the mqtt_abort_connect()
extraction and a test-only over-read fix. Convention 2 scopes the CHANGELOG to
what SDK users see, and neither is visible outside the repo.

Rebased onto five commits that landed meanwhile, whose entries are folded in at
the new length: the session-token-reason API (#29), the reset scope (#28), the
POSIX binary renaming, and audio_chat_demo's header-shadowing and device-VAD
fixes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
heshaoqiong-tuya added a commit that referenced this pull request Aug 27, 2026
Applies convention 6 to the section that motivated it: 619 lines down to 139.

The entries were commit bodies pasted under a heading — motivation, rejected
alternatives, test counts and internal reasoning, several running past fifty
lines for one change. All of that is still in the commits, which is where a
reader who wants it looks. What is left here is what a reader acts on: the
symbol, the behaviour change, the migration step.

Most entries now carry a PR number. They could not be recovered from git
history because these landed as squash or rebase merges, which leave no
"Merge pull request #N" commit; the closed-PR list on GitHub has them, and each
attribution was confirmed against that PR's own commit list rather than
inferred from a branch name. Four entries carry none because they were pushed
straight to master with no PR to cite.

Two merged PRs turned out to have no entry at all, and are added:

- #21, the APP-confirmed OTA (protocol 15) callback — a public callback on both
  config structs.
- #23, the sizable ATOP response buffer — user-visible, since the sizes are set
  with -D.

Three defects the rewrite surfaced, all from entries being appended rather than
amended as the work continued:

- Added and Fixed each appeared twice, and the second Fixed held Added-type
  material (the generic ATOP call). Merged into one of each, in the order Keep
  a Changelog defines, since release notes are generated from those headings.
- The auto-connect default was documented both ways: Changed said it is now on
  by default, while the connect/disconnect entry still said "The default stays
  false". The later change never revisited the earlier entry.
- The music-play demo was credited to #15, which is the region-wire-codes fix.
  It is #12.

Two entries are dropped rather than shortened: the mqtt_abort_connect()
extraction and a test-only over-read fix. Convention 2 scopes the CHANGELOG to
what SDK users see, and neither is visible outside the repo.

Rebased onto five commits that landed meanwhile, whose entries are folded in at
the new length: the session-token-reason API (#29), the reset scope (#28), the
POSIX binary renaming, and audio_chat_demo's header-shadowing and device-VAD
fixes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
sedawwk pushed a commit that referenced this pull request Aug 27, 2026
* docs: require terse CHANGELOG entries with a PR number

The Unreleased section had drifted into commit bodies pasted under a heading:
single entries running fifteen-plus lines through motivation, rejected
alternatives and test counts. That is the right material, in the wrong file --
release notes are skimmed, and a reader who wants the reasoning goes to the
commit.

Convention 2 already said *when* an entry is needed; this says what it should
look like. `## [0.3.0]` is named as the reference because it is the last section
written that way: one line per change, sub-bullets only for specifics a reader
acts on.

Two things the section had also been losing: the PR number, which is the only
link from a one-line summary back to the reasoning, and the Added / Changed /
Fixed split, which release notes are generated from -- a fix landing under Added
is published as a feature.

No CHANGELOG entry for this commit, per convention 2: repo-internal, and this
file is explicitly excluded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs(changelog): condense Unreleased to the new convention

Applies convention 6 to the section that motivated it: 619 lines down to 139.

The entries were commit bodies pasted under a heading — motivation, rejected
alternatives, test counts and internal reasoning, several running past fifty
lines for one change. All of that is still in the commits, which is where a
reader who wants it looks. What is left here is what a reader acts on: the
symbol, the behaviour change, the migration step.

Most entries now carry a PR number. They could not be recovered from git
history because these landed as squash or rebase merges, which leave no
"Merge pull request #N" commit; the closed-PR list on GitHub has them, and each
attribution was confirmed against that PR's own commit list rather than
inferred from a branch name. Four entries carry none because they were pushed
straight to master with no PR to cite.

Two merged PRs turned out to have no entry at all, and are added:

- #21, the APP-confirmed OTA (protocol 15) callback — a public callback on both
  config structs.
- #23, the sizable ATOP response buffer — user-visible, since the sizes are set
  with -D.

Three defects the rewrite surfaced, all from entries being appended rather than
amended as the work continued:

- Added and Fixed each appeared twice, and the second Fixed held Added-type
  material (the generic ATOP call). Merged into one of each, in the order Keep
  a Changelog defines, since release notes are generated from those headings.
- The auto-connect default was documented both ways: Changed said it is now on
  by default, while the connect/disconnect entry still said "The default stays
  false". The later change never revisited the earlier entry.
- The music-play demo was credited to #15, which is the region-wire-codes fix.
  It is #12.

Two entries are dropped rather than shortened: the mqtt_abort_connect()
extraction and a test-only over-read fix. Convention 2 scopes the CHANGELOG to
what SDK users see, and neither is visible outside the repo.

Rebased onto five commits that landed meanwhile, whose entries are folded in at
the new length: the session-token-reason API (#29), the reset scope (#28), the
POSIX binary renaming, and audio_chat_demo's header-shadowing and device-VAD
fixes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants