Giter Club home page Giter Club logo

Comments (4)

psi-4ward avatar psi-4ward commented on September 22, 2024

Nice 😉

from asksinanalyzerxs.

bolausson avatar bolausson commented on September 22, 2024

I tried to implement it within the persistentStorage.ts but since I never coded something in TypeScript I scraped the effort and took the detour via the CSV files + Python which just took a couple of minutes.

I mean there is a InfluxDB2 client available so I might give it another try when I have more time 😄

from asksinanalyzerxs.

psi-4ward avatar psi-4ward commented on September 22, 2024

Describe the protocol to me and the mapping you've choosen. Probably I will implement it. Tbh, I stored the data into influx for some timing using the web socket and node red.

from asksinanalyzerxs.

bolausson avatar bolausson commented on September 22, 2024

The mapping is a simple dictionary which replicates your CSV header one to one.
Payload and RAW should probably be optional to not bloat your TSDB.

MM = [
    {
        "measurement": 'Telegrams',
        "tags": {
            "flags": str(row["flags"]),
            "type": str(row["type"]),
            "fromAddr": str(row["fromAddr"]),
            "toAddr": str(row["toAddr"]),
            "fromName": str(row["fromName"]),
            "toName": str(row["toName"]),
            "fromSerial": str(row["fromSerial"]),
            "toSerial": str(row["toSerial"]),
            "toIsIp": str(row["toIsIp"]),
            "fromIsIp": str(row["fromIsIp"]),
#          "payload": str(row["payload"]),
#          "raw": str(row["raw"]),
            },
        "fields": {
            "tstamp": int(row["tstamp"]),
            "date": str(row["date"]),
            "rssi": int(row["rssi"]),
            "len": int(row["len"]),
            "cnt": int(row["cnt"]),
            "dc": float(row["dc"]),
            },
        "time": int(row["tstamp"]),
    },
]

Not sure if the translation below to JS is correct:

import {InfluxDB, Point, HttpError} from '@influxdata/influxdb-client'
import {url, token, org, bucket} from './env.mjs'

// If you use the timestamp like in your CSV file, you must tell InfluxDB to use write precision='ms' else the write fails
const writeApi = influxDB.getWriteApi(org, bucket, 'ms', writeOptions)

const point1 = new Point('Telegrams')
// Add all tags:
  .tag('flags', flags.toString())
  .tag('ftype', type.toString())
  .tag('fromAddr', fromAddr.toString())
  .tag('toAddr', toAddr.toString())
  .tag('fromName', fromName.toString())
  .tag('toName', toName.toString())
  .tag('fromSerial', fromSerial.toString())
  .tag('toSerial', toSerial.toString())
  .tag('toIsIp', toIsIp.toString())

/*
  not sure how to implement a clause to add the paylod and raw data if a checkpox for one or the other is checked
  .tag('payload', payload.toString()) 
  .tag('raw', raw.toString())
*/

// Add all fields
  .intField('tstamp', tstamp)
  .stringField('date', date)
  .intField('rssi', rssi)
  .intField('len', len)
  .intField('cnt', cnt)
  .floatField('dc', dc)

// Add the timestamp of the telegram
 .timestamp(tstamp)

// write the data
writeApi.writePoint(point1)

There are lots of examples how to use the Node.js client:
https://github.com/influxdata/influxdb-client-js#usage
Write data with the InfluxDB JavaScript client library and the API Reference

from asksinanalyzerxs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.