Skip to content

Fix CB120B detection: map NW-20230112 to the CB120B profile (type 70) - #115

Merged
keefo merged 2 commits into
keefo:mainfrom
itsmeMJS:fix/cb120b-light-type
Sep 24, 2026
Merged

keefo merged 2 commits into
keefo:mainfrom
itsmeMJS:fix/cb120b-light-type

Conversation

@itsmeMJS

@itsmeMJS itsmeMJS commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

The CB120B advertises over BLE as NW-20230112&<serial>. getProjectName(_:) has no case for 20230112, so the light resolves to an empty project name, getLightType falls through to type 0, and the app sends it the legacy 0x82/0x83 CCT packets (clamped to 3200–5600K), which the light ignores. Result: the light appears, power on/off works, but the CCT and brightness sliders do nothing.

Database/lights.json has carried a CB120B profile as type 70 since #90, but nothing routed to it: the existing nickName.contains("CB120B") branch returns 84, which has no database profile.

Fix

  • getProjectName(_:): add "20230112" → "CB120B"
  • getLightType: route CB120B to type 70 (the database profile) instead of 84
  • getProjectName(_ idx:): return "CB120B" for 70
  • Add a unit test for the NW-20230112&… name

Verification

Tested on a real CB120B (macOS, this branch built as Release):

  • Light is identified as CB120B, image cb120b.png, CCT range 27–65.
  • CCT and brightness sliders in the UI now drive the light across 2700–6500K and 0–100%.
  • MCP set_cct works; the packet sent is the type-70 pattern 78 87 05 <brr> <cct> 32 00 00 <chk>, which I also confirmed directly over BLE outside the app.

No database change needed.

The CB120B advertises as NW-20230112&<serial>. getProjectName had no case for
20230112, so the light resolved to an empty project name and fell through to
light type 0, which has no database profile. It then received legacy
0x82/0x83 CCT packets (clamped to 3200-5600K) that the light ignores, so
only power on/off worked.

Database/lights.json has carried a CB120B profile as type 70 since keefo#90, but
the CB120B branch in getLightType pointed at type 84, which has no profile.

- getProjectName: add 20230112 -> CB120B
- getLightType: route CB120B to type 70 (the database profile)
- getProjectName(idx): return CB120B for 70
- add a unit test for the NW-20230112 name

Verified on hardware: type 70's CCT packet (78 87 05 brr cct 32 00 00 chk)
drives a CB120B correctly across 2700-6500K and 0-100%.
keefo
keefo previously approved these changes Sep 5, 2026
@keefo

keefo commented Sep 5, 2026

Copy link
Copy Markdown
Owner

thank you for providing this pr.

@keefo

keefo commented Sep 5, 2026

Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	NeewerLite/NeewerLite/Model/NeewerLightConstant.swift

@keefo keefo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @itsmeMJS! I merged main into the branch to resolve the conflict with #112 (BH20C), keeping both getProjectName entries. Looks good: routing CB120B to the existing type 70 database profile is the right fix.

@keefo
keefo merged commit 6450b89 into keefo:main Sep 24, 2026
1 check passed
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