Skip to main content
PSUT / IoTEngineering learning studio
WORKSPACE
Offline-first portalDr. Mohammad Alja’afreh
Embedded Systems StudioIoT Programming and ApplicationsExperimentsWorkspaces
ENGINEERING WORKSPACE
Home/WSL Laboratories/Lab 7 · Bluetooth board & phone pairing
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
Pi practical / X7
Networking and Communication

Lab 7 · Bluetooth board & phone pairing

Ask Dr. Mohammad · X7 →

WSL 2 has no Bluetooth: its Linux kernel has no Bluetooth stack and cannot see the PC’s Bluetooth adapter. bluetoothctl list shows no controller.

Design experiment & verify evidence →
X7 · Laboratory mentorAsk about the current experiment, its algorithms or Python notebook.
Ask Dr. MohammadAdaptive practice
Learning workflow · Core IoT & programmingX7 · Bluetooth board & phone pairing
Readiness checksRevision deckEngineering workspaceRecord evidence

Related course access: IoT Programming and Applications — same laboratory, notebook and completion record.

X7 · Academic orientation

Scope and objectives

Scope of the experiment

Trace discovery, pairing and application-session availability as separate states.

The focus of this experiment is to distinguish Bluetooth discovery, pairing and connection. Students then trace board and phone state changes and required permissions, and diagnose failed pairing without assuming data-channel readiness. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.

Learning objectives

  • Distinguish Bluetooth discovery, pairing and connection.
  • Trace board and phone state changes and required permissions.
  • Diagnose failed pairing without assuming data-channel readiness.
  • Identify the configured inputs (Device discoverable; Pairing succeeds; Required service available; Fixture RSSI (dBm); Configured minimum RSSI (dBm)) and record the corresponding observed outputs with units where applicable.
  • Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.

Expected learning outcomes

On completion, students can distinguish Bluetooth discovery, pairing and connection, trace board and phone state changes and required permissions, and diagnose failed pairing without assuming data-channel readiness.

Required deliverables

Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing diagnose failed pairing without assuming data-channel readiness. Separate predicted values from observations.

Prerequisite knowledge and related learning

Review the following catalogue prerequisites before starting. After completion, continue to Lab 8 · Bluetooth telemetry & LED control.

Environment and experimental methodology

The browser instrument and the specified local software or network environment. Use the experiment’s documented topology and distinguish modeled values from actual packet observations.

Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.

X7 / PREPARE

Before starting

Follow the setup guide and use the named terminal or editor. A browser model is not a real GPIO measurement or a running service.

Ubuntu WSL setup →
Before you run / verification gate

If bluetoothctl cannot connect to a BlueZ service, record that limitation; continue with X8 TCP substitute. No real pairing is required.

CONCEPTS / ACTIVE RECALL

Understand the experiment

Scientific architecture · Bluetooth pairing, link and authorization

Bluetooth connection lifecycle — Adapter enabled / discoverable; Discovery / peer identified; Pairing / establish trust; Authorization / permitted service; Disconnect / session closed
Scientific concept map: Bluetooth adapter — Discoverable state; Peer device — Discovery; Pairing — Establish trusted link; Authorization — Service access; Session — Connected or rejected.

Scientific foundations and analytical reasoning

Discovery advertises a device, pairing establishes association, and service availability and authorization control use. RSSI is a received power indicator, not a distance measurement.

Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.

Scientific theory · Bluetooth discovery and access

Discovery exposes an advertised or discoverable device; pairing establishes a security relationship appropriate to the Bluetooth mode. Connection and service access may require additional authorization. Received signal strength is affected by orientation, interference and path loss, so it is not a direct distance reading.

Worked example and engineering interpretation

A phone may discover a board but fail pairing, or pair yet lack the required service. Record these states separately. A change from −50 dBm to −60 dBm is a tenfold received-power decrease, not a proven tenfold increase in distance.

Engineering principles · additional worked teaching example

Discovery, pairing, service discovery and data transfer are separate stages. RSSI in dBm is logarithmic: a 10 dB difference represents a power ratio 10^(10/10)=10, not ten extra milliwatts. WSL discovery may be limited by host adapter access.

From theory to experiment

Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.

How to investigate Lab 7 · Bluetooth board & phone pairing

Explain the limitations of Bluetooth in WSL.

Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.

Experiment-specific guided practice

Objective: Explain the limitations of Bluetooth in WSL.

  1. Run discovery at −55 dBm and inspect connection phases.
  2. Disable discovery, then restore and reject pairing. Identify first unavailable phase.
  3. Select RSSI below the configured threshold; compare with missing application service.
  4. Use the original Bluetooth practical and distinguish pairing from service connection.

