-
Notifications
You must be signed in to change notification settings - Fork 10
Fix incorrect bit check for MaxLRTxPowerLevel in SupportsSerialAPISetup_func #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix incorrect bit check for MaxLRTxPowerLevel in SupportsSerialAPISetup_func #45
Conversation
|
Thank you, this looks legit, let me run tests Please update commit message, to explain what was the observed issue and the motivation of the fix (reference to specs will be also appreciated) Reviewers welcome (I cant add names) cc: @lmolina @ochavezmiranda @Thomasdjb @XavierPerraud-Silabs |
|
I noticed an issue (not related to this change) in build log: 1046.6 Generating codsh: 1: mscgen: not found https://en.wikipedia.org/wiki/MscGen May this be fixed |
| ERR_PRINTF("Error: Checking if 0x%02X is supported, requires checking " | ||
| "beyond 1st byte of Extended Z-Wave API Setup Supported Sub" | ||
| "Commands bitmask, which is not supported.\n", subcmd); | ||
| } else if (subcmd > 8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend something closer to the source code of the Z-Wave stack:
uint8_t index = (subcmd - 1) / 8 + 1; // +1 because the sub command bitmask start at index 1 instead of 0.
uint8_t mask = (1 << ((x - 1) % 8));
return capabilities.supported_serialapi_bitmask[index] & mask;
| // check if the subcmd being checked has two bits set for e.g. 3(0011), 5(0101) | ||
| // Where we need to check the Extended Z-Wave API Setup Supported Sub Commands bitmask | ||
| if (subcmd & (subcmd - 1)) { | ||
| if (subcmd > 16) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why subcmd is limited to 16?
Highest subcmd defined in the controller is 22: SERIAL_API_SETUP_CMD_GET_REGION_INFO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the reason is the limitation of the Z/IP Gateway, which only supports a few specific Serial API subcommands.
The Z/IP Gateway supports only the following Serial API subcommands:
SERIAL_API_SETUP_CMD_UNSUPPORTED,
SERIAL_API_SETUP_CMD_SUPPORTED = 1<<0,
SERIAL_API_SETUP_CMD_TX_STATUS_REPORT = 1<<1,
SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET = 3,
SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET = 1<<2,
SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET = 5,
SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET = 1<<3,
// SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE = 1<<4,
SERIAL_API_SETUP_CMD_RF_REGION_GET = 1<<5,
SERIAL_API_SETUP_CMD_RF_REGION_SET = 1<<6,
SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET = 1<<7,
This PR fixes an issue in SupportsSerialAPISetup_func() where the subcommand ID was incorrectly used as a bit index in is_bit_num_set_in_byte(). This prevented MaxLRTxPowerLevel from being configured via zipgateway.cfg.