syntax = "proto2";

import "nanopb.proto";

package jaiabot.protobuf;

message LoRaMessage
{
    required int32 src = 1;
    required int32 dest = 2;
    optional bytes data = 3 [(nanopb).max_size = 251];
    enum MessageType
    {
        LORA_DATA = 1;            // bidirectional
        SET_PARAMETERS = 2;       // control -> feather
        PARAMETERS_ACCEPTED = 3;  // feather -> control
        PARAMETERS_REJECTED = 4;  // feather -> control
        FEATHER_READY = 5;        // feather -> control
        TRANSMIT_RESULT = 6;      // feather -> control

        LOW_CONTROL = 50;  // control -> feather

        DEBUG_MESSAGE = 100;  // feather -> control
    }
    required MessageType type = 4 [default = LORA_DATA];
    optional int32 id = 5;
    optional int32 flags = 6;
    optional sint32 rssi = 7;

    optional bool transmit_successful = 10;

    // configuration
    // Maps directly onto RadioHead's enumeration:
    // https://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF95.html#ab9605810c11c025758ea91b2813666e3
    // Bw125Cr45Sf128   Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on.
    // Default medium range.
    //
    // Bw500Cr45Sf128   Bw = 500 kHz, Cr = 4/5, Sf =
    // 128chips/symbol, CRC on. Fast+short range.
    //
    // Bw31_25Cr48Sf512 Bw = 31.25
    // kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long range.
    //
    // Bw125Cr48Sf4096  Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, low data
    // rate, CRC on. Slow+long range.
    //
    // Bw125Cr45Sf2048  Bw = 125 kHz, Cr = 4/5, Sf
    // = 2048chips/symbol, CRC on. Slow+long range.

    enum ModemConfigChoice
    {
        Bw125Cr45Sf128 = 1;
        Bw500Cr45Sf128 = 2;
        Bw31_25Cr48Sf512 = 3;
        Bw125Cr48Sf4096 = 4;
        Bw125Cr45Sf2048 = 5;
    }

    optional ModemConfigChoice modem_config = 20 [default = Bw125Cr45Sf128];

    // +5-+23 dBm
    optional int32 tx_power = 21 [default = 13];

    message ControlSurfaces
    {
        required sint32 motor = 1;
        required sint32 port_elevator = 2;
        required sint32 stbd_elevator = 3;
        required sint32 rudder = 4;
    }



    optional ControlSurfaces control = 30;
}
