Skip to content

Commit 4bbfec2

Browse files
committed
changed import order and better constant names
1 parent 0e65d91 commit 4bbfec2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

examples/wifi/expanded/requests_wifi_api_openskynetwork_private.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"""OpenSky-Network.org Single Flight Private API Example"""
55
# pylint: disable=import-error
66

7-
import binascii
87
import os
98
import time
109

10+
import binascii
1111
import adafruit_connection_manager
1212
import wifi
1313

@@ -18,7 +18,7 @@
1818
# All active flights JSON: https://opensky-network.org/api/states/all # PICK ONE! :)
1919
# JSON order: transponder, callsign, country
2020
# ACTIVE transpondes only, for multiple "c822af&icao24=cb3993&icao24=c63923"
21-
TRANSPONDER = "4b1806"
21+
TRANSPONDER = "ad4f1c"
2222

2323
# Get WiFi details, ensure these are setup in settings.toml
2424
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
@@ -46,17 +46,16 @@
4646
# base64 encode and strip appended \n from bytearray
4747
OSN_CREDENTIALS_B = binascii.b2a_base64(b"" + str(OSN_CREDENTIALS)).strip()
4848
BASE64_STRING = str(OSN_CREDENTIALS_B) # bytearray
49-
TRUNCATED_BASE64_STRING = BASE64_STRING[2:-1] # truncate bytearray head/tail
49+
SLICED_BASE64_STRING = BASE64_STRING[2:-1] # slice bytearray head/tail
5050

5151
if DEBUG:
52-
print("Original Binary Data: ", OSN_CREDENTIALS_B)
5352
print("Base64 ByteArray: ", BASE64_STRING)
54-
print(f"Base64 String: {TRUNCATED_BASE64_STRING}")
53+
print(f"Base64 Sliced String: {SLICED_BASE64_STRING}")
5554

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

6261

0 commit comments

Comments
 (0)