syntax = "proto2";

import "nanopb.proto";


enum UsbPackageType {
  FIRMWARESTART = 3841;        // 0xF01
  FIRMWAREPACKAGE = 3842;      // 0xF02
  FIRMWAREDONE = 3843;         // 0xF03
  FIRMWAREPACKAGEACK = 3844;   // 0xF04
  FIRMWAREFILECHECK = 3845;     // 0xF05
  FIRMWAREUPDATEDONE = 3846;   // 0xF06
  REQUEST_DEVICE_LIST = 1000;
  RESPONSE_DEVICE_LIST = 1001;
}

message FirmwareStart {
  required string name = 1 [(nanopb).max_size = 32];
  required uint32 size = 2;
  required uint32 packages = 3;
  required uint32 device_id = 4;
  required uint32 crc_fw = 5;
}

message FirmwareFileCheck {
  required string name = 1 [(nanopb).max_size = 32];
  required uint32 size = 2;
  required uint32 device_id = 3;
  required bool   ready_for_data =4;
  required uint32 crc_fw = 5;
}

message FirmwarePackage {
  required uint32 counter = 1;
  required uint32 crc_pac = 2;
  required uint32 device_id = 3;
  required bytes data = 4 [(nanopb).max_size = 256];
}

message FirmwarePackageAck {
  required uint32 counter = 1;
  required uint32 crc_pac = 2;
  required uint32 device_id = 3;
  required bool ack =4;
}

message FirmwareDone {
  required uint32 size = 1;
  required uint32 crc_fw = 2;
  required uint32 device_id = 3;
}


message FirmwareUpdateDone {
  required uint32 device_id = 3;
}



message RequestDeviceList {
  required uint32 msg =1;
}

message Device {
  required bool  available =1;
  required uint32 canid = 2;
  required uint32 device = 3;
  required uint32 counter = 4;
}

message ResponseDeviceList {
  repeated Device devices = 1 [(nanopb).max_count = 18];
}