Skip to content
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

Status report encoding status to uint32_t mask not compatible #218

Open
ldholmgren opened this issue Jan 29, 2025 · 0 comments
Open

Status report encoding status to uint32_t mask not compatible #218

ldholmgren opened this issue Jan 29, 2025 · 0 comments

Comments

@ldholmgren
Copy link

ldholmgren commented Jan 29, 2025

Is your feature request related to a problem? Please describe.
Current implementation of osdp_status_report and specifically ISTATR that forces input status to either '0' or '1' (uint32_t mask) is not compatible with implementations that report status above 0x01 to indicate different fault states.

I think this is yet another case of the OSDP standard being somewhat unclear which have led to different implementatons of it.

I noticed that in the newly released 2.2.2 standard, they have specified a new set of possible standard codes for ISTATR (above 0x01), with anything above 0x80 reserved for vendor specific implementations. So a change to how this work would also make the library conform with the latest OSDP version.

Describe the solution you'd like
Change the logic and the uint32_t mask in osdp_status_report to a byte array with a defined value for the maximum number of inputs allowed

This would be a breaking change to the library API though

I'd be willing to submit a PR for it if wanted


OSDP 2.2/IEC SPEC
Image

OSDP 2.2.2 ISTATR SPEC
Image

Relevant code
pd_build_reply(...)

case REPLY_ISTATR: {
	event = (struct osdp_event *)pd->ephemeral_data;
	int n = pd->cap[OSDP_PD_CAP_CONTACT_STATUS_MONITORING].num_items;
	if (event->status.nr_entries != n) {
		break;
	}
	assert_buf_len(n + 1, max_len);
	buf[len++] = pd->reply_id;
	**for (i = 0; i < n; i++) {
		buf[len++] = !!(event->status.mask & (1 << i));
	}**
	ret = OSDP_PD_ERR_NONE;
	break;
}

cp_decode_response(...)

case REPLY_ISTATR: {
	uint32_t status_mask = 0;
	int cap_num = OSDP_PD_CAP_CONTACT_STATUS_MONITORING;

	if (len != pd->cap[cap_num].num_items || len > 32) {
		LOG_ERR("Invalid input status report length %d", len);
		return OSDP_CP_ERR_GENERIC;
	}
	**for (i = 0; i < len; i++) {
		status_mask |= !!buf[pos++] << i;
	}**
	event.type = OSDP_EVENT_STATUS;
	event.status.type = OSDP_STATUS_REPORT_INPUT;
	event.status.nr_entries = len;
	event.status.mask = status_mask;
	memcpy(pd->ephemeral_data, &event, sizeof(event));
	make_request(pd, CP_REQ_EVENT_SEND);
	ret = OSDP_CP_ERR_NONE;
	break;
}
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

No branches or pull requests

1 participant