<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Shantanu]]></title><description><![CDATA[Some technical blogs I write after accomplishing something or based on observations.]]></description><link>https://shaxntanu.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b0a762e1551beb5c5821976/aab24c1a-2e88-4caf-8b24-792077ffc842.jpg</url><title>Shantanu</title><link>https://shaxntanu.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 30 Nov 2026 22:33:42 GMT</lastBuildDate><atom:link href="https://shaxntanu.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[When a CircuitPython Module Becomes a Package: Fixing Circup Updates]]></title><description><![CDATA[How Circup handles a library changing from a single module file to a package, with disk and Web Workflow paths covered.]]></description><link>https://shaxntanu.hashnode.dev/when-a-circuitpython-module-becomes-a-package-fixing-circup-updates</link><guid isPermaLink="true">https://shaxntanu.hashnode.dev/when-a-circuitpython-module-becomes-a-package-fixing-circup-updates</guid><category><![CDATA[circup]]></category><category><![CDATA[adafruit]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Shantanu]]></dc:creator><pubDate>Sun, 29 Nov 2026 04:49:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/bbc2708c-b2be-4b41-a0e9-9d545613d911.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>When an installed CircuitPython library changes from a single module file into a package directory, Circup has to replace the old file with the new package.</em></p>
<p>Circup installs and updates libraries from the CircuitPython bundle. A library can be distributed as one module, such as <code>foo.py</code>, or as a package directory containing <code>__init__.py</code> and related modules.</p>
<p>That creates an update edge case: a library that was installed as a single file can later be reorganized as a package. The update needs to remove the old file and copy the package directory into place.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/3ace7a53-bc9f-4389-800f-68995b863c6f.png" alt="Figure 1. Circup replaces an installed single-file library module with the package directory from the CircuitPython bundle." style="display:block;margin:0 auto" />

<p><em>Figure 1. File-to-package transition handled by Circup: the prior module file is replaced by the library's package directory.</em></p>
<h2>The file-to-package transition</h2>
<p>A simplified example is:</p>
<pre><code class="language-text">Before: adafruit_emc2101.py
After:  adafruit_emc2101/
</code></pre>
<p>The names still refer to the same library, but the filesystem object has changed from a file to a directory. An updater that keeps resolving the old bundle path can try to handle the package as if it were still a file.</p>
<h2>What the pull request changes</h2>
<p><a href="https://github.com/adafruit/circup/pull/290">Adafruit Circup PR #290</a> updates path resolution so Circup can install a package after the old single-file module is removed. The change covers both the local disk backend and the Web Workflow backend.</p>
<p>The requested update can still use Circup’s existing command:</p>
<pre><code class="language-console">circup install --update adafruit_emc2101
</code></pre>
<p>The fix is intended to handle the transition without changing how users choose or install libraries.</p>
<h2>Regression coverage</h2>
<p>The review discussion asked for tests to use a real package from the bundle rather than a mocked empty module. The revised tests use <code>adafruit_emc2101</code>, create the old single-file form on the test device, run the update, and check that the old file is replaced by the package. The disk and Web Workflow paths are both covered.</p>
<p>The PR description reports four focused Windows regression cases passing, 68 passing tests, and five failures in unchanged tests during the full Windows suite. It lists Linux CI as pending. These results come from the PR description and were not independently rerun for this article.</p>
<h2>Review status</h2>
<p>As of 29 November 2026, PR #290 remains open and unmerged. The revised tests use the real <code>adafruit_emc2101</code> package to cover both disk and Web Workflow paths, as requested in review. The current PR description lists Linux CI as pending. This article describes work under review, not an accepted or released change. The issue linked from the pull request is <a href="https://github.com/adafruit/circup/issues/100">#100</a>.</p>
<h2>References</h2>
<ul>
<li><a href="https://github.com/adafruit/circup/pull/290">Adafruit Circup PR #290: Handle updates when a module becomes a package</a></li>
<li><a href="https://github.com/adafruit/circup/issues/100">Circup issue #100</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Tracking Progress in Long CircuitPython Library Updates]]></title><description><![CDATA[How Circup's progress indicator shows the current module position in long library update runs.]]></description><link>https://shaxntanu.hashnode.dev/tracking-progress-in-long-circuitpython-library-updates</link><guid isPermaLink="true">https://shaxntanu.hashnode.dev/tracking-progress-in-long-circuitpython-library-updates</guid><category><![CDATA[circup]]></category><category><![CDATA[circuitpython]]></category><dc:creator><![CDATA[Shantanu]]></dc:creator><pubDate>Sun, 29 Nov 2026 04:47:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/98aec150-d2a2-481b-b0c7-ca38e74f065a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p><em>Circup now shows each module’s position in the update list, making long update runs easier to follow.</em></p>
<p>CircuitPython is Python for microcontrollers. Adafruit and other contributors publish libraries that let a board use sensors, displays, motors, and other hardware without every project having to write those drivers from scratch. Circup is the command-line tool that installs and updates those libraries.</p>
<p>When a project has many libraries installed, <code>circup update --all</code> can take a while. Circup already printed a line when each update succeeded, but the output did not show how far through the planned work it had reached. A list of names told me what had finished, not where I was in the list.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/72ae3f87-4b21-4708-8b24-a6a02011c9f4.png" alt="Figure 1. Circup displays the current module position and total update count in terminal output." style="display:block;margin:0 auto" />

