Skip to content
Snippets Groups Projects

Api authentication

Merged Callum Inglis requested to merge UAT into main
3 files
+ 13
2
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -46,7 +46,9 @@ from SX127x.LoRaArgumentParser import LoRaArgumentParser
from SX127x.board_config import BOARD
import SX127x.packer as packer
DEBUG = 1
import secrets
DEBUG = 2
API_URL = "https://emiei.4oh4.co/api"
MAX_TX_RESERVATION_TIME = 2 # Seconds
@@ -72,6 +74,7 @@ class RxHello(object):
class SensorResponse(object):
def __init__(self, sensorMetadata, data):
self.gatewayMetadata = GatewayMetadata()
self.sensorMetadata = SensorMetadata(**sensorMetadata)
self.sensorReading = SensorReading(**data)
@@ -83,9 +86,15 @@ class SensorResponse(object):
headers = {'Content-Type': 'Application/json'}
response = requests.post(API_URL + '/sensor/reading', data=self.ToJson(), headers=headers)#, verify=False) # Using self signed cert for now, sort later!
if DEBUG > 1:
print(self.ToJson())
print(response) # Ensure 200 Response!
return
class GatewayMetadata(object):
def __init__(self):
self.gatewayUID = getserial()
self.apiKey = secrets.API_KEY
class SensorMetadata(object):
def __init__(self, uid, messageID, samplePeriod):
self.uid = uid
Loading