Reference check:

Model boundary:

Independent task and submission evidence

2. Disable discovery, then restore and reject pairing. Identify first unavailable phase. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.

Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.

TrialChanged settingFixed settingsPredicted resultActual observation / unitsEvidence / uncertainty
A: baselineReferenceRecordPredictRecordRecord
B: one changeRecordSame as APredictRecordRecord
A: repeatRestoreSame as APredictRecordRecord

Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.

Worked engineering reasoning and boundary conditions

Engineering reference configuration: Device discoverable = true; Pairing succeeds = true; Required service available = true; Fixture RSSI (dBm) = -55; Configured minimum RSSI (dBm) = -85. In the classroom model, Discovered = Yes; Paired = Yes; Application session = Ready. No Bluetooth radio interaction occurs. A closed, deterministic browser model. The existing practical instructions and source files provide independent execution; browser results are not hardware measurements.

Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.

Concept animation · message sequence

Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.

Lab 7 · Bluetooth board & phone pairing: message sequenceScannerPeerApplicationDiscoveryPairingService

Step 1 of 3 · Discovery

Discovery

1. Scanner → Peer
Discovery

Teaching example only; inspect live calculations or real practical evidence separately.

Recall the concept before revealing its explanation.

0 / 3 revealed
X7 · 01 / 08Why no automatic Bluetooth pairing?Reveal explanation
Engineering explanation

WSL generally lacks direct access to a Pi Bluetooth radio.

X7 · 02 / 08What does an empty controller list mean?Reveal explanation
Engineering explanation

No usable controller was enumerated; it does not prove a broken radio.

X7 · 03 / 08What Bluetooth adapter conditions must be established before pairing?Reveal explanation
Engineering explanation

If bluetoothctl cannot connect to a BlueZ service, record that limitation; continue with X8 TCP substitute. No real pairing is required.

X7 · 04 / 08What is the difference between discovery and pairing?Reveal explanation
Engineering reasoning

Discovery identifies nearby devices; pairing establishes a relationship using the selected procedure and security settings.

X7 · 05 / 08Why may WSL not expose a Bluetooth controller?Reveal explanation
Engineering reasoning

Hardware passthrough and driver support depend on the host and configuration; a TCP substitute is not radio pairing.

X7 · 06 / 08Bluetooth pairing is considered under WSL. Select every technically valid statement. A. Check the actual host/controller access available. B. Pairing and application data transfer are distinct operations. C. WSL always exposes every Bluetooth adapter directly. D. An IP socket is itself a Bluetooth radio.Reveal explanation
Applied scenario

Correct: A. Check the actual host/controller access available.; B. Pairing and application data transfer are distinct operations.

X7 · 07 / 08In Bluetooth board & phone pairing, which command or code executes Inspect BlueZ if installed?Reveal explanation
Implementation recall

sudo apt install -y bluez bluetoothctl list

X7 · 08 / 08For Bluetooth board & phone pairing, which actual output or state confirms the prescribed practical run succeeded, and what does it not establish?Reveal explanation
Evidence & acceptance

Install BlueZ only if needed and run bluetoothctl list. WSL often has no controller or running BlueZ service; record no controller as an environment limitation, not a passed pairing test. Physical Raspberry Pi pairing is separate. Continue to X8 TCP substitute to study the application protocol.

Execution boundary · Not possible on WSL. Browser simulation below is a teaching model, not execution of Python or firmware. The real commands run in VS Code/WSL; Wokwi is used for Arduino/ESP32 where indicated.
Bluetooth adapter. Host controller and pairing.
Bluetooth adapter. Host controller and pairing.
Independent conceptual protocol trace

Animated Lab 7 · Bluetooth board & phone pairing

Use the scenario selector to explore reference, failure and recovery. The animation is explanatory, separate from the actual terminal exercise. Animation timing is for learning, not measured protocol latency.

