Skip to content
Snippets Groups Projects
Commit c6452b79 authored by Callum Inglis's avatar Callum Inglis
Browse files

Merge branch 'api-authentication' into 'DEV'

Api authentication

See merge request !2
parents 8f761057 52b971ab
No related branches found
No related tags found
3 merge requests!4Api authentication,!3Api authentication,!2Api authentication
This commit is part of merge request !4. Comments created here will be created in the context of that merge request.
secrets.h
\ No newline at end of file
secrets.h
RaspberryPi_Receiver/secrets.py
\ No newline at end of file
......@@ -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
......
API_KEY = "<API KEY HERE>"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment