Insert into ReadingRepo, but it's not tested yet
This commit is contained in:
parent
3123215f11
commit
855cbc0c1b
3 changed files with 16 additions and 5 deletions
|
@ -11,12 +11,12 @@ class ReadingRepo {
|
|||
this.query_insert = this.db.prepare(`INSERT INTO readings (
|
||||
id,
|
||||
lat, long,
|
||||
data_rate_id, code_rate, bit_rate
|
||||
data_rate, code_rate
|
||||
) VALUES (
|
||||
:id,
|
||||
:latitude,
|
||||
:longitude,
|
||||
:data_rate_id, :code_rate, :bit_rate
|
||||
:data_rate, :code_rate
|
||||
)`);
|
||||
|
||||
this.insert_query.run(reading);
|
||||
|
|
|
@ -5,7 +5,7 @@ CREATE TABLE readings IF NOT EXISTS (
|
|||
long FLOAT NOT NULL, -- Longitude component of GPS co-ordinates of reading,
|
||||
data_rate TEXT NOT NULL, -- The id of the data rate code in the data_rates table that describes the data rate at which the message was transmitted
|
||||
code_rate TEXT, -- The coding rate at which the message was transmitted. FUTURE: This may need to be an INTEGER field - not sure
|
||||
bit_rate INTEGER, -- The bit rate at which the message was transmitted
|
||||
-- bit_rate INTEGER, -- The bit rate at which the message was transmitted -- We didn't actually recieve this - disparity between API docs & actual message
|
||||
);
|
||||
CREATE TABLE rssis IF NOT EXISTS (
|
||||
id INTEGER PRIMARY KEY, -- Random unique int
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
import { decode_payload } from './DecodePayload.mjs';
|
||||
|
||||
class MessageHandler {
|
||||
constructor() {
|
||||
|
||||
constructor({ ReadingRepo, RSSIRepo, GatewayRepo }) {
|
||||
this.repo_reading = ReadingRepo;
|
||||
this.repo_rssi = RSSIRepo;
|
||||
this.repo_gateway = GatewayRepo;
|
||||
}
|
||||
|
||||
async handle(message) {
|
||||
|
@ -12,6 +14,15 @@ class MessageHandler {
|
|||
|
||||
let decoded_payload = decode_payload(message.payload_raw);
|
||||
console.log(decoded_payload);
|
||||
|
||||
this.repo_reading.add({
|
||||
id: decoded_payload.id,
|
||||
latitude: decoded_payload.latitude,
|
||||
longitude: decoded_payload.longitude,
|
||||
|
||||
data_rate: message.metadata.data_rate,
|
||||
code_rate: message.metadata.coding_rate
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue