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

Update AndroidUSBInterface.java #24

Merged
merged 2 commits into from
May 25, 2022
Merged

Update AndroidUSBInterface.java #24

merged 2 commits into from
May 25, 2022

Conversation

hhovhann
Copy link
Contributor

@hhovhann hhovhann commented May 25, 2022

  1. Transform the VID variable into an array.
  2. Add the new Vendor ID to support the EXAR brand.
  3. Replace the name of variable FTDI_PIDS with UART_PIDS.
  4. Add the new PID of the XR21V1410 for newly added Vendor ID.
  5. Add a new condition to find devices (FTDI or EXAR).

Reference Document:
May24th.docx

1. Transform the VID variable into an array.
2. Add the new Vendor ID to support the EXAR brand.
3. Replace the name of variable FTDI_PIDS with UART_PIDS.
4. Add the new PID of the XR21V1410 for newly added Vendor ID.
5. Add a new condition to find devices (FTDI or EXAR).
@hhovhann
Copy link
Contributor Author

hhovhann commented May 25, 2022

Was done in the scope of Upwork AD and related to issue 23

Refactor condition for FTDI and EXAR vendors
@simonows simonows self-requested a review May 25, 2022 10:30
if (device.getVendorId() == VID) {
for (int pid:FTDI_PIDS) {
if (device.getVendorId() == VID[0]) {
for (int pid:UART_PIDS) {
Copy link
Contributor Author

@hhovhann hhovhann May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR: This could be done by checking contains deviceProductId in defined array:

PSEUDO CODE:

if (device.getVendorId() == VID[0] && Arrays.asList(FTDI_PIDS).contains(device.getProductId())){
        usbDevice = device;
        logger.info("USB XBee Android device from FTDI vendor found: " + usbDevice.getDeviceName());
        break;
}

break;
}
}
} else if (device.getVendorId() == VID[1] && device.getProductId() == UART_PIDS[0]){
Copy link
Contributor Author

@hhovhann hhovhann May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition will be O(1) instead of the previous logic when I have tried to merge the checks together in the first if. Of course, this could be refactored as well to have more clean code here.
Could be two small functions:
containsDevice and containsProduct and those functions will use getDevice logic

break;
}
}
} else if (device.getVendorId() == VID[1] && device.getProductId() == UART_PIDS[0]){
usbDevice = device;
logger.info("USB XBee Android device from EXAR vendor found: " + usbDevice.getDeviceName());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: Add different logs to be sure that the new EXAR vendor device was found.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please contact contact@beechat.network to claim bounty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresponsive email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share an email here and we'll contact you today? thanks in advance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresponsive email

@simonows simonows merged commit 87651e6 into BeechatNetworkSystemsLtd:crypto May 25, 2022
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.

None yet

3 participants