Recent trace events
    Shared research workbenches · network designer & advanced studies
    Concurrent-device simulation & Monte Carlo research
    Distributed digital twin · topology, protocol & battery research
    Loading experiment-specific apparatus…
    Previous model / additional reference tools
    Simulation task

    Explain the limitations of Bluetooth in WSL.

    Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.

    Interactive engineering workbenchX7 · Existing model
    01 / Explore

    Interactive lab simulation

    Browser model
    X7 · Model-linked instrumentation

    Visual observation lens

    Back to controls ↑

    Original virtual instrument; model signals and execution trace.

    Loading instrument…

    Awaiting model display.

    Experimental instrumentation · A/B

    Compare two model conditions

    Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.

    Open simulation view
    Baseline A
    Not captured
    Comparison B
    Not captured

    Capture a baseline to begin.

    Evidence portfolio →
    V19.0 · Contextual AI workspace

    Ask your engineering assistants

    X7 · current context

    Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.

    Dr. Mohammad · offline
    Dr. Mohammad

    Offline curriculum-grounded assistance.

    Open local tutor
    Lab 7 · Bluetooth board & phone pairing

    Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.

    Prepare a contextual AI prompt

    0 characters

    Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.

    Prepare → review → copy & open your selected provider → paste and submit there.

    Run & verify — acceptance checklist

    Build verification: Source reviewed; Bluetooth controller/WSL pending.

    Install BlueZ only if needed and run bluetoothctl list. WSL often has no controller or running BlueZ service; record no controller as an environment limitation, not a passed pairing test. Physical Raspberry Pi pairing is separate. Continue to X8 TCP substitute to study the application protocol.

    Record the actual output, source (mock/model or physical), and any error. A missing tool, timeout or untested external service is not a pass.

    Complete lab-by-lab verification report →Open automated verification center → Ask Engineering Copilot →

    Independent theoretical exercises

    Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.

    01 · Predict and derive using the given inputs

    At RSSI −55 dBm and a modeled minimum −85 dBm, calculate margin in dB and the corresponding power ratio.

    02 · Compare or justify using evidence

    Draw discovery→pairing→service→authorization. Explain why WSL's TCP substitute does not test the physical Bluetooth radio.

    03 · Scenario analysis

    Scenario analysis · Independent work

    Device A RSSI −60 dBm, B −75 dBm. Calculate relative received power ratio A/B, then explain why stronger signal does not prove pairing success.

    Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.

    Expanded independent theoretical exercise bank

    Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.

    Intermediate · Explain a changed-input result

    Independent theoretical exercise · X7-01

    Use the reference configuration (Device discoverable = true; Pairing succeeds = true; Required service available = true; Fixture RSSI (dBm) = -55; Configured minimum RSSI (dBm) = -85), but change Device discoverable = false. The model reports Discovered = No. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.

    Intermediate · Interpret a state transition

    Independent theoretical exercise · X7-02

    The reference model reports Discovered: Yes. Under Device discoverable = false it reports No. Explain which configured condition changed and what the two outputs establish, and what they do not establish.

    Intermediate · Interpret a technical trace

    Independent theoretical exercise · X7-03

    For Required service available = false, the model supplies this excerpt from Execution observations: Event / item · Observed result Discovery · Yes Pairing · Yes Service · No Count rows whose Observed result value is exactly “Yes”, and identify the displayed row numbers. Explain what the count describes.

    Advanced · Reverse reasoning

    Independent theoretical exercise · X7-04

    An observation is Application session = Unavailable. Candidate A uses Device discoverable = true; Pairing succeeds = true; Required service available = true; Fixture RSSI (dBm) = -55; Configured minimum RSSI (dBm) = -85. Candidate B changes the listed settings (Required service available = false) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.

    Advanced · Diagnose a reported mismatch

    Independent theoretical exercise · X7-05

    A student configures Fixture RSSI (dBm) = -110 while preserving all other reference settings, but copies the reference report of Discovered = Yes. Evaluate whether the report is justified. Identify the first configuration/output check to perform.

    Challenging · Design a controlled verification

    Independent theoretical exercise · X7-06

    Design a controlled comparison for Lab 7 · Bluetooth board & phone pairing using reference Device discoverable = true; Pairing succeeds = true; Required service available = true; Fixture RSSI (dBm) = -55; Configured minimum RSSI (dBm) = -85 and test Device discoverable = false. Specify the changed setting(s), measured metric Discovered, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.

    Step-by-step experimental procedure

    Trace discovery, pairing and application-session availability as separate states.

    1 · Reference workbench configuration

    Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.

    Device discoverableYes
    Pairing succeedsYes
    Required service availableYes
    Fixture RSSI (dBm)-55
    Configured minimum RSSI (dBm)-85

    2 · Perform the investigation in order

    1. Run discovery at −55 dBm and inspect connection phases.
    2. Disable discovery, then restore and reject pairing. Identify first unavailable phase.
    3. Select RSSI below the configured threshold; compare with missing application service.
    4. Use the original Bluetooth practical and distinguish pairing from service connection.

    3 · Compare controlled trials

    TrialIndependent changeExpected checkObservation
    ConnectedUse reference inputs aboveApplication session: ReadyRecord actual result
    Pair failurePairing succeeds = NoApplication session: UnavailableRecord actual result
    Weak signalFixture RSSI (dBm) = -95Application session: UnavailableRecord actual result

    4 · Analyze and report

    This RSSI cutoff is a teaching policy, not a Bluetooth physical-layer guarantee.

    Required evidence: Record the named metrics and trace for the reference and changed cases, then attach the corresponding practical command output or device evidence if available.

    Model boundary: A closed, deterministic browser model. The existing practical instructions and source files provide independent execution; browser results are not hardware measurements.

    Controlled investigation · reproducible evidence

    Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.

    TrialIndependent changeDependent observation
    ConnectedUse reference inputs aboveRecord actual outcome and units
    Pair failurePairing succeeds = NoRecord actual outcome and units
    Weak signalFixture RSSI (dBm) = -95Record actual outcome and units

    Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.

    Loading laboratory-specific procedure…

    Python / Google Colab notebook

    Bounded notebook reference exercise; original device/service commands are reference-only. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.

    Download NotebookOpen Google ColabAll Python notebooks

    Independent implementation sequence

    1. Identify Bluetooth limitations
    2. Inspect BlueZ if installed
    02 / Implement

    Step-by-step instructions

    Before you run / verification gate

    If bluetoothctl cannot connect to a BlueZ service, record that limitation; continue with X8 TCP substitute. No real pairing is required.

    Complete one-time setup first. Copy one command block at a time into the indicated environment. Do not copy prompt characters. Open new terminals where named; variables are terminal-specific. Ctrl+C stops a running foreground command.

    01

    Identify Bluetooth limitations

    WSL has no built-in Pi Bluetooth radio. Wokwi is not used as a Bluetooth SPP bridge. This is a protocol-learning lab, not an actual pairing test.

    Checkpoint Complete the action before continuing.
    02

    Inspect BlueZ if installed

    These commands do not promise a physical adapter.

    WSL · Bash
    sudo apt install -y bluez
    bluetoothctl list
    ✓ Expected: Available Bluetooth controllers are listed if present. WSL may expose none; use the documented TCP substitute instead.
    Expected result for each action (2)
    1. sudo apt install -y bluezPackages are installed or already up to date; the prompt returns. Verify executable availability before using them.
    2. bluetoothctl listAvailable Bluetooth controllers are listed if present. WSL may expose none; use the documented TCP substitute instead.
    Checkpoint A controller may be absent. Use the browser pairing model and Lab 8 TCP substitute. A real Pi/phone is required for actual pairing.

    Experimental notebook

    Record your own results. Values are not prefilled or independently verified.

    03 / Inspect

    Source code and method

    labs/pi-practical/labs/exp07/check_bluetooth.pyDownload source
    PY · source file
    # ------------------------------------------------------------
    # Copyright © 2026/2027 Dr. Mohammad Alja'afreh. All rights reserved.
    # PSUT IoT Engineering Learning Platform
    # ------------------------------------------------------------
    # ====================================================================
    # LAB PURPOSE / CHECK BLUETOOTH
    # ====================================================================
    """Experiment 7: check the Raspberry Pi Bluetooth controller via BlueZ."""
    
    # ====================================================================
    # 01 / IMPORT REQUIRED LIBRARIES
    # ====================================================================
    import subprocess
    
    # ====================================================================
    # 02 / INSPECT THE BLUEZ CONTROLLER
    # ====================================================================
    def main():
        # List available Bluetooth adapters; fail if the command fails.
        subprocess.run(['bluetoothctl','list'], check=True)
        # Display adapter state, address and supported settings.
        subprocess.run(['bluetoothctl','show'], check=True)
        print('Pair a phone using bluetoothctl; follow the Experiment 7 README.')
    
    # ====================================================================
    # PROGRAM ENTRY POINT / RUN THE EXPERIMENT
    # ====================================================================
    if __name__ == '__main__': main()
    
    04 / Verify

    Evidence of completion

    Save the actual terminal output from the checkpoints above. For simulated inputs explicitly record browser model, fakepi, mock or Wokwi. Never present those data as physical measurements. If a checkpoint fails, see the troubleshooting guide.

    Python / Google Colab laboratory

    X7 · 9 notebook cells · 2 executable Python cells

    Complete the theoretical investigation first. Run the cells in order, record actual outputs and compare against your prediction.

    How to execute

    1. Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
    2. Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
    3. Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.

    Execution scope: Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.

    01Instructions · Markdown
    # x7 · Lab 7 · Bluetooth board & phone pairing **PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh** ## Introduction Explain the limitations of Bluetooth in WSL. ## How to run 1. Download this notebook from the laboratory page. Open Google Colab → File → Upload notebook. 2. Select a Python CPU runtime. Run cells from top to bottom using Shift+Enter, or Runtime → Run all. 3. Read the printed observations and assertions. Change one parameter at a time and rerun the relevant cell. 4. Save your own outputs and compare them to the portal Experiment tab. **Execution boundary:** Bounded notebook reference exercise; original device/service commands are reference-only. Do not run the hardware or service commands in Colab. No real credentials are needed. The notebook is self-contained.
    02Instructions · Markdown
    ## Experiment-specific preparation Explain the limitations of Bluetooth in WSL. **Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):** 1. Run discovery at −55 dBm and inspect connection phases. 2. Disable discovery, then restore and reject pairing. Identify first unavailable phase. 3. Select RSSI below the configured threshold; compare with missing application service. 4. Use the original Bluetooth practical and distinguish pairing from service connection. **Evidence:** **Boundary:**
    03Instructions · Markdown
    ## 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implemented, and explain any discrepancy. - Distinguish actual local Python execution from mock, physical and external-service observations. ## 2. Environment check
    04Python · executable cell
    PYTHON · Code cell
    # =====================================================================
    # X7 | Code cell 01 | Lab 7 · Bluetooth board & phone pairing
    # Purpose: 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implem
    # Inputs: the explicit fixture/settings below and any preceding cell state.
    # Output: inspect printed values, returned records or assertions; record evidence.
    # =====================================================================
    import sys
    print("Python",sys.version.split()[0])
    # Check the expected invariant so a mismatch fails visibly instead of appearing successful.
    assert sys.version_info >= (3,10)
    
    Ask Dr. Mohammad about this cell
    05Instructions · Markdown
    ## 3. Implementation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
    06Python · executable cell
    PYTHON · Code cell
    # =====================================================================
    # X7 | Code cell 02 | Lab 7 · Bluetooth board & phone pairing
    # Purpose: 3. Implementation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
    # Inputs: the explicit fixture/settings below and any preceding cell state.
    # Output: inspect printed values, returned records or assertions; record evidence.
    # =====================================================================
    # Closed fixture: distinguish discovery from pairing; no Bluetooth radio access.
    devices=[{'id':'demo-sensor','paired':False},{'id':'demo-phone','paired':True}]
    # Check the expected invariant so a mismatch fails visibly instead of appearing successful.
    print('Discovered:',[d['id'] for d in devices]);print('Paired:',[d['id'] for d in devices if d['paired']]);assert sum(d['paired'] for d in devices)==1
    
    Ask Dr. Mohammad about this cell
    07Instructions · Markdown
    ## Original portal implementation (reference only) These are the actual laboratory snippets. They are retained for comparison; follow the portal setup for WSL, hardware or services. They are **not** executed by Run all. ```python # ------------------------------------------------------------ # Copyright © 2026/2027 Dr. Mohammad Alja'afreh. All rights reserved. # PSUT IoT Engineering Learning Platform # ------------------------------------------------------------ # ==================================================================== # LAB PURPOSE / CHECK BLUETOOTH # ==================================================================== """Experiment 7: check the Raspberry Pi Bluetooth controller via BlueZ.""" # ==================================================================== # 01 / IMPORT REQUIRED LIBRARIES # ==================================================================== import subprocess # ==================================================================== # 02 / INSPECT THE BLUEZ CONTROLLER # ==================================================================== def main(): # List available Bluetooth adapters; fail if the command fails. subprocess.run(['bluetoothctl','list'], check=True) # Display adapter state, address and supported settings. subprocess.run(['bluetoothctl','show'], check=True) print('Pair a phone using bluetoothctl; follow the Experiment 7 README.') # ==================================================================== # PROGRAM ENTRY POINT / RUN THE EXPERIMENT # ==================================================================== if __name__ == '__main__': main() ```
    08Instructions · Markdown
    ## 4. Results and analysis Record the actual output and whether the assertions pass. Identify a parameter to vary, state your prediction, repeat the reference calculation, then explain the changed result. | Trial | Configuration | Observation | Interpretation | |---|---|---|---| | A | Reference | | | | B | One controlled change | | | | C | Reference repeat | | | **Limitations:** Bounded notebook reference exercise; original device/service commands are reference-only. Notebook success does not certify external equipment or services.
    09Instructions · Markdown
    ## Guided reasoning and evidence A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above. **Independent task:** 2. Disable discovery, then restore and reject pairing. Identify first unavailable phase. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat. | Trial | Input/configuration | Prediction | Observation | Evidence / limitation | |---|---|---|---|---| | A | Reference | | | | | B | Changed input | | | | | A repeat | Reference | | | | A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.