fleet-telemetry icon indicating copy to clipboard operation
fleet-telemetry copied to clipboard

Custom server

Open ShogunPanda opened this issue 1 year ago • 2 comments

Hello! I'm trying to write a custom telemetry server to process data from Tesla. Note that I'm NOT using fleet-telemetry at all. I have few questions:

  1. Can you please add the flatbuffers definitions (not the compile Go ones) in the repository)?
  2. I'm not really into Go code, so I need to know the following: do we need to confirm receipt of a message via StreamAckMessage or we just receive StreamMessage and that's it?

Thanks!

ShogunPanda avatar Sep 26 '24 13:09 ShogunPanda

I've also looked into this a little bit so will contribute what I know:

The protobuf definitions are all here (compiled pb.go and uncompiled .proto) https://github.com/teslamotors/fleet-telemetry/tree/main/protos

I dont know for sure, but I believe the vehicle is expecting messages to be ack'ed because I have seen vehicles retransmit messages to my fleet-telmetery instances.

Out of interest what language are you writing it in? I started a NodeJS version but gave up very quickly.

Bre77 avatar Sep 27 '24 04:09 Bre77

Thanks for your input! Yup, I see the proto there but it seems the message receives them embedded a in a flatbuffer structure. I hope they publish this.

I'm writing them in Node.js (see at my profile and you'll get why ;)). I'm using @fastify/websocket which makes the process pretty easy.

ShogunPanda avatar Sep 27 '24 17:09 ShogunPanda

@ShogunPanda are you able to make it work? We are trying to build using Node/Express and hosting it using Google Cloud Run behind a load balancer.

One of our cars is connecting using Websocket and sending some messages, but we are stuck trying to convert the message to a JSON using protobufJS(https://www.npmjs.com/package/protobufjs)

We did some tests creating a custom proto file, sending a message using Websocket and decoding the message and it worked, but we are failing miserable using the proto files provided on this project.

rafadalosto avatar Oct 22 '24 12:10 rafadalosto

Unfortunately not. I ended up installing the Go fleet-telemetry and getting it via the JSON stdout log

ShogunPanda avatar Oct 24 '24 08:10 ShogunPanda

Here is what I have, this definition is successfully decoding a FlatbuffersStream message. Comments derived via LLM of this file https://github.com/teslamotors/fleet-telemetry/blob/main/messages/stream_message.go . Working fbs definition found by manually inspecting the binary protocol, comparing with the go source, and working with LLM.

namespace tesla;

// Stream message containing telemetry data
table FlatbuffersStream {
  created_at:uint32;             // timestamp
  sender_id:[ubyte] (deprecated);   // deprecated: use combination of device_type + device_id
  payload:[ubyte];               // the protobuf encoded payload
  device_type:[ubyte];          // device identity coming from the certificate derived of Issuer CN
  device_id:[ubyte];            // device identity coming from the certificate derived of Subject CN
  delivered_at_epoch_ms:uint64;  // timestamp (in milliseconds) at which the message reached the backend
}

// Acknowledgment message
table FlatbuffersStreamAck {
  // empty ack message
}

// Define the union with explicit values matching the Message enum
union Message {
  FlatbuffersStream = 4,
  FlatbuffersStreamAck = 5
}

// Main message envelope that wraps all messages
table FlatbuffersEnvelope {
  txid:[ubyte];           // unique transaction id of this message
  topic:[ubyte];          // used for routing messages to backend queues
  message:Message;        // the actual message content as a union
  message_id:[ubyte];     // unique id of the message
}

root_type FlatbuffersEnvelope;

sjmiller609 avatar Nov 20 '24 17:11 sjmiller609

@ShogunPanda @rafadalosto could u guys share with me what you have so far, I am also exploring having a nodejs server for that.

davidsl4 avatar Dec 14 '24 16:12 davidsl4

See flatbuffers definition https://github.com/teslamotors/fleet-telemetry/blob/main/messages/stream_message.go

ThomasAlxDmy avatar Jan 16 '25 07:01 ThomasAlxDmy