Skip to content

Commit

Permalink
changed import order and better constant names
Browse files Browse the repository at this point in the history
  • Loading branch information
DJDevon3 committed Mar 19, 2024
1 parent 0e65d91 commit 4bbfec2
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"""OpenSky-Network.org Single Flight Private API Example"""
# pylint: disable=import-error

import binascii
import os
import time

import binascii
import adafruit_connection_manager
import wifi

Expand All @@ -18,7 +18,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 = "4b1806"
TRANSPONDER = "ad4f1c"

# Get WiFi details, ensure these are setup in settings.toml
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
Expand Down Expand Up @@ -46,17 +46,16 @@
# 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
TRUNCATED_BASE64_STRING = BASE64_STRING[2:-1] # truncate bytearray head/tail
SLICED_BASE64_STRING = BASE64_STRING[2:-1] # slice bytearray head/tail

if DEBUG:
print("Original Binary Data: ", OSN_CREDENTIALS_B)
print("Base64 ByteArray: ", BASE64_STRING)
print(f"Base64 String: {TRUNCATED_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(TRUNCATED_BASE64_STRING)}
OPENSKY_HEADER = {"Authorization": "Basic " + str(SLICED_BASE64_STRING)}
OPENSKY_SOURCE = "https://opensky-network.org/api/states/all?" + "icao24=" + TRANSPONDER


Expand Down

0 comments on commit 4bbfec2

Please sign in to comment.