Why getAttribute increments _requestId twice?


#1

Hi,

I’m new to this afero world.
Last a couple weeks I’ve been struggling to learn how to use afLib.
And finally today, my getAttribute and setAttribute seem to start working.

Now as I’d like to make sure my request was taken care of,
I’d like to compare the request and the notified result.

To map these two, I wanted to use "_requestId"
but in afLib::getAtrribute(), _requestId gets incremented twice.

int afLib::getAttribute(const uint16_t attrId) {
_requestId++; // <- here
uint8_t dummy; // This value isn’t actually used.
return queuePut(MSG_TYPE_GET, _requestId++, attrId, 0, &dummy, 0, 0); // <- here again
}

I wonder if there is an unavoidable reason to do this?

Or can I safely replace

return queuePut(MSG_TYPE_GET, _requestId++, attrId, 0, &dummy, 0, 0);

to
< return queuePut(MSG_TYPE_GET, _requestId, attrId, 0, &dummy, 0, 0);

Best Regards,
16-Nov-2017
Motoo Tanaka


#2

Hi Tanaka-san,

That looks like it’s a typo in the code. requestId shouldn’t need to be incremented twice.

We will correct this in the next release of afLib, but for now you can edit afLib.cpp and remove the “++” from the queuePut() call, as you describe above, and that should take care of your problem.

Thank you!

Joe


#3

Dear Joe-san,

Thank you very much for your answer!
That solves me of my current issue.

Best Regards,
17-Nov-2017
moto