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

Refactor BT enable #49

Open
wants to merge 14 commits into
base: bt_enable_refac
Choose a base branch
from
Open

Refactor BT enable #49

wants to merge 14 commits into from

Conversation

Jason2866
Copy link
Owner

@Jason2866 Jason2866 commented Apr 3, 2025

By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes

Checklist

  1. Please provide specific title of the PR describing the change, including the component name (eg. „Update of Documentation link on Readme.md“)
  2. Please provide related links (eg. Issue which will be closed by this Pull Request)
  3. Please update relevant Documentation if applicable
  4. Please check Contributing guide
  5. Please confirm option to "Allow edits and access to secrets by maintainers" when opening a Pull Request

This entire section above can be deleted if all items are checked.


Description of Change

Please describe your proposed Pull Request and it's impact.

Tests scenarios

Please describe on what Hardware and Software combinations you have tested this Pull Request and how.

(eg. I have tested my Pull Request on Arduino-esp32 core v2.0.2 with ESP32 and ESP32-S2 Board with this scenario)

Related links

Please provide links to related issue, PRs etc.

(eg. Closes #number of issue)

Summary by CodeRabbit

  • New Features

    • Enhanced Bluetooth initialization and management for improved stability and more reliable connectivity.
    • Simplified Bluetooth status checks based on target configuration.
  • Bug Fixes

    • Corrected Bluetooth status reporting to accurately reflect whether Bluetooth functionality is active.
  • Chores

    • Streamlined code by removing unnecessary function declarations and checks related to Bluetooth status.

Copy link

coderabbitai bot commented Apr 3, 2025

Walkthrough

This pull request restructures the Bluetooth initialization and management functions for ESP32 platforms. In esp32-hal-bt.c, the btStart function now checks if Bluetooth is enabled, initializes the controller if not, and includes error handling with logging. The btInUse and btStop functions have also been updated. Additionally, deprecated functions (btStarted and btStartMode) have been removed. In esp32-hal-misc.c, the btInUse function is redefined to return a specific boolean value based on the CONFIG_IDF_TARGET_ESP32 configuration, replacing the older conditional implementation.

Changes

Files Change Summary
cores/esp32/…/esp32-hal-bt.c - btInUse now returns a boolean indicating Bluetooth status.
- btStart has been reworked to check if Bluetooth is enabled, initialize the controller if not, and include error handling with logging.
- btStop now logs errors on failure.
- Removed btStarted and btStartMode.
cores/esp32/…/esp32-hal-misc.c - Redesigned btInUse to directly return true when CONFIG_IDF_TARGET_ESP32 is defined and false otherwise.
- Eliminated the previous conditional compilation block and external weak declaration.
cores/esp32/…/esp32-hal-bt.h - Removed declarations for btStarted and btStartMode.
libraries/BLE/src/BLEDevice.cpp - Updated preprocessor directive to require both CONFIG_BLUEDROID_ENABLED and CONFIG_BT_ENABLED for including FreeRTOS headers.
libraries/BluetoothSerial/src/BluetoothSerial.cpp - Simplified Bluetooth status checks in _init_bt, _stop_bt, and isReady methods to use btStart() instead of btStarted().
libraries/SimpleBLE/src/SimpleBLE.cpp - Modified preprocessor directives and logic in _init_gap and _stop_gap functions to streamline Bluetooth initialization and stopping logic.
libraries/SimpleBLE/src/SimpleBLE.h - Added #include "soc/soc_caps.h" and expanded conditional compilation directive to include SOC_BT_SUPPORTED alongside existing checks.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant BTMod as Bluetooth Module
    participant Ctrl as Controller
    participant BD as Bluedroid Stack

    App->>BTMod: Call btStart()
    BTMod->>BTMod: Check if BT is already enabled
    alt Already Enabled
        BTMod-->>App: Return success
    else
        BTMod->>Ctrl: Initialize Controller
        alt Controller Initialized
            BTMod->>BD: Enable Bluedroid
            alt Bluedroid Enabled
                BTMod-->>App: Return success
            else Bluedroid Error
                BTMod-->>App: Log error & return failure
            end
        else Initialization Error
            BTMod-->>App: Log error & return failure
        end
    end
Loading

Poem

I'm a rabbit with a code delight,
Hopping through functions both day and night,
With BT paths reformed crisp and clear,
Logging errors so none shall steer,
Bugs vanish like carrots in plain sight!
🐇💻 Keep on hopping—code is a delight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 22f07d0 and f7f5f69.

📒 Files selected for processing (7)
  • cores/esp32/esp32-hal-bt.c (1 hunks)
  • cores/esp32/esp32-hal-bt.h (0 hunks)
  • cores/esp32/esp32-hal-misc.c (3 hunks)
  • libraries/BLE/src/BLEDevice.cpp (1 hunks)
  • libraries/BluetoothSerial/src/BluetoothSerial.cpp (3 hunks)
  • libraries/SimpleBLE/src/SimpleBLE.cpp (3 hunks)
  • libraries/SimpleBLE/src/SimpleBLE.h (1 hunks)
💤 Files with no reviewable changes (1)
  • cores/esp32/esp32-hal-bt.h

Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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 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.

@Jason2866
Copy link
Owner Author

@coderabbitai review

Copy link

coderabbitai bot commented Apr 3, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

github-actions bot commented Apr 3, 2025

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "CONFIG_SOC_BT_SUPPORTED":
    • summary looks empty
    • type/action looks empty
  • the commit message "Fix error: simple_ble_start enable controller failed 259":
    • summary looks empty
    • type/action looks empty
  • the commit message "SOC_BT_SUPPORTED":
    • summary looks empty
    • type/action looks empty
  • the commit message "Update esp32-hal-bt.c":
    • summary looks empty
    • type/action looks empty
  • the commit message "fix BT mem release logic":
    • summary looks empty
    • type/action looks empty
  • the commit message "guard SimpleBLE":
    • summary looks empty
    • type/action looks empty
  • the commit message "less changes":
    • summary looks empty
    • type/action looks empty
  • the commit message "log_e":
    • summary looks empty
    • type/action looks empty
  • the commit message "more safe guards":
    • summary looks empty
    • type/action looks empty
  • the commit message "reemove duplicate btInUse define":
    • summary looks empty
    • type/action looks empty
  • the commit message "remove old refactored code":
    • summary looks empty
    • type/action looks empty
  • the commit message "use bluedroid":
    • summary looks empty
    • type/action looks empty
  • the commit message "use bt only when enabled":
    • summary looks empty
    • type/action looks empty

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 10 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

⚠️
	The **target branch** for this Pull Request **must be the default branch** of the project (`master`).

	If you would like to add this feature to a different branch, please state this in the PR description and we will consider it.

👋 Hello Jason2866, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against f7f5f69

@Jason2866
Copy link
Owner Author

@coderabbitai full review

Copy link

coderabbitai bot commented Apr 3, 2025

✅ Actions performed

Full review triggered.

@Jason2866
Copy link
Owner Author

@CodeRabbit full review

Copy link

coderabbitai bot commented Apr 4, 2025

✅ Actions performed

Full review triggered.

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.

1 participant