Hi Chdi,
Thank you for the support, we’re still stuck on this topic. Please review my findings.
What I understand is.
If we want to check variable "Can Change password" which have mask value 2.
Mask value 2 will mean we are interacting with "Can change password" and flag value will be either 0 or 1, same logic applies to other variables. But it still fails and does not work for all scenarios.
If we want to check option "Can Change Settings" which have mask value 16.
Mask value 16 will mean we are interacting with "Can change Settings" and flag value will be either 0 or 1, same logic applies to other variables. But it still fails and does not work for all scenarios.
For example:
When you get the 'fl' value you just need to check each bit status - 0 or 1. Depend on bitN value 0 or 1 it will be mean the option status of:
1 bit = 1 - User disabled, 0 - User active
2 bit =1 - Can't change password , 0 - can change password
3 bit = 1 - Can create items, 0 - cannot create items
5 bit = 1 - Can't change settings, 0 - can change settings
6 bit = 1 - Can send SMS, 0 - cannot send sms
In your example fl = 21 = 10101 which equates to:
1 bit = 1 - User disabled
2 bit = 0 - can change password
3 bit = 1 - can create items
5 bit = 1 - Can't change settings
6 bit = 0 - cannot send sms
The way fl = 21 = 10101 binary you are mapping also does not seems to work. It works if we have following sequence/order.
In your example fl = 21 = 10101 which equates to:
1 bit = 1 - User disabled
2 bit = 0 - can change password
3 bit = 1 - can create items
5 bit = 0 - cannot send sms
6 bit = 1 - Can't change settings
Also sequence we have in Wialon CMS dashboard is different.
Please Note:
There are scenarios in we have falgs value 32. And 32 = 100000, which are actually 7 bits, and we have 6 bits to take care and in some cases we have flag 4 = 0100 or 5 = 0101 which are 4 bit values and in your example we have 5 bits to take care each time.
Maybe go further into detail I’m not sure how to figure this algo out on my end.
Sincerely we appreciate any help,