<p><em>Figure 1. The progress indicator reports a module's position in the pending update list.</em></p>
<h2>The change</h2>
<p>The update command now numbers each successful update by its position in the list of modules that need work. For example:</p>
<pre><code class="language-text">5/389 Updated adafruit_gps
</code></pre>
<p>The implementation uses the list that Circup has already built:</p>
<pre><code class="language-python">for index, module in enumerate(modules_to_update, start=1):
    ...
    click.echo(f"{index}/{len(modules_to_update)} Updated {module.name}")
</code></pre>
<p>If there are <code>n</code> modules to update, the displayed position <code>i</code> is in the range <code>1 ≤ i ≤ n</code>.</p>
<p>This is a list position, not a count of successful updates. The index advances through the planned list even if an earlier item is skipped or fails. That keeps later messages tied to the same module position rather than making the count look like a success tally.</p>
<h2>Why a small counter helps</h2>
<p>During a long update, the operator can estimate how much of the original work list remains. The counter also gives a quick way to relate terminal output to a log or a reported failure. The command still updates the same modules in the same order, and the counter does not change success or failure behavior.</p>
<p>The implementation stays in the existing loop. It does not add a progress-bar dependency, keep a second count, or alter module selection. The total comes directly from <code>modules_to_update</code>, so the numerator and denominator describe the same work list.</p>
<h2>Review and merge</h2>
<p>I submitted this change as <a href="https://github.com/shaxntanu">@shaxntanu</a>. <a href="https://github.com/FoamyGuy">@FoamyGuy</a> reviewed the behavior, suggested dropping a standalone test that was not needed, and later approved the updated PR. <a href="https://github.com/FoamyGuy">@FoamyGuy</a> merged the contribution into Adafruit’s Circup repository.</p>
<h2>Validation</h2>
<p>During review, the maintainer asked to drop the standalone test case, so the final diff keeps the implementation in the existing update loop. The PR’s validation notes report a targeted CLI check, and the hosted GitHub Actions <code>test</code> job passed. The full local Windows run reported 65 passing tests and five failures in unchanged path-format and CLI/network-sensitive tests.</p>
<p>The contribution was merged in <a href="https://github.com/adafruit/circup/pull/291">Adafruit Circup PR #291</a>, fixing <a href="https://github.com/adafruit/circup/issues/273">issue #273</a>.</p>
<h2>What I took away</h2>
<p>A useful progress indicator does not need to own the update process. Reusing the order already present in the program made the output clearer with a small change and without changing what Circup updates.</p>
<h2>References</h2>
<ul>
<li><a href="https://github.com/adafruit/circup/pull/291">Merged PR #291: Show progress when updating multiple modules</a></li>
<li><a href="https://github.com/adafruit/circup/issues/273">Issue #273</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[A Safe, Confirmed Way to Clear Circup’s Local Cache]]></title><description><![CDATA[How Adafruit Circup's clear-cache command confirms before deleting downloaded bundle data and local settings.]]></description><link>https://shaxntanu.hashnode.dev/a-safe-confirmed-way-to-clear-circup-s-local-cache</link><guid isPermaLink="true">https://shaxntanu.hashnode.dev/a-safe-confirmed-way-to-clear-circup-s-local-cache</guid><category><![CDATA[circup]]></category><category><![CDATA[adafruit]]></category><dc:creator><![CDATA[Shantanu]]></dc:creator><pubDate>Sun, 29 Nov 2026 04:47:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/70e2efea-6a17-4e72-a47d-447a3dbb8ead.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p><strong>The new</strong> <code>circup clear-cache</code> <strong>command removes saved bundle data after an explicit confirmation.</strong></p>
<p>CircuitPython is Python that runs on microcontroller boards. To install a sensor or display library, developers often use Circup, Adafruit’s command-line tool for managing CircuitPython libraries. Circup keeps data on the computer as well as files on the board, including downloaded bundles and local bundle settings.</p>
<p>Before this change, there was no direct Circup command for clearing that local data. Removing it manually meant finding the right directory and knowing which files were safe to delete. The new command provides a clear, confirmable way to reset Circup’s local data.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/4134c541-2535-4613-b12d-f41626ff8fe9.png" alt="Figure 1. Circup checks for local data, requests confirmation, and removes the cache only after acceptance." style="display:block;margin:0 auto" />

