diff --git a/app/readings.db b/app/readings.db index f3d6b7a..ab91286 100644 Binary files a/app/readings.db and b/app/readings.db differ diff --git a/app/services/post_services.py b/app/services/post_services.py index 18c6dd2..2706b9c 100644 --- a/app/services/post_services.py +++ b/app/services/post_services.py @@ -30,21 +30,23 @@ def add_latest_reading(meter, info): return make_response("Meter Id. not recognised. Must be between 1 and 3.", 400) return make_response("Invalid token.", 400) -def log_status_change(device, status): - # NEED TO ADD TOKEN. - if device == 1: - return add_status_change_to_device1(status) - elif device == 2: - return add_status_change_to_device2(status) - elif device == 3: - return add_status_change_to_device3(status) - elif device == 4: - return add_status_change_to_device4(status) - elif device == 5: - return add_status_change_to_device5(status) - elif device == 6: - return add_status_change_to_device6(status) - return make_response("Device Id. not recognised. Must be between 1 and 6.", 400) +def log_status_change(device, info): + if info["token"] == device_check_token: + status = {"time":info["time"], "status":info["status"]} + if device == 1: + return add_status_change_to_device1(status) + elif device == 2: + return add_status_change_to_device2(status) + elif device == 3: + return add_status_change_to_device3(status) + elif device == 4: + return add_status_change_to_device4(status) + elif device == 5: + return add_status_change_to_device5(status) + elif device == 6: + return add_status_change_to_device6(status) + return make_response("Device Id. not recognised. Must be between 1 and 6.", 400) + return make_response("Invalid token.", 400) ''' Nitty-Gritty Functions diff --git a/app/swagger.yml b/app/swagger.yml index a627543..fd5671a 100644 --- a/app/swagger.yml +++ b/app/swagger.yml @@ -255,6 +255,12 @@ paths: description: >- The current status of the device you would like to log. The two status types are "on" and "off". + token: + type: string + example: it-is-not-password-if-you-are-wondering + description: >- + This is basically a token to check the info. sent to + the server is from a valid machine. responses: 201: description: >-