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

Notify updated devicenames during scanning #429

Merged
merged 1 commit into from
May 29, 2017

Conversation

Wieltje
Copy link
Contributor

@Wieltje Wieltje commented May 24, 2017

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

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", ""));
Copy link
Owner

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

Copy link
Contributor Author

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.

Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

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.

@randdusing
Copy link
Owner

Will try to make a release tonight.

@randdusing randdusing merged commit 3c88eb9 into randdusing:master May 29, 2017
@Wieltje
Copy link
Contributor Author

Wieltje commented May 31, 2017

Thanks, this solves #428

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

Successfully merging this pull request may close these issues.

2 participants