<p><em>Figure 1. Cache removal is gated by explicit confirmation; declining the prompt preserves local data.</em></p>
<h2>The command</h2>
<p>Run <code>circup clear-cache</code>. Circup checks whether its data directory exists. If it does not, the command reports that the cache is already empty. If it does exist, Click asks for confirmation before the directory is removed. Declining the prompt stops the operation and preserves the saved data.</p>
<p>The command is marked as boardless, so it can run without a CircuitPython device connected. It removes Circup’s data on the computer. It does not uninstall libraries from a board that has already been connected.</p>
<h2>Why confirmation matters</h2>
<p>The cache includes local bundle settings as well as downloaded files. Removing it can mean downloading bundles again and restoring any local bundle choices. The confirmation prompt makes that effect visible before deletion.</p>
<p>The behavior is intentionally narrow: if the directory is missing, return a useful message; otherwise, ask and remove the Circup data directory only after the user accepts.</p>
<pre><code class="language-python">if not os.path.exists(DATA_DIR):
    click.echo("Circup cache is already empty.")
    return
</code></pre>
<pre><code class="language-python">click.confirm(
    "This removes downloaded bundles and local bundle settings. Continue?",
    abort=True,
)
shutil.rmtree(DATA_DIR)
</code></pre>
<p>The README’s <code>circup --help</code> example was refreshed at the same time. A regression check compares the documented help output with the actual CLI, so future commands and options are less likely to leave the example stale.</p>
<h2>Review and merge</h2>
<p>I submitted this change as <a href="https://github.com/shaxntanu">@shaxntanu</a>. <a href="https://github.com/dhalbert">@dhalbert</a> reviewed the change, raised merge conflicts, and then approved the updated PR. <a href="https://github.com/dhalbert">@dhalbert</a> merged it into Adafruit’s Circup repository.</p>
<h2>Validation</h2>
<p>Tests cover clearing data after confirmation, preserving it when the prompt is declined, and keeping the README help example synchronized. The hosted GitHub Actions <code>test</code> job passed. The full local Windows run reported 67 passing tests and five failures in unchanged path-format and CLI error-code assertions.</p>
<p>The change was merged in <a href="https://github.com/adafruit/circup/pull/292">Adafruit Circup PR #292</a>, addressing <a href="https://github.com/adafruit/circup/issues/221">issue #221</a> and <a href="https://github.com/adafruit/circup/issues/170">issue #170</a>.</p>
<h2>What I took away</h2>
<p>Convenience commands still need to make their scope clear. Here, a short prompt tells the user what local data will go away, while leaving the libraries already installed on a board alone.</p>
<h2>References</h2>
<ul>
<li><a href="https://github.com/adafruit/circup/pull/292">Merged PR #292: Add clear-cache command and sync README help</a></li>
<li><a href="https://github.com/adafruit/circup/issues/221">Issue #221</a></li>
<li><a href="https://github.com/adafruit/circup/issues/170">Issue #170</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Making Circup’s Terminal Colors Clearer on Dark Backgrounds]]></title><description><![CDATA[How Circup uses bright ANSI red and green to improve visibility in dark themes, with palette-dependent contrast on white.]]></description><link>https://shaxntanu.hashnode.dev/making-circup-s-terminal-colors-clearer-on-dark-backgrounds</link><guid isPermaLink="true">https://shaxntanu.hashnode.dev/making-circup-s-terminal-colors-clearer-on-dark-backgrounds</guid><category><![CDATA[circup]]></category><category><![CDATA[adafruit]]></category><dc:creator><![CDATA[Shantanu]]></dc:creator><pubDate>Sun, 29 Nov 2026 04:46:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/f0b672f8-ce39-4916-a2b0-cdfd6cf04389.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p><strong>A small ANSI color change improves visibility on dark terminal backgrounds, with a palette-dependent trade-off on white.</strong></p>
<p>CircuitPython runs Python programs directly on microcontroller boards. Circup is Adafruit’s command-line tool for installing and updating CircuitPython libraries. Like many command-line tools, it uses color to make errors, warnings, and status messages easier to scan.</p>
<p>The standard red and green colors were difficult to see in some dark terminal themes. The contribution changed those existing messages to Click’s bright red and bright green variants. The message text and command behavior stayed the same.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/ff2cc268-12bd-4cca-9138-5f6141c03747.png" alt="Figure 1. Comparison of standard and bright ANSI red and green across terminal backgrounds; rendered colors depend on the active palette." style="display:block;margin:0 auto" />

<p><em>Figure 1. Bright ANSI variants select palette entries 91 and 92; their contrast depends on the terminal theme and background.</em></p>
<h2>From standard to bright ANSI colors</h2>
<p>The core edit is a color name change:</p>
<pre><code class="language-python">click.secho("Could not install a library", fg="bright_red")
click.secho("default-bundle", fg="bright_green")
</code></pre>
<p>In common ANSI palettes, standard red and green use codes 31 and 32. The bright variants use 91 and 92:</p>
<table>
<thead>
<tr>
<th>Color</th>
<th align="right">Standard ANSI code</th>
<th align="right">Bright ANSI code</th>
</tr>
</thead>
<tbody><tr>
<td>Red</td>
<td align="right">31</td>
<td align="right">91</td>
</tr>
<tr>
<td>Green</td>
<td align="right">32</td>
<td align="right">92</td>
</tr>
</tbody></table>
<p>The change applies to Circup’s existing error and warning messages, along with green status text. It does not add a new output mode or change when Circup emits a message.</p>
<h2>Color depends on the terminal</h2>
<p>ANSI codes select palette entries. A terminal theme decides what those entries look like, so the same code can have different contrast on different backgrounds. The PR discussion includes a before-and-after rendering on a white background. In the Windows Terminal Campbell palette, bright green looked lighter and had lower contrast on white, even though the target was to improve visibility on dark backgrounds.</p>
<p>That comparison is useful context: changing to a brighter ANSI color is not a universal contrast fix. The result depends on the user’s palette. The maintainer reviewed the light-background comparison and approved the change. <a href="https://github.com/adafruit/circup/pull/293#issuecomment-6889666515">View the before-and-after rendering and review discussion</a>.</p>
<h2>Review and merge</h2>
<p>I submitted this change as <a href="https://github.com/shaxntanu">@shaxntanu</a>. <a href="https://github.com/dhalbert">@dhalbert</a> asked for a before-and-after view on a white background. I posted a rendering with Windows Terminal’s Campbell palette and noted that bright green had lower contrast on white. <a href="https://github.com/dhalbert">@dhalbert</a> reviewed the comparison, approved the change, and merged it into Adafruit’s Circup repository.</p>
<h2>Validation</h2>
<p>Two focused CLI tests check the ANSI sequences emitted for red and green output. The hosted GitHub Actions <code>test</code> job passed. The full local Windows run reported 66 passing tests and five failures in unchanged path-format and install-error assertions.</p>
<p>The change was merged in <a href="https://github.com/adafruit/circup/pull/293">Adafruit Circup PR #293</a>, fixing <a href="https://github.com/adafruit/circup/issues/267">issue #267</a>.</p>
<h2>What I took away</h2>
<p>Terminal colors are a small interface detail with real usability impact, but there is no single palette that looks identical everywhere. The change improves the dark-background case it targeted, and the review discussion records what the same colors look like on a white background.</p>
<h2>References</h2>
<ul>
<li><a href="https://github.com/adafruit/circup/pull/293">Merged PR #293: Improve terminal color contrast</a></li>
<li><a href="https://github.com/adafruit/circup/issues/267">Issue #267</a></li>
<li><a href="https://github.com/adafruit/circup/pull/293#issuecomment-6889666515">Before-and-after palette comparison</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Pairing a CircuitPython Version with Its Board ID in Circup]]></title><description><![CDATA[A Circup fix keeps the manually supplied CircuitPython version and board ID together for correct backend compatibility checks.]]></description><link>https://shaxntanu.hashnode.dev/pairing-a-circuitpython-version-with-its-board-id-in-circup</link><guid isPermaLink="true">https://shaxntanu.hashnode.dev/pairing-a-circuitpython-version-with-its-board-id-in-circup</guid><category><![CDATA[circup]]></category><category><![CDATA[circuitpython]]></category><category><![CDATA[cli]]></category><category><![CDATA[adafruit]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Shantanu]]></dc:creator><pubDate>Sun, 29 Nov 2026 04:45:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/0d97eb02-3688-4a21-81c7-53b6b18c425b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p><em>A local-device fix keeps both manual values together so Circup’s backend can check compiled-library compatibility correctly.</em></p>
<p>CircuitPython is Python for microcontroller boards. Circup, Adafruit’s command-line library manager, needs to know which board and CircuitPython version it is working with. That information helps it choose compatible libraries, including compiled <code>.mpy</code> files.</p>
<p>Usually Circup can detect the device details. But when a local device path does not provide the metadata Circup needs, a developer can pass it manually with <code>--cpy-version</code> and <code>--board-id</code>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/fd7e6c33-341b-482c-ab82-c5fa02dd5e78.png" alt="Figure 1. Circup forms a manual version and board-ID tuple before passing it to the selected backend." style="display:block;margin:0 auto" />

