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

Update Open-Sky Network Private Area API Example #168

Merged
merged 6 commits into from
Apr 10, 2024

Conversation

DJDevon3
Copy link
Contributor

@DJDevon3 DJDevon3 commented Mar 18, 2024

Private API, website credentials required. Instructions in code comments. More daily calls than Public API.
Pulls flight data from a geographic area. Example is around Orlando airport.

Added

  • pretty serial hierarchy view
  • general code cleanup and improvements
  • improved endpoints with server side failure messages
  • improved and streamlined debugging
  • shouty constants to make Pylint happy.
  • imports sorted
  • switched from circuitpython_base64 to adafruit_binascii for base64 credential encoding
  • doc strings for functions
  • uses settings.toml by default
  • now using Connection Manager by default

Changed from circuitpython_base64 community library to adafruit_binascii. It encodes to base64 much faster and has Adafruit library support. It's a better way to go for examples needing base64 encoding.

Serial output example:

Connecting to WiFi...
✅ Wifi!
 | Attempting to GET OpenSky-Network Area Flights JSON!
 | ✅ OpenSky-Network JSON!
 |  | Timestamp: 03/18/2024 07:00:20
 |  | Trans:ad4804 Sign:JBU2523 Origin:United States Time:1710744961 Last:1710744961 Lon:-81.327 Lat:28.4545 BaroAlt:83.82 Ground:False Vel:69.97 Head:179.16 VertRate:-3.58 Sens:None GeoAlt:68.58 Squawk:0501 Task:False PosSys:0 Cat:0 
 |  | Trans:a05087 Sign:GTX508  Origin:United States Time:1710745220 Last:1710745220 Lon:-81.4167 Lat:28.7626 BaroAlt:914.4 Ground:False Vel:80.53 Head:154.25 VertRate:0 Sens:None GeoAlt:906.78 Squawk:None Task:False PosSys:0 Cat:0 
✂️ Disconnected from OpenSky-Network API

Finished!
Board Uptime: 1 hours
Next Update: 30 minutes
===============================

@DJDevon3
Copy link
Contributor Author

DJDevon3 commented Mar 18, 2024

This example also has the base64 encoded string appending with \n which likely will fail for you if the other private example does. I find it really odd and a bit concerning that this works for me but not for you. I'll take another look into this one today too and ensure the \n append is sliced off.

@DJDevon3 DJDevon3 changed the title Update Open-Sky Network Area API Example with Connection Manager Update Open-Sky Network Private Area API Example Mar 19, 2024
@DJDevon3
Copy link
Contributor Author

DJDevon3 commented Mar 19, 2024

Also added .strip to the end of binascii.b2a_base64(b"" + str(OSN_CREDENTIALS)).strip() which will strip off the \n. still have to use slice but it's 2 less characters to slice off. as far as i know this should be the final version for review.

@DJDevon3
Copy link
Contributor Author

Double checked the other PR's. This one is ready for review.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

Lets change this one also to use encode() and decode(). There are some diffs in comments in #167 that show the required changes for that.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you!

@FoamyGuy FoamyGuy merged commit 1c56938 into adafruit:main Apr 10, 2024
1 check passed
@DJDevon3 DJDevon3 deleted the DJDevon3-openskynetwork_private_area branch April 10, 2024 23:11
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 11, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 3.2.4 from 3.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#184 from DJDevon3/GithubAPI
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#177 from DJDevon3/DJDevon3-WifiSimpleTest
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#176 from DJDevon3/DJDevon3-MultipleCookies
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#167 from DJDevon3/DJDevon3-openskynetwork_private
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#168 from DJDevon3/DJDevon3-openskynetwork_private_area

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants