[Bug] PROP_BITMAP Object DP is always rejected by dp_type_check()

Open Beginner friendly
#668 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
c
Domain
embedded-iot

Research direction

Start in dp_schema.c around dp_rept_valid_check() and dp_type_check(), then run the issue's DP 130 minimal reproduction through tuya_iot_dp_obj_report(). Confirm that a schema-matching PROP_BITMAP is accepted, serialized, and reported, while mismatched property types remain rejected.

Written by the indexing model from the issue text.

Description

Summary

tuya_iot_dp_obj_report() cannot report a schema-valid PROP_BITMAP DP. The Object-DP validator first correctly verifies that the DP type matches the schema property type, but the bitmap-specific branch then compares the same dp_obj_t.type field with the unrelated cJSON node type cJSON_Number.

This causes every bitmap/Fault Object DP to be filtered before it is serialized and sent to Tuya Cloud.

Affected versions

  • Reproduced with TuyaOpen v1.8.0

Minimal reproduction

Configure DP 130 as a report-only Fault DP with nine labels, so the downloaded product schema contains:

{
  "id": 130,
  "mode": "ro",
  "property": {
    "type": "bitmap",
    "maxlen": 9
  }
}

Report it through the public Object-DP API:

dp_obj_t bitmap = {
    .id = 130,
    .type = PROP_BITMAP,
    .value.dp_bitmap = 1U,
};

int result = tuya_iot_dp_obj_report(client, NULL, &bitmap, 1U, DP_REPT_NO_FILTER_FLAG);

Actual result

The SDK logs:

[dp_schema.c:732] bitmap check fail 4 1 9

For a report containing only this DP, tuya_iot_dp_obj_report() returns OPRT_SVC_DP_ID_NOT_FOUND (-3585) because the valid-DP set is empty.

A real Fault value produces the same failure, for example:

[dp_schema.c:732] bitmap check fail 4 130 9

Here 4 is PROP_BITMAP, 130 is the bitmap value, and 9 is the schema maxlen.

Expected result

A dp_obj_t whose type is PROP_BITMAP should be accepted when the product schema property type is also PROP_BITMAP, and its numeric bitmap value should be serialized and reported.

Root cause

dp_rept_valid_check() already performs the correct Object-DP/schema check:

if (dp->type != dpnode->desc.prop_tp) {
    return OPRT_SVC_DP_TP_NOT_MATCH;
}

After that check passes, dp_type_check() reaches this bitmap branch:

case PROP_BITMAP:
    if (dp->type != cJSON_Number) {
        PR_ERR("bitmap check fail %d %d %d", dp->type,
               dp->value.dp_bitmap,
               node->prop.prop_bitmap.max_len);
        return FALSE;
    }
    break;

dp->type is a Tuya property type, not a cJSON node type:

PROP_BITMAP = 4
cJSON_Number = 8

The condition is therefore always true for every correctly formed bitmap Object DP.

The earlier dp->type != dpnode->desc.prop_tp check remains active and still rejects an Object DP whose property type does not match the product schema.

Dominant language
C
Stars
1.9k
Forks
305
Avg merge
15h 30m
Merged PRs (30d)
20

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tuya/TuyaOpen

All issues in tuya/TuyaOpen

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.