<p><em>Figure 1. The values travel together as (CircuitPython version, board ID), matching the backend's expected data shape.</em></p>
<h2>The bug</h2>
<p>When both options were supplied, Circup passed only the version string to the backend. The backend API expects a pair: the CircuitPython version and the board identifier. Later, the MPY compatibility check treated the string as if it were that pair. This could make <code>list</code> or <code>update</code> fail for local paths.</p>
<p>The intended input is:</p>
<pre><code class="language-bash">circup --path /path/to/CIRCUITPY --cpy-version 11.0.0 --board-id fake list
</code></pre>
<p>The fix creates a tuple only when both values are present:</p>
<pre><code class="language-python">version_override = (
    (cpy_version, board_id)
    if cpy_version is not None and board_id is not None
    else None
)
</code></pre>
<p>The same tuple is passed to either the Web Workflow backend or the disk backend. That keeps the values in the shape the backend already expects and leaves automatic detection unchanged.</p>
<h2>Why the pair matters</h2>
<p>The CircuitPython version describes the firmware release. The board ID identifies the target board. Compiled modules may be specific to both. Passing one string where a two-value input is expected loses that relationship and can break the compatibility check.</p>
<p>Conceptually, the override is the ordered pair:</p>
<p><code>version_override = (CircuitPython version, board ID)</code></p>
<p>For example, a version by itself is not the complete manual override. Circup uses the pair when both flags are supplied, then hands that pair to the selected backend.</p>
<h2>Review and merge</h2>
<p>I submitted this change as <a href="https://github.com/shaxntanu">@shaxntanu</a>. During review, <a href="https://github.com/FoamyGuy">@FoamyGuy</a> noted that CircuitPython 8.0.0 was no longer supported and asked me to use 11.0.0 instead. After I updated the example and regression test, <a href="https://github.com/FoamyGuy">@FoamyGuy</a> approved and merged the PR.</p>
<h2>Validation</h2>
<p>A regression test checks that the backend receives <code>("11.0.0", "fake")</code> when both flags are provided. The hosted GitHub Actions <code>test</code> job passed. The full local Windows run reported 65 passing tests and five failures in unchanged path-format and CLI/network-sensitive tests.</p>
<p>The fix was merged in <a href="https://github.com/adafruit/circup/pull/294">Adafruit Circup PR #294</a>, addressing <a href="https://github.com/adafruit/circup/issues/220">issue #220</a>.</p>
<h2>What I took away</h2>
<p>Small data-shape mismatches can travel a long way before failing. This fix keeps the version and board ID together at the point where Circup creates the backend, so later compatibility checks receive the information they were designed to use.</p>
<h2>References</h2>
<ul>
<li><a href="https://github.com/adafruit/circup/pull/294">Merged PR #294: Fix updates with manual local device version</a></li>
<li><a href="https://github.com/adafruit/circup/issues/220">Issue #220</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[What Is My Pico W Connected To?]]></title><description><![CDATA[How Adafruit CircuitPython's Pico W and Pico 2 W wifi.radio.ap_info exposes the connected access point and improves network-state diagnostics.]]></description><link>https://shaxntanu.hashnode.dev/what-is-my-pico-w-connected-to</link><guid isPermaLink="true">https://shaxntanu.hashnode.dev/what-is-my-pico-w-connected-to</guid><category><![CDATA[Open Source]]></category><category><![CDATA[Python]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Electronics]]></category><category><![CDATA[adafruit]]></category><dc:creator><![CDATA[Shantanu]]></dc:creator><pubDate>Sun, 29 Nov 2026 04:43:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/a75cf362-c219-4a3e-ac04-af3e3fa713f7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a href="https://docs.circuitpython.org/en/latest/README.html">CircuitPython</a> is an open-source, beginner-friendly version of Python for microcontrollers, developed by Adafruit. A microcontroller is a small computer on an electronics board. It can read sensors and control parts such as LEDs. With CircuitPython, you write a Python script and save it to the board, where it runs directly on the hardware. A few lines of code might blink an LED, read a temperature sensor, or, on the Pico W, use Wi-Fi.</p>
<p>When a microcontroller says it is connected to Wi-Fi, I still want to know which access point it joined, what signal it sees, and which channel it is using. That information can make the difference between guessing at a network problem and understanding it.</p>
<p><a href="https://www.adafruit.com">Adafruit</a>’s CircuitPython project exposes connected-network details through <code>wifi.radio.ap_info</code>. When connected, it returns a <code>wifi.Network</code> object. When disconnected, it returns <code>None</code>. On the Raspberry Pi Pico W port, however, reading <code>ap_info</code> used to raise <code>NotImplementedError</code>. <a href="https://github.com/adafruit/circuitpython/issues/9323">Issue #9323</a> reported the missing implementation. <a href="https://github.com/adafruit/circuitpython/issues/11030">Issue #11030</a> separately requested the connected-network signal strength for the Pico 2 W.</p>
<h2>My contribution and the merged follow-up</h2>
<p>I opened <a href="https://github.com/adafruit/circuitpython/pull/11625">PR #11625</a> with an initial implementation of <code>wifi.radio.ap_info</code> for the Raspberry Pi port. My PR was closed without merging. A later implementation, <a href="https://github.com/adafruit/circuitpython/pull/11646">PR #11646</a>, was authored by <a href="https://github.com/mikeysklar">@mikeysklar</a> and merged into <a href="https://github.com/adafruit/circuitpython">CircuitPython</a> on October 25, 2026. Its description credits my earlier PR for taking the same approach.</p>
<p>To be precise about the history, I contributed the initial implementation and design direction. <a href="https://github.com/mikeysklar">@mikeysklar</a> authored the merged follow-up, fixed two related bugs, and reported the hardware test results described below. The PR history records approval and merge by <a href="https://github.com/dhalbert">@dhalbert</a>, a CircuitPython core developer.</p>
<p><strong>PR status: merged.</strong></p>
<h2>What <code>ap_info</code> gives an application</h2>
<p>The API returns a <code>wifi.Network</code> object or <code>None</code>. A small diagnostic script can inspect the active connection:</p>
<pre><code class="language-python">import wifi

