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

Fix/ble connect #402

Merged
merged 3 commits into from
Jan 13, 2025
Merged

Fix/ble connect #402

merged 3 commits into from
Jan 13, 2025

Conversation

ByteZhang1024
Copy link
Contributor

@ByteZhang1024 ByteZhang1024 commented Jan 13, 2025

Summary by CodeRabbit

  • Version Updates

    • Updated multiple packages to version 1.0.19-alpha.0, including:
      • Electron and Expo example projects
      • Core SDK packages
      • Transport and connectivity SDKs
      • Web and BLE-related packages
  • Dependency Updates

    • Synchronized dependency versions across multiple packages within the OneKey ecosystem
  • Pre-release Preparation

    • Transitioned packages to an alpha pre-release version, suggesting ongoing development and testing

Copy link

coderabbitai bot commented Jan 13, 2025

Walkthrough

This pull request involves a comprehensive version update across multiple packages within the OneKey SDK ecosystem. The primary change is a version bump from 1.0.18 to 1.0.19-alpha.0 for nearly all packages, indicating a coordinated pre-release update. Additionally, a minor modification was made to the ReactNativeBleTransport class in the React Native transport implementation to improve connection management.

Changes

File/Path Change Summary
packages/*/package.json Version updated from 1.0.18 to 1.0.19-alpha.0 for multiple packages including core, SDK, transport, and example packages
packages/hd-transport-react-native/src/index.ts Added await this.release(uuid) in acquire method to ensure proper connection resource management

Sequence Diagram

sequenceDiagram
    participant Client
    participant ReactNativeBleTransport
    participant BleTransport

    Client->>ReactNativeBleTransport: acquire(input)
    ReactNativeBleTransport->>ReactNativeBleTransport: release(uuid)
    ReactNativeBleTransport->>BleTransport: new instance
    BleTransport-->>ReactNativeBleTransport: transport created
    ReactNativeBleTransport-->>Client: return transport
Loading

The sequence diagram illustrates the enhanced connection acquisition process, showing the additional step of releasing existing resources before creating a new transport instance.

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@wabicai wabicai self-requested a review January 13, 2025 06:31
Copy link

socket-security bot commented Jan 13, 2025

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Critical CVE npm/[email protected] ⚠︎

View full report↗︎

Next steps

What is a critical CVE?

Contains a Critical Common Vulnerability and Exposure (CVE).

Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

Copy link

Report too large to display inline

View full report↗︎

@ByteZhang1024 ByteZhang1024 merged commit 52a172d into onekey Jan 13, 2025
5 checks passed
@ByteZhang1024 ByteZhang1024 deleted the fix/bleConnect branch January 13, 2025 06:36
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6cd696 and 0409978.

📒 Files selected for processing (13)
  • packages/connect-examples/electron-example/package.json (1 hunks)
  • packages/connect-examples/expo-example/package.json (2 hunks)
  • packages/core/package.json (2 hunks)
  • packages/hd-ble-sdk/package.json (2 hunks)
  • packages/hd-common-connect-sdk/package.json (2 hunks)
  • packages/hd-transport-http/package.json (2 hunks)
  • packages/hd-transport-lowlevel/package.json (2 hunks)
  • packages/hd-transport-react-native/package.json (2 hunks)
  • packages/hd-transport-react-native/src/index.ts (1 hunks)
  • packages/hd-transport-webusb/package.json (2 hunks)
  • packages/hd-transport/package.json (1 hunks)
  • packages/hd-web-sdk/package.json (2 hunks)
  • packages/shared/package.json (1 hunks)
🔇 Additional comments (8)
packages/hd-transport-lowlevel/package.json (1)

3-3: Verify alpha version compatibility

The package and its dependencies are moving to an alpha version. Ensure all consumers are prepared for potential breaking changes.

Also applies to: 22-23

✅ Verification successful

Alpha version update is safe to proceed

The package is properly imported and managed through package.json files. No hardcoded version references found in the codebase. Package managers will handle version constraints appropriately.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any hardcoded version references
rg -g '!package*.json' -g '!yarn.lock' '1\.0\.18'

Length of output: 51


Script:

#!/bin/bash
# Check for package references in code
rg -g '!package*.json' -g '!yarn.lock' 'hd-transport-lowlevel'

# Find other package.json files that might depend on this
fd package.json --exec grep -l "hd-transport-lowlevel" {}

# Look for dynamic requires or imports
ast-grep --pattern 'require("hd-transport-lowlevel")'
ast-grep --pattern 'from "hd-transport-lowlevel"'

Length of output: 673

packages/shared/package.json (1)

3-3: LGTM!

Version bump is consistent with the project-wide update.

packages/hd-ble-sdk/package.json (1)

3-3: Version bump to alpha needs changelog entry

Moving to an alpha version (1.0.19-alpha.0) suggests significant changes. This aligns with the PR title mentioning BLE connection fixes.

Please add a changelog entry describing:

  • What BLE connection issues were fixed
  • Why an alpha release is needed
  • Breaking changes, if any

Also applies to: 23-25

packages/hd-transport-webusb/package.json (1)

3-3: Version alignment looks good

Package version and dependencies are correctly aligned with the alpha release.

Also applies to: 23-24

packages/hd-transport-react-native/package.json (1)

3-3: Verify BLE dependencies compatibility

Since this PR fixes BLE connectivity:

  1. Consider updating react-native-ble-plx (3.0.1) and react-native-ble-manager (8.1.0)
  2. Test compatibility with the alpha release

Also applies to: 22-25

packages/hd-transport-http/package.json (1)

3-3: Check axios security updates

Package versions are aligned correctly. However, axios 0.27.2 might need an update.

Also applies to: 27-29

packages/hd-common-connect-sdk/package.json (1)

3-3: Dependencies alignment is correct

All dependencies are properly aligned to version 1.0.19-alpha.0.

Also applies to: 23-27

packages/hd-web-sdk/package.json (1)

3-3: Verify necessity of web SDK updates

The PR focuses on BLE fixes, but web SDK changes are included. Let's verify if these changes are necessary.

Check for related changes:

Also applies to: 24-27

✅ Verification successful

Version update is necessary for transport layer consistency

The web SDK depends on core transport packages and shares common interfaces. Version bump maintains consistency across the package ecosystem.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Look for BLE-related changes in web SDK
rg -l "BLE|Bluetooth" packages/hd-web-sdk/

Length of output: 44


Script:

#!/bin/bash
# Check package dependencies and imports
cat packages/hd-web-sdk/package.json

# Look for transport-related imports
rg -l "transport|HardwareSDK" packages/hd-web-sdk/src/

Length of output: 1987

Comment on lines +363 to +365
// release transport before new transport instance
await this.release(uuid);

Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Remove redundant release call

This release call is redundant. The code already releases the transport at lines 352-357 if it exists in the cache.

-    // release transport before new transport instance
-    await this.release(uuid);
-

Comment on lines +3 to 4
"version": "1.0.19-alpha.0",
"description": "> TODO: description",
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Update package description before release

The description field still contains a TODO placeholder. Consider updating it before the 1.0.19 release.

@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-core",
"version": "1.0.18",
"version": "1.0.19-alpha.0",
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Version bump appears unnecessary

The core package only has package.json changes. No code changes found to justify the version bump to 1.0.19-alpha.0.

🔗 Analysis chain

Version bump needs clarification

The version bump to alpha suggests significant changes, but the PR title only mentions BLE fixes. Core package changes might have broader impact.

Let's check if there are actual code changes in the core package:

Also applies to: 28-29

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for code changes in the core package
git diff HEAD~1 packages/core/ -- ':!package.json'

Length of output: 89


Script:

#!/bin/bash
# List modified files in core package
git diff --name-status HEAD~1 packages/core/

# Show actual changes in core package (excluding package.json)
git diff HEAD~1 -- 'packages/core/*' ':!packages/core/package.json'

# Check for any new files
git ls-files --others --exclude-standard packages/core/

Length of output: 203

@@ -2,7 +2,7 @@
"name": "hardware-example",
"productName": "HardwareExample",
"executableName": "onekey-hardware-example",
"version": "1.0.18",
"version": "1.0.19-alpha.0",
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider keeping example version stable

Example packages don't typically need version bumps. Consider keeping it at 1.0.18 unless there are breaking changes.

@@ -1,6 +1,6 @@
{
"name": "expo-example",
"version": "1.0.18",
"version": "1.0.19-alpha.0",
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Review version bump strategy

The wholesale version bump to 1.0.19-alpha.0 across all packages seems excessive for BLE-specific fixes. Consider:

  1. Only bump versions of directly affected packages
  2. Use patch version for targeted fixes

Also applies to: 3-3, 3-3, 3-3

Comment on lines +22 to +25
"@onekeyfe/hd-ble-sdk": "^1.0.19-alpha.0",
"@onekeyfe/hd-common-connect-sdk": "^1.0.19-alpha.0",
"@onekeyfe/hd-core": "^1.0.19-alpha.0",
"@onekeyfe/hd-web-sdk": "^1.0.19-alpha.0",
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Add BLE-specific test coverage

The SDK update lacks test cases for the BLE connectivity fixes. Add tests to:

  • Verify BLE connection handling
  • Test BLE-specific error scenarios
  • Validate fixed connectivity issues
🔗 Analysis chain

BLE SDK update aligns with PR purpose

The BLE SDK update matches the PR's focus on fixing BLE connectivity.

However, consider:

  1. Documenting the specific BLE fixes in the changelog
  2. Adding test cases for the fixed BLE connectivity issues

Let's check for related test updates:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Look for BLE-related test changes
rg -l "test.*ble|ble.*test" packages/

Length of output: 211


Script:

#!/bin/bash
# Look for bluetooth/test-related files with broader patterns
echo "=== Searching for Bluetooth-related tests ==="
rg -l "bluetooth|Bluetooth" packages/ | grep -i "test"

echo -e "\n=== Finding all test files ==="
fd "test" packages/ --type f | grep -iE "test\.(js|ts|jsx|tsx)$"

Length of output: 1690


Script:

#!/bin/bash
# Check device-related test content for BLE/Bluetooth testing
echo "=== Checking device test content ==="
rg -A 5 "describe|it\(" "packages/connect-examples/expo-example/src/testTools/functionalTesting/lockDevice/InitDeviceTest.tsx" "packages/connect-examples/expo-example/src/testTools/functionalTesting/lockDevice/LockDeviceTest.tsx"

echo -e "\n=== Checking transport tests ==="
rg -A 5 "describe|it\(" "packages/hd-transport/__tests__/build-receive.test.js"

Length of output: 885

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