JSON without metadata

Viewed 4

Hi everyone!
I'm sending data to webhook.site in JSON format. I format the binary data using the Helium codec and send it. The problem is that I'm sending all the metadata Helium requires. Is there a way to send only the data I choose in JSON format?

Thanks!

// Define el codec para el payload binario de 30 bytes de la boya
function decodeUplink(input) {
    var bytes = input.bytes;
    var decoded = {};
    var i = 0;

    // Helper para leer un entero de 16 bits (2 bytes) Big Endian
    function readInt16(bytes) {
        var value = (bytes[i] << 8) | bytes[i + 1];
        i += 2;
        return value;
    }

    // Helper para leer un entero de 32 bits (4 bytes) Big Endian
    function readInt32(bytes) {
        var value = (bytes[i] << 24) | (bytes[i + 1] << 16) | (bytes[i + 2] << 8) | bytes[i + 3];
        i += 4;
        return value;
    }

    // --- Desempaquetado ---

    // Latitud y Longitud (4 bytes cada una, escaladas por 1,000,000)
    decoded.latitud = readInt32(bytes) / 1000000.0;
    decoded.longitud = readInt32(bytes) / 1000000.0;

    // Batería (1 byte)
    decoded.bateria = bytes[i++];

    // Temperaturas (2 bytes cada una, escaladas por 10)
    decoded.temperatura_interna = readInt16(bytes) / 10.0;
    decoded.temperatura_agua = readInt16(bytes) / 10.0;

    // Humedad interna (1 byte)
    decoded.humedad_interna = bytes[i++];

    // pH (2 bytes, escalado por 100)
    decoded.ph = readInt16(bytes) / 100.0;

    // Oxígeno disuelto (2 bytes, escalado por 100)
    decoded.oxigeno_disuelto = readInt16(bytes) / 100.0;

    // Conductividad (2 bytes)
    decoded.conductividad = readInt16(bytes);

    // Salinidad y Turbidez (1 byte cada una)
    decoded.salinidad = bytes[i++];
    decoded.turbidez = bytes[i++];

    // RMS, Pico, Leq (2 bytes cada uno, escalados por 100)
    decoded.rms = readInt16(bytes) / 100.0;
    decoded.pico = readInt16(bytes) / 100.0;
    decoded.leq = readInt16(bytes) / 100.0;
    
    // Devolvemos el objeto JSON decodificado
    return { data: decoded };
1 Answers

If your question is if you can modify the codec to only return the values that you want to expose, then yes you can modifiy it without any issues. Please note that all the other meta-data (e.g. gateway rxInfo, txInfo, ...) data is always sent by ChirpStack. You can not modify this part of the JSON payload.