ap = wifi.radio.ap_info
if ap is None:
    print("Not connected")
else:
    print("SSID:", ap.ssid)
    print("BSSID:", ":".join(f"{byte:02x}" for byte in ap.bssid))
    print("Channel:", ap.channel)
    print("RSSI:", ap.rssi)
    print("Security:", ap.authmode)
    print("Country:", repr(ap.country))
</code></pre>
<p>The SSID is the network name. The BSSID identifies the access point radio, usually by its MAC address, helping distinguish among several access points that share one SSID. RSSI and channel can help explain why the same device behaves differently across rooms or routers.</p>
<p>RSSI is often expressed in dBm, a logarithmic power unit. To convert a value in dBm to milliwatts:</p>
<p>\(P_{\mathrm{mW}} = 10^{R_{\mathrm{dBm}}/10}\)</p>
<p>For example, \(-60\,\mathrm{dBm} = 10^{-6}\,\mathrm{mW} = 1\,\mathrm{nW}\).</p>
<p>This equation is the background for interpreting an RSSI reading. The CircuitPython change returns the CYW43 driver’s RSSI value and does not perform this conversion itself.</p>
<h2>A few implementation details that mattered</h2>
<p>The Pico W uses the CYW43 Wi-Fi driver. The merged change first checks whether the station link is up. If it is not, <code>ap_info</code> returns <code>None</code>. If it is connected, the code assembles a <code>wifi.Network</code> record from the current SSID and driver data: channel from the CYW43 channel query, RSSI from <code>cyw43_wifi_get_rssi</code>, and BSSID from <code>cyw43_wifi_get_bssid</code>.</p>
<p>There is a timing wrinkle: the CYW43 join is asynchronous. A call to <code>connect()</code> can time out even though the join continues in the background. The merged implementation records the target SSID and whether a password was supplied before starting the join. That gives <code>ap_info</code> enough context if the link comes up after the call times out.</p>
<p>The follow-up also fixed stale IPv4 state when switching networks. If DHCP had supplied an address, stopping the station now clears that old address before the next connection waits for a lease. The intended state sequence is <code>AP A with IP_A → disconnect and clear old IP → AP B with IP_B</code>.</p>
<p>Without clearing the old address, a program could briefly observe AP A’s IP after it had started switching to AP B. The PR’s test report states that the regression was reproduced on the base branch and was resolved after the change.</p>
<p>A smaller Python object bug affected <code>wifi.Network.country</code>. The implementation had returned the raw empty-string QSTR as if it were already a Python object. Wrapping it with <code>MP_OBJ_NEW_QSTR(MP_QSTR_)</code> returns the empty string <code>''</code> with the correct object representation instead of integer <code>0</code>.</p>
<h2>What the reported tests found</h2>
<p>The results below come from <a href="https://github.com/mikeysklar">@mikeysklar</a>’s <a href="https://github.com/adafruit/circuitpython/pull/11646">PR #11646 description</a>, which states that the tests were run on their board farm. I did not run these hardware tests myself.</p>
<table>
<thead>
<tr>
<th>Check reported in PR #11646</th>
<th>Base branch</th>
<th>Pico W</th>
<th>Pico 2 W</th>
</tr>
</thead>
<tbody><tr>
<td>Smoke checks across scan, HTTP, HTTPS, ping, and mDNS (10 runs)</td>
<td>Not reported</td>
<td>100/100</td>
<td>100/100</td>
</tr>
<tr>
<td><code>ap_info</code> on home, open, and WPA2 networks</td>
<td>Not reported</td>
<td>Pass</td>
<td>Pass</td>
</tr>
<tr>
<td>Correct IP after switching networks (20 runs)</td>
<td>0/20</td>
<td>20/20</td>
<td>20/20</td>
</tr>
<tr>
<td><code>ap_info</code> after a timed-out <code>connect()</code> (5 runs)</td>
<td>Not reported</td>
<td>5/5</td>
<td>5/5</td>
</tr>
<tr>
<td>Same-network reconnect median</td>
<td>2.97 s</td>
<td>3.96 s</td>
<td>3.97 s</td>
</tr>
<tr>
<td>1,000 pings and three AP start/stop cycles</td>
<td>Not reported</td>
<td>Pass</td>
<td>Pass</td>
</tr>
</tbody></table>
<p>WPA3, enterprise authentication, and roaming were not tested.</p>
<p>The author also reported median same-network reconnect times of 2.97 seconds on the base branch, 3.96 seconds on Pico W, and 3.97 seconds on Pico 2 W.</p>
<p>The reported differences are <code>3.96 - 2.97 = 0.99 s</code> and <code>3.97 - 2.97 = 1.00 s</code>. That is about one extra second in the reported median for same-network reconnects. It is a measured trade-off in this test setup, not a guarantee for every router or deployment.</p>
<p>GitHub Actions shows the PR’s build workflow as successful, with 15 boards built. The Pico W and Pico 2 W board builds are included in the run.</p>
<h2>What I took away</h2>
<p>This work reminded me that a network API is only as useful as the state behind it. A correct <code>ap_info</code> needs to describe the link that is actually up, even when connection work is asynchronous. A correct IP property must stop exposing a lease from a network the device has already left. Testing those transitions mattered as much as testing the happy path.</p>
<p>My first PR did not merge, but the follow-up incorporated the same core approach, expanded the fix, and credited the earlier work. An open-source contribution can shape a solution, even when the final patch lands in another PR. Thanks to <a href="https://github.com/mikeysklar">@mikeysklar</a> for carrying the implementation through hardware testing and for the acknowledgement, and to the CircuitPython maintainers for reviewing the API behaviour.</p>
<h2>Figures</h2>
<p>The figures pair an RSSI conversion and network-state visualisation with reported test results and a screenshot of the merged PR. The hardware measurements are attributed to <a href="https://github.com/mikeysklar">@mikeysklar</a> and <a href="https://github.com/adafruit/circuitpython/pull/11646">PR #11646</a>.</p>
<img src="https://cdn-images-1.medium.com/max/800/1*7_2LbbhwzsNBOmr9krUcwg.png" alt="RSSI conversion from dBm to power." style="display:block;margin:0 auto" />

<p><em>Figure 1. RSSI conversion from dBm to power. At -60 dBm, the received power is 1 nW. CircuitPython returns the driver’s RSSI value without performing this conversion.</em></p>
<img src="https://cdn-images-1.medium.com/max/800/1*hbnmMy1iK5SLxQ8DKxkynQ.png" alt="Network-switch IP checks reported in PR #11646." style="display:block;margin:0 auto" />

<p><em>Figure 2. Network-switch IP checks reported in</em> <a href="https://github.com/adafruit/circuitpython/pull/11646"><em>PR #11646</em></a><em>. After the change, both boards reported the expected address in 20/20 runs; the base branch reported 0/20.</em></p>
<img src="https://cdn-images-1.medium.com/max/800/1*hPiK1aj7z4Fw7Bgw4Xuc9g.png" alt="Median same-network reconnect times reported in PR #11646." style="display:block;margin:0 auto" />

<p><em>Figure 3. Median same-network reconnect times reported in</em> <a href="https://github.com/adafruit/circuitpython/pull/11646"><em>PR #11646</em></a><em>: 2.97 s on the base branch, 3.96 s on Pico W, and 3.97 s on Pico 2 W. These values are specific to the reported test setup.</em></p>
<img src="https://cdn-images-1.medium.com/max/800/1*TKDd1_HQUCMnbphaLvX73g.png" alt="Dark-mode screenshot of the merged CircuitPython PR #11646, including the reported Pico W and Pico 2 W results." style="display:block;margin:0 auto" />

