-
Notifications
You must be signed in to change notification settings - Fork 354
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
Notify updated devicenames during scanning #429
Conversation
ScanResult.getScanRecord().getDeviceName() returns the most up to date name from the latest scan while ScanResult.getDevice().getName() returns first name found after starting scan
@@ -2905,6 +2905,9 @@ public void onScanResult(int callbackType, ScanResult result) { | |||
JSONObject returnObj = new JSONObject(); | |||
|
|||
addDevice(returnObj, result.getDevice()); | |||
if(result.getScanRecord().getDeviceName() != null){ | |||
addProperty(returnObj, keyName, result.getScanRecord().getDeviceName().replace("\0", "")); |
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.
What's the replace needed for? Perhaps this should be opt in since it changes the existing behavior
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'm communicating with a device which padds it's name field with 0x00's. I'm not sure why, but getDevice().getName() filters this by itself while getScanRecord().getDeviceName() does not, resulting in strange behaviour on the JS side.
Better solutions are appreciated off course.
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.
If this is dependent on a specific device, I think it should be done on the client side.
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 think that the behaviour of the plugin should not change, so since getDevice().getName() skips the zeroes, I think the result of getScanRecord().getDeviceName() should be filtered to obtain the same result.
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.
Ahh I see what you're saying. The empty stay is just right padded with 0x00? I think that behavior is fine then.
Will try to make a release tonight. |
Thanks, this solves #428 |
ScanResult.getScanRecord().getDeviceName() returns the most up to date name from the latest scan while ScanResult.getDevice().getName() returns first name found after starting scan