naneos.cloud.upload
Upload of gathered snapshots to the naneos IoT service.
backend_status(response)
The status the backend answered with, and what it said (empty if nothing).
The API gateway can wrap the answer of the lambda: a route the deployed lambda does not know comes back as HTTP 200 whose body is {"statusCode": 404, "body": ...}. Trusting the HTTP status alone would count that upload as done.
Source code in src/naneos/cloud/upload.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
build_body(upload_string)
The JSON envelope the backend expects around the base64 protobuf.
Source code in src/naneos/cloud/upload.py
150 151 152 153 154 155 156 157 158 | |
build_combined_entry(data, abs_time)
The protobuf message for a snapshot, with timestamps relative to abs_time.
Source code in src/naneos/cloud/upload.py
181 182 183 | |
build_prepared_entry(frames, abs_time)
The message for frames from prepare_frames(); they must not go through it twice.
Source code in src/naneos/cloud/upload.py
186 187 188 189 | |
prepare_frames(data)
The frames of a snapshot as the upload needs them, small enough to keep for a day.
One row per second (see to_upload_frame) and only the columns that have a field on the wire and data in them: 21 of the 56 columns of a P2 frame. The message built from the result is the message built from the full frame. Frames from here can be concatenated and sent with send_frames().
Source code in src/naneos/cloud/upload.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
send_frames(frames)
Upload frames from prepare_frames(), keyed by device serial number.
The frames may hold the rows of several snapshots: the timestamps in the message are relative to now, so old data lands at its own time. Blocks for up to TIMEOUT_SECONDS, more for a request with many rows. Raises requests.RequestException on network problems (requests.ReadTimeout when the server was reached but did not answer in time); HTTP errors are reported by the returned response.
Source code in src/naneos/cloud/upload.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
to_upload_frame(df)
Prepare one device frame for the backend: one row per whole second, no inf.
Frames are indexed by unix time in milliseconds (see naneos.frames). The index is rounded, not truncated: the devices sample at ~1Hz with a phase of their own, so truncating puts the two samples that straddle a second boundary into the same second, where one of them wins, and leaves the neighbouring second without a row at all.
The backend takes at most 1 Hz. Rows that land in the same second, as they do for a device read at 10 Hz or 100 Hz, are merged into one.
Source code in src/naneos/cloud/upload.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
upload_diagnostic(diagnostic)
Upload a UI curve or a pulse form to its endpoint.
Source code in src/naneos/cloud/upload.py
115 116 117 118 119 | |
upload_pulse_form(form)
Upload one pulse form. Blocks and raises like upload_snapshot().
Source code in src/naneos/cloud/upload.py
110 111 112 | |
upload_snapshot(data)
Upload the frames of a snapshot, keyed by device serial number.
Blocks for up to TIMEOUT_SECONDS. Raises requests.RequestException on network problems; HTTP errors are reported by the returned response.
Source code in src/naneos/cloud/upload.py
96 97 98 99 100 101 102 | |
upload_ui_curve(curve)
Upload one UI curve. Blocks and raises like upload_snapshot().
Source code in src/naneos/cloud/upload.py
105 106 107 | |