<p><em>Figure 4. Screenshot of</em> <a href="https://github.com/adafruit/circuitpython/pull/11646"><em>CircuitPython PR #11646</em></a><em>. It shows the merged status and validation results reported for Pico W and Pico 2 W.</em></p>
<h2>References</h2>
<ul>
<li><a href="https://github.com/adafruit/circuitpython/pull/11646">Merged PR #11646: Pico W boards report the connected network and fix two Wi-Fi bugs</a></li>
<li><a href="https://github.com/adafruit/circuitpython/pull/11625">My initial PR #11625: implement wifi.radio.ap_info for Raspberry Pi</a></li>
<li><a href="https://github.com/adafruit/circuitpython/issues/9323">Issue #9323: wifi.radio.ap_info was not implemented on Pico W</a></li>
<li><a href="https://github.com/adafruit/circuitpython/issues/11030">Issue #11030: Wi-Fi signal strength on the Pico 2 W port</a></li>
<li><a href="https://docs.circuitpython.org/en/latest/shared-bindings/wifi/">CircuitPython wifi API documentation</a></li>
<li><a href="https://www.raspberrypi.com/documentation/pico-sdk/networking.html">Raspberry Pi Pico SDK networking documentation for CYW43</a></li>
<li><a href="https://www.cisco.com/c/en/us/support/docs/wireless-mobility/wireless-lan-wlan/23231-powervalues-23231.html">Cisco RF power values: dB and dBm conversion</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Qwen CLI Has a Sense of Humour…]]></title><description><![CDATA[A short look at three unexpected Qwen CLI status messages and the humor they bring to everyday coding work.]]></description><link>https://shaxntanu.hashnode.dev/qwen-cli-has-a-sense-of-humour</link><guid isPermaLink="true">https://shaxntanu.hashnode.dev/qwen-cli-has-a-sense-of-humour</guid><category><![CDATA[AI]]></category><category><![CDATA[#qwen]]></category><category><![CDATA[coding]]></category><category><![CDATA[cli]]></category><dc:creator><![CDATA[Shantanu]]></dc:creator><pubDate>Sun, 29 Nov 2026 04:41:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/acc5c7c6-85b0-4ee9-aa2d-cb2624592c13.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One thing I’m genuinely enjoying when using <a href="https://qwen.ai/qwencode"><strong>Qwen CLI</strong></a> is that it sometimes forgets it’s supposed to be a coding assistant and starts talking like a mildly unhinged coworker.</p>
<p>You’ll be sitting there waiting for it to finish implementing some completely normal feature, and instead of the usual:</p>
<blockquote>
<p>“Analysing the codebase…”</p>
</blockquote>
<p>Qwen hits you with:</p>
<blockquote>
<p>“Just a moment, I’m finding the right meme…”</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/928fc5ab-4336-4686-8c8e-495bbb5993df.png" alt="Terminal screenshot showing Qwen CLI: ‘Just a moment, I’m finding the right meme…’" style="display:block;margin:0 auto" />

<p><em>Figure 1. Qwen CLI’s status message says it is searching for an appropriate meme while a coding task is running.</em></p>
<p><em>I (shockingly) laughed!</em></p>
<p>I find it funny.</p>
<p>It’s such a small thing, but these little messages make the whole CLI experience feel less robotic. You’re already staring at a terminal waiting for your code to be completed, your tests to run, or your AI agent to stop digging through 47 files looking for one missing function.</p>
<p>So when it suddenly says it’s <strong>looking for the right meme</strong>, it catches you completely off guard (actually bro, i never couldve thought of this, im more of an IDE first user).</p>
<p>The funniest part is that the underlying task is probably completely serious. It could be refactoring a clustering pipeline, fixing some obscure Python dependency, or analysing your entire repository.</p>
<p>Meanwhile Qwen:</p>
<p><strong>“Hold on, bro, I need the appropriate meme for this situation.”</strong></p>
<p>AI coding tools have gotten ridiculously capable, but I think these tiny personality quirks are what make them actually enjoyable to use.</p>
<p>Maybe the future of coding isn’t just better agents.</p>
<p>Maybe it’s agents who know <strong>exactly when a meme is required.</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/2a1364e5-3365-4ec1-a3a5-114df7c1b69c.png" alt="Terminal screenshot showing Qwen CLI status: ‘Counting electrons…’" style="display:block;margin:0 auto" />

<p><em>Figure 2. The terminal shows the playful status line “Counting electrons…”</em></p>
<p><em>sure bro :/</em></p>
<img src="https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/31918860-dd35-4f79-a094-c19bcb32ee1e.png" alt="Terminal screenshot showing Qwen CLI status: ‘Ensuring the magic smoke stays inside the wires…’" style="display:block;margin:0 auto" />

<p><em>Figure 3. The terminal shows “Ensuring the magic smoke stays inside the wires…” as another humorous status line.</em></p>
<p><em>our little comedian…</em></p>
]]></content:encoded></item></channel></rss>