adafruit / Adafruit_CircuitPython_Requests

Requests-like interface for web interfacing
MIT License
51 stars 36 forks source link

Update Fitbit API Example with Connection Manager #164

Closed DJDevon3 closed 3 months ago

DJDevon3 commented 3 months ago

Added pretty serial hierarchy view, general code cleanup and improvements, more endpoints (added Watch Battery Percentage). Attempted to ensure it meets current syntax practices. Made some constants shouty to make Pylint happy. Added a way to reset NVM back to factory default and it turned into the easiest method for anyone adding new credentials for the very first use. NVM reset is a very nice and easy to use feature now.

Serial output example:

📡 Connecting to WiFi...
✅ WiFi!
 | MANUAL REBOOT TOKEN DIFFERENCE -------
 | Requesting authorization for next token
 | Next Token: b768b6a28dd890d123e83e86669f5b8913647946b1736f2b3577ee8baef420a6
 | 🔑 Next token written to NVM Successfully!
 | Attempting to GET Fitbit JSON!
 | ✅ Fitbit Intraday JSON!
 |  | Fitbit Date: 2024-03-17
 |  | Fitbit Time: 11:41
 |  | Today's Logged Pulses: 702
 |  | Latest 15 Minute Averages: 71, 66, 69, 68, 67, 69, 67, 70, 68, 69, 69, 69, 68, 69, 69
 | Attempting to GET Device JSON!
 | ✅ Fitbit Device JSON!
 |  | Watch Battery %: 30

Finished!
Board Uptime: 3.1 days
Next Update: 15 minutes
===============================

NVM Reset Serial output example:

TOP NVM IS BRAND NEW! WAITING FOR A FIRST TOKEN
Top NVM RESET:
Refresh Token Reset:
🚮 NVM Cleared!
⚠️ Save your new access token & refresh token from Fitbits Tutorial (Step 4) to settings.toml now.
⚠️ If the script runs again(due to settings.toml file save) while reset=True that's ok!
⚠️ Then set RESET_NVM back to False.
DJDevon3 commented 3 months ago

It's not discord webscrape. accidentally up arrowed in cmd line to a previous description.