Skip to content

Commit

Permalink
update with requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DJDevon3 committed Apr 2, 2024
1 parent ca41b26 commit 6d627d9
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: MIT
# Coded for Circuit Python 8.2.x
"""OpenSky-Network.org Single Flight Private API Example"""
# pylint: disable=import-error

import binascii
import os
Expand All @@ -18,7 +17,7 @@
# All active flights JSON: https://opensky-network.org/api/states/all # PICK ONE! :)
# JSON order: transponder, callsign, country
# ACTIVE transpondes only, for multiple "c822af&icao24=cb3993&icao24=c63923"
TRANSPONDER = "ad4f1c"
TRANSPONDER = "4b1812"

# Get WiFi details, ensure these are setup in settings.toml
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
Expand All @@ -44,18 +43,17 @@
# -- Base64 Conversion --
OSN_CREDENTIALS = str(osnusername) + ":" + str(osnpassword)
# base64 encode and strip appended \n from bytearray
OSN_CREDENTIALS_B = binascii.b2a_base64(b"" + str(OSN_CREDENTIALS)).strip()
BASE64_STRING = str(OSN_CREDENTIALS_B) # bytearray
SLICED_BASE64_STRING = BASE64_STRING[2:-1] # slice bytearray head/tail
OSN_CREDENTIALS_B = binascii.b2a_base64(OSN_CREDENTIALS.encode()).strip()
BASE64_STRING = OSN_CREDENTIALS_B.decode() # bytearray


if DEBUG:
print("Base64 ByteArray: ", BASE64_STRING)
print(f"Base64 Sliced String: {SLICED_BASE64_STRING}")

# Requests URL - icao24 is their endpoint required for a transponder
# example https://opensky-network.org/api/states/all?icao24=a808c5
# OSN private: requires your website username:password to be base64 encoded
OPENSKY_HEADER = {"Authorization": "Basic " + str(SLICED_BASE64_STRING)}
OPENSKY_HEADER = {"Authorization": "Basic " + BASE64_STRING}
OPENSKY_SOURCE = "https://opensky-network.org/api/states/all?" + "icao24=" + TRANSPONDER


Expand Down

0 comments on commit 6d627d9

Please sign in to comment.