Forráskód Böngészése

v0.1.1-4:20241017车端定位底盘状态mqtt

chengkaiqiang 1 hónapja
szülő
commit
7c8bdf09ad

+ 5 - 0
ZJ_PRO/.vscode/settings.json

@@ -0,0 +1,5 @@
+{
+    "files.associations": {
+        "ostream": "cpp"
+    }
+}

+ 122 - 0
ZJ_PRO/EgoSystem/DataMqttStatus.cpp

@@ -0,0 +1,122 @@
+#include "DataMqttStatus.h"
+#include <iostream>
+#include <stdio.h>
+
+MQTTAsync_responseOptions CDataMqttSensor::opts = MQTTAsync_responseOptions_initializer;
+MQTTAsync CDataMqttSensor::m_mqttClient;
+bool CDataMqttSensor::_run = false;
+char** CDataMqttSensor::subTopic = NULL;
+std::string CDataMqttSensor::_Esn;
+
+CDataMqttStatusSensor::CDataMqttSensor(CMessageQueue* q) :_message(q)
+{
+}
+
+
+void CDataMqttStatusSensor::SetSensorMQTT(MQTTAsync mqClient, std::string Esn)
+{
+    m_mqttClient = mqClient;
+    _Esn = Esn;
+}
+
+void CDataMqttStatusSensor::onConnectCallCBack(void* context, char* cause) 
+{
+    if(m_mqttClient != NULL)
+    {
+        
+        std::cout << "Connection successful" << std::endl;
+        int rc;
+        const int qos[1] = {0};
+
+        const int ROWS = 1;
+        const int COLUMNS = 64;
+
+        subTopic = new char* [ROWS];
+        for (int row = 0; row < ROWS; row++)
+        {
+            subTopic[row] = new char[COLUMNS];
+        }
+        
+        memcpy((char*)*(subTopic + 0),"Vehicle/CanBus/StateVeh001",strlen("Vehicle/CanBus/StateVeh001"));
+        
+
+        opts = MQTTAsync_responseOptions_initializer;
+        opts.context = m_mqttClient;
+
+        if ((rc = MQTTAsync_subscribeMany(m_mqttClient, 1 , subTopic, qos, &opts)) != MQTTASYNC_SUCCESS) //subTopic
+        {
+            std::cout << "MQTTAsync_subscribe() fail, error code: " << rc << std::endl;
+        }
+        _run = true;
+    }
+
+}
+
+void CDataMqttStatusSensor::onConnectFailure(void* context, MQTTAsync_failureData* response) 
+{
+    _run = false;
+    printf("connection fail, error code: %d, error message:%s\n", response ? response->code : 0, response ? response->message : 0);
+}
+
+void CDataMqttStatusSensor::Disconnect(void* context, char* cause) 
+{
+    _run = false;
+    std::cout << "disconnect, cause: " << cause << std::endl;
+}
+
+void CDataMqttStatusSensor::sendMessage(char* data, int qos , const char * pubTopic)
+{
+    if (_run && (m_mqttClient != NULL))
+    {
+        int rc;
+        MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
+        MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
+
+        opts.context = m_mqttClient;
+
+        pubmsg.payload = data;
+        pubmsg.payloadlen = strlen(data);
+        pubmsg.qos = qos;
+        
+        if ((rc = MQTTAsync_sendMessage(m_mqttClient, pubTopic, &pubmsg, &opts)) != MQTTASYNC_SUCCESS)
+        {
+            std::cout << "MQTTAsync_sendMessage() fail, error code: " << rc << std::endl;
+        }
+    }
+}
+
+int  CDataMqttStatusSensor::RecevieMessage(void* context, char* pubTopic, int topicLen, MQTTAsync_message* message)
+{
+    if (_run)
+    {
+        char buf[message->payloadlen + 1];
+
+        memcpy(buf, message->payload, message->payloadlen);
+
+        MQTTAsync_freeMessage(&message);
+        MQTTAsync_free(pubTopic);
+    }
+    return 1;
+}
+
+void CDataMqttStatusSensor::Stop(const char* _Esn)
+{
+    
+    MQTTAsync_disconnectOptions optDis = MQTTAsync_disconnectOptions_initializer;
+    if(_run)
+    {
+        MQTTAsync_unsubscribeMany(m_mqttClient, 1, subTopic, &opts);
+        MQTTAsync_disconnect(&m_mqttClient, &optDis);
+
+        const int ROWS = 1;
+        for (int row = 0; row < ROWS; row++)
+        {
+            delete [] subTopic[row];
+        }
+        delete [] subTopic;
+    }
+    
+    _run = false;
+    m_mqttClient = NULL;
+    MQTTAsync_destroy(&m_mqttClient);
+}

+ 30 - 0
ZJ_PRO/EgoSystem/DataMqttStatus.h

@@ -0,0 +1,30 @@
+#pragma once
+#include "../common/iobuffer.h"
+#include "../common/sensor_socket.h"
+
+
+class CMessageQueue;
+
+class CDataMqttStatusSensor//:public ISensorNotify
+{
+public:
+    CDataMqttStatusSensor(CMessageQueue* q);
+
+    void SetSensorMQTT(MQTTAsync mqClient,std::string Esn);
+    void Stop(const char* _Esn);
+
+    static MQTTAsync_responseOptions opts;
+    static MQTTAsync m_mqttClient;
+    static bool _run;
+    static char** subTopic;
+    static std::string _Esn;
+
+    static void Disconnect(void* context, char* cause);
+    static int  RecevieMessage(void* context, char* pubTopic, int topicLen, MQTTAsync_message* message);
+    static void onConnectFailure(void* context, MQTTAsync_failureData* response); 
+    static void onConnectCallCBack(void* context, char* cause);
+    static void sendMessage(char* data, int qos, const char* pubTopic);
+
+private:
+    CMessageQueue* _message;
+};

+ 0 - 4
ZJ_PRO/EgoSystem/MqttClient.cpp

@@ -44,8 +44,6 @@ void CMqttSensor::onConnectCallCBack(void* context, char* cause) //���ӳɹ
 
         opts = MQTTAsync_responseOptions_initializer;
 
-        //char* const subTopic[2] = { "hello" ,"hello1" };  //��������
-
         opts.context = m_mqttClient;
 
         if ((rc = MQTTAsync_subscribeMany(m_mqttClient, 3 , subTopic, qos, &opts)) != MQTTASYNC_SUCCESS) //subTopic
@@ -54,8 +52,6 @@ void CMqttSensor::onConnectCallCBack(void* context, char* cause) //���ӳɹ
         }
         _run = true;
     }
-    
-    //sendMessage("11111",1, "hello");
 }
 
 void CMqttSensor::onConnectFailure(void* context, MQTTAsync_failureData* response) //����ʧ��callback

+ 15 - 2
ZJ_PRO/EgoSystem/Rtk.cpp

@@ -205,10 +205,20 @@ void CRtkSensor::Send_ZGJ_Rtk(float headingAngle,float lat,float lon,float loc_s
 	memset(Topic, 0, 64);
 	sprintf(Topic, "v2x/v1/grasp/%s/info/up", CMqttSensor::_Esn.c_str());
 	CMqttSensor::sendMessage((char*)sw.write(Source).c_str(), 0, (char*)Topic);
+
+	//发送给服务器定位
+	Json::StyledWriter gpstoserver;
+	Json::Value SourceServer;
+	SourceServer["timestamp"] = SendTime.assign(Dst,strlen(Dst));
+	Json::Value GpsToServer;
+	GpsToServer["headingAngle"] = headingAngle;
+	GpsToServer["lat"] = lat;
+	GpsToServer["lon"] = lon;
+	SourceServer["location"].append(GpsToServer);
+	CMqttSensor::sendMessage((char*)gpstoserver.write(SourceServer).c_str(), 0, (char*)"/Vehicle/Sensors/Location/Veh001"); //发送定位给服务器
 }
 
-void CRtkSensor::Send_ZGJ_status(int Status)//ץ�ֻ�״̬��Ϣ�ϱ�
-{
+void CRtkSensor::Send_ZGJ_status(int Status)
 	if (CMqttSensor::_run)
 	{
 		struct timeval tv;
@@ -246,5 +256,8 @@ void CRtkSensor::Send_ZGJ_status(int Status)//ץ�ֻ�״̬��Ϣ�ϱ�
 		memset(Topic, 0, 64);
 		sprintf(Topic, "v2x/v1/grasp/%s/status/up", CMqttSensor::_Esn.c_str());
 		CMqttSensor::sendMessage((char*)sw.write(Source).c_str(), 0, (char*)Topic);
+
+		
+
 	}
 }

+ 9 - 19
ZJ_PRO/EgoSystem/can_bus.cpp

@@ -42,23 +42,7 @@ float Canb2f(uint8_t m0, uint8_t m1, uint8_t m2, uint8_t m3)
     return f;
 }
 
-int hex_to_decimal(const char* hex_str) {
-    int decimal = 0;
-    int len = strlen(hex_str);
-
-    for (int i = 0; i < len; i++) {
-        char c = toupper(hex_str[i]);
-        if (c >= '0' && c <= '9') {
-            decimal = decimal * 16 + (c - '0');
-        } else if (c >= 'A' && c <= 'F') {
-            decimal = decimal * 16 + (c - 'A' + 10);
-        } else {
-            return -1; // 输入的字符串含有非十六进制字符
-        }
-    }
 
-    return decimal;
-}
 
 int16_t make_int16(unsigned char h,unsigned char l)
 {
@@ -173,6 +157,7 @@ void CCanBusSensor::Notify(struct can_frame *date)
             break;
         
         case 0x28A:
+            travelSpeed = make_int16(date->data[1],date->data[0]);   //行驶速度
             _data.Travel_speed = make_int16(date->data[1],date->data[0]);//行驶速度
             _data.Engine_temperature = make_int16(date->data[3],date->data[2]);//发动机水温
             _data.Hand_gear = make_int16(date->data[5],date->data[4]);//水箱水位
@@ -202,6 +187,11 @@ void CCanBusSensor::Notify(struct can_frame *date)
             break;
 
         case 0x28F:
+
+            fGear = (date->data[0] & 0x40) == 0x40 ? 1 : 0;        //前进档
+            bGear = (date->data[0] & 0x80) == 0x80 ? 1 : 0;        //后退档
+            gearStatus = (date->data[1] & 0x01) == 0x10 ? 1 : 0;   //实际档位
+
             _data.Idle_protection = (date->data[3] & 0x80) == 0x80 ? 1 : 0;//怠速保护
             _data.Front_toggle = (date->data[1] & 0x08) == 0x08 ? 1 : 0;//前轮对中
             _data.Back_toggle = (date->data[1] & 0x10) == 0x10 ? 1 : 0;//后轮对中
@@ -223,6 +213,8 @@ void CCanBusSensor::Notify(struct can_frame *date)
             //增加
             memcpy(_data.all_Buff,date->data,date->can_dlc);
 
+            _message -> SendStatusToServer( travelSpeed,fGear,bGear,gearStatus);
+
             break;
 
         case 0x280:
@@ -444,7 +436,6 @@ void CCanBusSensor::SendStatusToMSG()
     _message->WritePacket(ChannelType::CHANNEL_CAR, pBuffer);
 }
 
-
 void CCanBusSensor::Emergency()
 {
     if(model)
@@ -455,5 +446,4 @@ void CCanBusSensor::Emergency()
         Sendframe[3].data[3] &= 0xFD;
         //_canbus->Write(&Sendframe[3]);
     }
-}
-
+}

+ 2 - 0
ZJ_PRO/EgoSystem/can_bus.h

@@ -45,5 +45,7 @@ private:
      FeedData _data;
      int model;//0本地,1远程
 
+     int travelSpeed,gearStatus,fGear,bGear; //行驶速度,实际档位,前进,后退档
+
      vehicle_control_cv control_can;
 };

+ 43 - 1
ZJ_PRO/EgoSystem/message_queue.cpp

@@ -742,6 +742,13 @@ void CMessageQueue::SwitchCamera(bool front)
 }
 */
 
+void CMessageQueue::OnMqttUser(std::string user_uid,int32_t cockpitId,int32_t vehicleId){
+    user_uuid = user_uid;
+    cockpit_id = cockpitId;
+    vehicle_id = vehicleId ;
+    
+}
+
 void CMessageQueue::OnMessageFrameNotify(ChannelType type,int16_t cmd,int16_t length,const void * data)
 {
      
@@ -999,7 +1006,10 @@ void CMessageQueue::SendVehicleStatus(vehicle_control_cv control_can)
 
 		std::string SendTime;
  
-        Source["VehicleID"] = 538;
+        Source["userID"] = user_uuid;
+        Source["cockpitID"] = cockpit_id;
+        Source["VehicleID"] = vehicle_id;
+        
         Source["timestamp"] = SendTime.assign(Dst,strlen(Dst));
 
         //车辆基本状态控制
@@ -1083,3 +1093,35 @@ void CMessageQueue::SendVehicleStatus(vehicle_control_cv control_can)
 
 	}
 }
+
+
+
+void CMessageQueue::SendStatusToServer(int32_t travelSpeed, int fGear, int bGear, int gearStatus) {
+   
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    char m_Send[16],Dst[16];
+    memset(Dst, 0, 16);
+    sprintf((char*)Dst, "%ld", tv.tv_sec * 1000 + tv.tv_usec / 1000);
+
+    Json::Value root;
+    Json::Value SoucreBus;
+    Json::FastWriter writer;
+
+    std::string SendTime;
+    SoucreBus["userID"] = user_uuid;
+    SoucreBus["cockpitID"] = cockpit_id;
+    SoucreBus["VehicleID"] = vehicle_id;
+    SoucreBus["travelSpeed"] = travelSpeed;
+    SoucreBus["fGear"] = fGear;
+    SoucreBus["bGear"] = bGear;
+
+    SoucreBus["timestamp"] = SendTime.assign(Dst,strlen(Dst));
+    SoucreBus["gearStatus"] =gearStatus;
+
+    Json::StyledWriter sw;
+    std::cout << sw.write(SoucreBus) << std::endl << std::endl;
+    
+    CDataMqttSensor::sendMessage((char*)sw.write(SoucreBus).c_str(), 0, (char*)"Vehicle/CanBus/State/Veh001");
+
+}

+ 11 - 0
ZJ_PRO/EgoSystem/message_queue.h

@@ -100,6 +100,10 @@ public:
 
    virtual void OnMessageFrameNotify(ChannelType type,int16_t cmd,int16_t length,const void * data) override;
 
+
+   virtual void OnMqttUser(std::string user_uid,int32_t cockpitId,int32_t vehicleId) override;//增加
+
+
    void OnNotifyConnected(bool bRet);
    void OnNotifyReq(int32_t index);
    void OnNotifyRep(int32_t index);
@@ -125,6 +129,7 @@ public:
    void SendZGJStatus(int status);
 
    void SendVehicleStatus(vehicle_control_cv control_can);
+   void SendStatusToServer(int32_t travelSpeed, int fGear, int bGear, int gearStatus) ; //发送底盘状态给服务器
    
 
    bool bStopedCar;
@@ -141,6 +146,12 @@ public:
    long long _source = 0;
    long long _dst = 0;
 
+   //增加
+   std::string user_uuid;
+   int32_t cockpit_id;
+   int32_t vehicle_id;
+
+
    
    
 private:

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 490 - 199
ZJ_PRO/Protocol/linux/protocol.pb.cc


+ 319 - 44
ZJ_PRO/Protocol/linux/protocol.pb.h

@@ -48,7 +48,7 @@ struct TableStruct_protocol_2eproto {
     PROTOBUF_SECTION_VARIABLE(protodesc_cold);
   static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
     PROTOBUF_SECTION_VARIABLE(protodesc_cold);
-  static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[42]
+  static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[43]
     PROTOBUF_SECTION_VARIABLE(protodesc_cold);
   static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
   static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
@@ -176,6 +176,9 @@ extern StopAckDefaultTypeInternal _StopAck_default_instance_;
 class TestTextReq;
 struct TestTextReqDefaultTypeInternal;
 extern TestTextReqDefaultTypeInternal _TestTextReq_default_instance_;
+class UserActivityInfo;
+struct UserActivityInfoDefaultTypeInternal;
+extern UserActivityInfoDefaultTypeInternal _UserActivityInfo_default_instance_;
 class Wiper;
 struct WiperDefaultTypeInternal;
 extern WiperDefaultTypeInternal _Wiper_default_instance_;
@@ -224,6 +227,7 @@ template<> ::RemoNet::SensorStop* Arena::CreateMaybeMessage<::RemoNet::SensorSto
 template<> ::RemoNet::State* Arena::CreateMaybeMessage<::RemoNet::State>(Arena*);
 template<> ::RemoNet::StopAck* Arena::CreateMaybeMessage<::RemoNet::StopAck>(Arena*);
 template<> ::RemoNet::TestTextReq* Arena::CreateMaybeMessage<::RemoNet::TestTextReq>(Arena*);
+template<> ::RemoNet::UserActivityInfo* Arena::CreateMaybeMessage<::RemoNet::UserActivityInfo>(Arena*);
 template<> ::RemoNet::Wiper* Arena::CreateMaybeMessage<::RemoNet::Wiper>(Arena*);
 template<> ::RemoNet::can_net_frame* Arena::CreateMaybeMessage<::RemoNet::can_net_frame>(Arena*);
 PROTOBUF_NAMESPACE_CLOSE
@@ -315,12 +319,13 @@ enum SCMessage : int {
   SC_NotifyCloseVideo = 4018,
   SC_KickOff = 4019,
   SC_State = 4022,
+  S2V_SendUserInfo = 6011,
   SCMessage_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::min(),
   SCMessage_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::max()
 };
 bool SCMessage_IsValid(int value);
 constexpr SCMessage SCMessage_MIN = SC_NONE;
-constexpr SCMessage SCMessage_MAX = SC_State;
+constexpr SCMessage SCMessage_MAX = S2V_SendUserInfo;
 constexpr int SCMessage_ARRAYSIZE = SCMessage_MAX + 1;
 
 const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* SCMessage_descriptor();
@@ -490,6 +495,179 @@ inline bool DirectionLight_Parse(
 }
 // ===================================================================
 
+class UserActivityInfo final :
+    public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:RemoNet.UserActivityInfo) */ {
+ public:
+  inline UserActivityInfo() : UserActivityInfo(nullptr) {}
+  ~UserActivityInfo() override;
+  explicit constexpr UserActivityInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
+
+  UserActivityInfo(const UserActivityInfo& from);
+  UserActivityInfo(UserActivityInfo&& from) noexcept
+    : UserActivityInfo() {
+    *this = ::std::move(from);
+  }
+
+  inline UserActivityInfo& operator=(const UserActivityInfo& from) {
+    CopyFrom(from);
+    return *this;
+  }
+  inline UserActivityInfo& operator=(UserActivityInfo&& from) noexcept {
+    if (this == &from) return *this;
+    if (GetOwningArena() == from.GetOwningArena()
+  #ifdef PROTOBUF_FORCE_COPY_IN_MOVE
+        && GetOwningArena() != nullptr
+  #endif  // !PROTOBUF_FORCE_COPY_IN_MOVE
+    ) {
+      InternalSwap(&from);
+    } else {
+      CopyFrom(from);
+    }
+    return *this;
+  }
+
+  static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
+    return GetDescriptor();
+  }
+  static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
+    return default_instance().GetMetadata().descriptor;
+  }
+  static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
+    return default_instance().GetMetadata().reflection;
+  }
+  static const UserActivityInfo& default_instance() {
+    return *internal_default_instance();
+  }
+  static inline const UserActivityInfo* internal_default_instance() {
+    return reinterpret_cast<const UserActivityInfo*>(
+               &_UserActivityInfo_default_instance_);
+  }
+  static constexpr int kIndexInFileMessages =
+    0;
+
+  friend void swap(UserActivityInfo& a, UserActivityInfo& b) {
+    a.Swap(&b);
+  }
+  inline void Swap(UserActivityInfo* other) {
+    if (other == this) return;
+  #ifdef PROTOBUF_FORCE_COPY_IN_SWAP
+    if (GetOwningArena() != nullptr &&
+        GetOwningArena() == other->GetOwningArena()) {
+   #else  // PROTOBUF_FORCE_COPY_IN_SWAP
+    if (GetOwningArena() == other->GetOwningArena()) {
+  #endif  // !PROTOBUF_FORCE_COPY_IN_SWAP
+      InternalSwap(other);
+    } else {
+      ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
+    }
+  }
+  void UnsafeArenaSwap(UserActivityInfo* other) {
+    if (other == this) return;
+    GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
+    InternalSwap(other);
+  }
+
+  // implements Message ----------------------------------------------
+
+  UserActivityInfo* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
+    return CreateMaybeMessage<UserActivityInfo>(arena);
+  }
+  using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
+  void CopyFrom(const UserActivityInfo& from);
+  using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
+  void MergeFrom(const UserActivityInfo& from);
+  private:
+  static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
+  public:
+  PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
+  bool IsInitialized() const final;
+
+  size_t ByteSizeLong() const final;
+  const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
+  uint8_t* _InternalSerialize(
+      uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
+  int GetCachedSize() const final { return _cached_size_.Get(); }
+
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const final;
+  void InternalSwap(UserActivityInfo* other);
+
+  private:
+  friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
+  static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
+    return "RemoNet.UserActivityInfo";
+  }
+  protected:
+  explicit UserActivityInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena,
+                       bool is_message_owned = false);
+  private:
+  static void ArenaDtor(void* object);
+  inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
+  public:
+
+  static const ClassData _class_data_;
+  const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
+
+  ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
+
+  // nested types ----------------------------------------------------
+
+  // accessors -------------------------------------------------------
+
+  enum : int {
+    kUserUuidFieldNumber = 1,
+    kCockpitIdFieldNumber = 2,
+    kVehicleIdFieldNumber = 3,
+  };
+  // string user_uuid = 1;
+  void clear_user_uuid();
+  const std::string& user_uuid() const;
+  template <typename ArgT0 = const std::string&, typename... ArgT>
+  void set_user_uuid(ArgT0&& arg0, ArgT... args);
+  std::string* mutable_user_uuid();
+  PROTOBUF_NODISCARD std::string* release_user_uuid();
+  void set_allocated_user_uuid(std::string* user_uuid);
+  private:
+  const std::string& _internal_user_uuid() const;
+  inline PROTOBUF_ALWAYS_INLINE void _internal_set_user_uuid(const std::string& value);
+  std::string* _internal_mutable_user_uuid();
+  public:
+
+  // int32 cockpit_id = 2;
+  void clear_cockpit_id();
+  int32_t cockpit_id() const;
+  void set_cockpit_id(int32_t value);
+  private:
+  int32_t _internal_cockpit_id() const;
+  void _internal_set_cockpit_id(int32_t value);
+  public:
+
+  // int32 vehicle_id = 3;
+  void clear_vehicle_id();
+  int32_t vehicle_id() const;
+  void set_vehicle_id(int32_t value);
+  private:
+  int32_t _internal_vehicle_id() const;
+  void _internal_set_vehicle_id(int32_t value);
+  public:
+
+  // @@protoc_insertion_point(class_scope:RemoNet.UserActivityInfo)
+ private:
+  class _Internal;
+
+  template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
+  typedef void InternalArenaConstructable_;
+  typedef void DestructorSkippable_;
+  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr user_uuid_;
+  int32_t cockpit_id_;
+  int32_t vehicle_id_;
+  mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
+  friend struct ::TableStruct_protocol_2eproto;
+};
+// -------------------------------------------------------------------
+
 class CSAdd final :
     public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:RemoNet.CSAdd) */ {
  public:
@@ -538,7 +716,7 @@ class CSAdd final :
                &_CSAdd_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    0;
+    1;
 
   friend void swap(CSAdd& a, CSAdd& b) {
     a.Swap(&b);
@@ -716,7 +894,7 @@ class SCAdd final :
                &_SCAdd_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    1;
+    2;
 
   friend void swap(SCAdd& a, SCAdd& b) {
     a.Swap(&b);
@@ -899,7 +1077,7 @@ class SCKickOff final :
                &_SCKickOff_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    2;
+    3;
 
   friend void swap(SCKickOff& a, SCKickOff& b) {
     a.Swap(&b);
@@ -1018,7 +1196,7 @@ class Robot final :
                &_Robot_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    3;
+    4;
 
   friend void swap(Robot& a, Robot& b) {
     a.Swap(&b);
@@ -1233,7 +1411,7 @@ class CSRobot final :
                &_CSRobot_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    4;
+    5;
 
   friend void swap(CSRobot& a, CSRobot& b) {
     a.Swap(&b);
@@ -1352,7 +1530,7 @@ class SCRobot final :
                &_SCRobot_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    5;
+    6;
 
   friend void swap(SCRobot& a, SCRobot& b) {
     a.Swap(&b);
@@ -1507,7 +1685,7 @@ class CSSign final :
                &_CSSign_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    6;
+    7;
 
   friend void swap(CSSign& a, CSSign& b) {
     a.Swap(&b);
@@ -1674,7 +1852,7 @@ class SCSign final :
                &_SCSign_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    7;
+    8;
 
   friend void swap(SCSign& a, SCSign& b) {
     a.Swap(&b);
@@ -1858,7 +2036,7 @@ class CSReq final :
                &_CSReq_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    8;
+    9;
 
   friend void swap(CSReq& a, CSReq& b) {
     a.Swap(&b);
@@ -2026,7 +2204,7 @@ class SCReq final :
                &_SCReq_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    9;
+    10;
 
   friend void swap(SCReq& a, SCReq& b) {
     a.Swap(&b);
@@ -2194,7 +2372,7 @@ class CSRep final :
                &_CSRep_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    10;
+    11;
 
   friend void swap(CSRep& a, CSRep& b) {
     a.Swap(&b);
@@ -2373,7 +2551,7 @@ class SCRep final :
                &_SCRep_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    11;
+    12;
 
   friend void swap(SCRep& a, SCRep& b) {
     a.Swap(&b);
@@ -2552,7 +2730,7 @@ class Offer final :
                &_Offer_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    12;
+    13;
 
   friend void swap(Offer& a, Offer& b) {
     a.Swap(&b);
@@ -2741,7 +2919,7 @@ class Answer final :
                &_Answer_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    13;
+    14;
 
   friend void swap(Answer& a, Answer& b) {
     a.Swap(&b);
@@ -2930,7 +3108,7 @@ class Candidate final :
                &_Candidate_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    14;
+    15;
 
   friend void swap(Candidate& a, Candidate& b) {
     a.Swap(&b);
@@ -3157,7 +3335,7 @@ class Leave final :
                &_Leave_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    15;
+    16;
 
   friend void swap(Leave& a, Leave& b) {
     a.Swap(&b);
@@ -3314,7 +3492,7 @@ class Close final :
                &_Close_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    16;
+    17;
 
   friend void swap(Close& a, Close& b) {
     a.Swap(&b);
@@ -3482,7 +3660,7 @@ class TestTextReq final :
                &_TestTextReq_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    17;
+    18;
 
   friend void swap(TestTextReq& a, TestTextReq& b) {
     a.Swap(&b);
@@ -3633,7 +3811,7 @@ class CanMessage final :
                &_CanMessage_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    18;
+    19;
 
   friend void swap(CanMessage& a, CanMessage& b) {
     a.Swap(&b);
@@ -3806,7 +3984,7 @@ class CCCanMesage final :
                &_CCCanMesage_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    19;
+    20;
 
   friend void swap(CCCanMesage& a, CCCanMesage& b) {
     a.Swap(&b);
@@ -3972,7 +4150,7 @@ class Wiper final :
                &_Wiper_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    20;
+    21;
 
   friend void swap(Wiper& a, Wiper& b) {
     a.Swap(&b);
@@ -4118,7 +4296,7 @@ class FrontLight final :
                &_FrontLight_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    21;
+    22;
 
   friend void swap(FrontLight& a, FrontLight& b) {
     a.Swap(&b);
@@ -4264,7 +4442,7 @@ class BackLight final :
                &_BackLight_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    22;
+    23;
 
   friend void swap(BackLight& a, BackLight& b) {
     a.Swap(&b);
@@ -4409,7 +4587,7 @@ class CCAskDataChannel final :
                &_CCAskDataChannel_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    23;
+    24;
 
   friend void swap(CCAskDataChannel& a, CCAskDataChannel& b) {
     a.Swap(&b);
@@ -4528,7 +4706,7 @@ class IMuMessage final :
                &_IMuMessage_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    24;
+    25;
 
   friend void swap(IMuMessage& a, IMuMessage& b) {
     a.Swap(&b);
@@ -4685,7 +4863,7 @@ class CCPing final :
                &_CCPing_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    25;
+    26;
 
   friend void swap(CCPing& a, CCPing& b) {
     a.Swap(&b);
@@ -4831,7 +5009,7 @@ class CCRadarMessage final :
                &_CCRadarMessage_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    26;
+    27;
 
   friend void swap(CCRadarMessage& a, CCRadarMessage& b) {
     a.Swap(&b);
@@ -5054,7 +5232,7 @@ class CCRobotAnalog final :
                &_CCRobotAnalog_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    27;
+    28;
 
   friend void swap(CCRobotAnalog& a, CCRobotAnalog& b) {
     a.Swap(&b);
@@ -5342,7 +5520,7 @@ class CCBootStrapReq final :
                &_CCBootStrapReq_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    28;
+    29;
 
   friend void swap(CCBootStrapReq& a, CCBootStrapReq& b) {
     a.Swap(&b);
@@ -5461,7 +5639,7 @@ class CCBooStrapRep final :
                &_CCBooStrapRep_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    29;
+    30;
 
   friend void swap(CCBooStrapRep& a, CCBooStrapRep& b) {
     a.Swap(&b);
@@ -5606,7 +5784,7 @@ class CCStartupReq final :
                &_CCStartupReq_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    30;
+    31;
 
   friend void swap(CCStartupReq& a, CCStartupReq& b) {
     a.Swap(&b);
@@ -5725,7 +5903,7 @@ class CCStartupRep final :
                &_CCStartupRep_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    31;
+    32;
 
   friend void swap(CCStartupRep& a, CCStartupRep& b) {
     a.Swap(&b);
@@ -5871,7 +6049,7 @@ class CCSwitch final :
                &_CCSwitch_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    32;
+    33;
 
   friend void swap(CCSwitch& a, CCSwitch& b) {
     a.Swap(&b);
@@ -6017,7 +6195,7 @@ class LidarPoint final :
                &_LidarPoint_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    33;
+    34;
 
   friend void swap(LidarPoint& a, LidarPoint& b) {
     a.Swap(&b);
@@ -6286,7 +6464,7 @@ class SensorStop final :
                &_SensorStop_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    34;
+    35;
 
   friend void swap(SensorStop& a, SensorStop& b) {
     a.Swap(&b);
@@ -6404,7 +6582,7 @@ class StopAck final :
                &_StopAck_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    35;
+    36;
 
   friend void swap(StopAck& a, StopAck& b) {
     a.Swap(&b);
@@ -6523,7 +6701,7 @@ class CCManipulation final :
                &_CCManipulation_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    36;
+    37;
 
   friend void swap(CCManipulation& a, CCManipulation& b) {
     a.Swap(&b);
@@ -6690,7 +6868,7 @@ class SCAddRobot final :
                &_SCAddRobot_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    37;
+    38;
 
   friend void swap(SCAddRobot& a, SCAddRobot& b) {
     a.Swap(&b);
@@ -6845,7 +7023,7 @@ class SCDelRobot final :
                &_SCDelRobot_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    38;
+    39;
 
   friend void swap(SCDelRobot& a, SCDelRobot& b) {
     a.Swap(&b);
@@ -7002,7 +7180,7 @@ class State final :
                &_State_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    39;
+    40;
 
   friend void swap(State& a, State& b) {
     a.Swap(&b);
@@ -7543,7 +7721,7 @@ class can_net_frame final :
                &_can_net_frame_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    40;
+    41;
 
   friend void swap(can_net_frame& a, can_net_frame& b) {
     a.Swap(&b);
@@ -7716,7 +7894,7 @@ class CCCanMsg final :
                &_CCCanMsg_default_instance_);
   }
   static constexpr int kIndexInFileMessages =
-    41;
+    42;
 
   friend void swap(CCCanMsg& a, CCCanMsg& b) {
     a.Swap(&b);
@@ -7830,6 +8008,101 @@ class CCCanMsg final :
   #pragma GCC diagnostic push
   #pragma GCC diagnostic ignored "-Wstrict-aliasing"
 #endif  // __GNUC__
+// UserActivityInfo
+
+// string user_uuid = 1;
+inline void UserActivityInfo::clear_user_uuid() {
+  user_uuid_.ClearToEmpty();
+}
+inline const std::string& UserActivityInfo::user_uuid() const {
+  // @@protoc_insertion_point(field_get:RemoNet.UserActivityInfo.user_uuid)
+  return _internal_user_uuid();
+}
+template <typename ArgT0, typename... ArgT>
+inline PROTOBUF_ALWAYS_INLINE
+void UserActivityInfo::set_user_uuid(ArgT0&& arg0, ArgT... args) {
+ 
+ user_uuid_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
+  // @@protoc_insertion_point(field_set:RemoNet.UserActivityInfo.user_uuid)
+}
+inline std::string* UserActivityInfo::mutable_user_uuid() {
+  std::string* _s = _internal_mutable_user_uuid();
+  // @@protoc_insertion_point(field_mutable:RemoNet.UserActivityInfo.user_uuid)
+  return _s;
+}
+inline const std::string& UserActivityInfo::_internal_user_uuid() const {
+  return user_uuid_.Get();
+}
+inline void UserActivityInfo::_internal_set_user_uuid(const std::string& value) {
+  
+  user_uuid_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
+}
+inline std::string* UserActivityInfo::_internal_mutable_user_uuid() {
+  
+  return user_uuid_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
+}
+inline std::string* UserActivityInfo::release_user_uuid() {
+  // @@protoc_insertion_point(field_release:RemoNet.UserActivityInfo.user_uuid)
+  return user_uuid_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
+}
+inline void UserActivityInfo::set_allocated_user_uuid(std::string* user_uuid) {
+  if (user_uuid != nullptr) {
+    
+  } else {
+    
+  }
+  user_uuid_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), user_uuid,
+      GetArenaForAllocation());
+#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
+  if (user_uuid_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
+    user_uuid_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
+  }
+#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
+  // @@protoc_insertion_point(field_set_allocated:RemoNet.UserActivityInfo.user_uuid)
+}
+
+// int32 cockpit_id = 2;
+inline void UserActivityInfo::clear_cockpit_id() {
+  cockpit_id_ = 0;
+}
+inline int32_t UserActivityInfo::_internal_cockpit_id() const {
+  return cockpit_id_;
+}
+inline int32_t UserActivityInfo::cockpit_id() const {
+  // @@protoc_insertion_point(field_get:RemoNet.UserActivityInfo.cockpit_id)
+  return _internal_cockpit_id();
+}
+inline void UserActivityInfo::_internal_set_cockpit_id(int32_t value) {
+  
+  cockpit_id_ = value;
+}
+inline void UserActivityInfo::set_cockpit_id(int32_t value) {
+  _internal_set_cockpit_id(value);
+  // @@protoc_insertion_point(field_set:RemoNet.UserActivityInfo.cockpit_id)
+}
+
+// int32 vehicle_id = 3;
+inline void UserActivityInfo::clear_vehicle_id() {
+  vehicle_id_ = 0;
+}
+inline int32_t UserActivityInfo::_internal_vehicle_id() const {
+  return vehicle_id_;
+}
+inline int32_t UserActivityInfo::vehicle_id() const {
+  // @@protoc_insertion_point(field_get:RemoNet.UserActivityInfo.vehicle_id)
+  return _internal_vehicle_id();
+}
+inline void UserActivityInfo::_internal_set_vehicle_id(int32_t value) {
+  
+  vehicle_id_ = value;
+}
+inline void UserActivityInfo::set_vehicle_id(int32_t value) {
+  _internal_set_vehicle_id(value);
+  // @@protoc_insertion_point(field_set:RemoNet.UserActivityInfo.vehicle_id)
+}
+
+// -------------------------------------------------------------------
+
 // CSAdd
 
 // string serial = 1;
@@ -11826,6 +12099,8 @@ CCCanMsg::frams() const {
 
 // -------------------------------------------------------------------
 
+// -------------------------------------------------------------------
+
 
 // @@protoc_insertion_point(namespace_scope)
 

+ 14 - 2
ZJ_PRO/Protocol/protocol.proto

@@ -43,8 +43,20 @@ enum SCMessage
   SC_NotifyCloseVideo=4018;
   SC_KickOff=4019;
   SC_State=4022;
+
+  S2V_SendUserInfo=6011;  //增加
   
 };
+
+//增加用于mqtt消息
+message UserActivityInfo
+{
+    string user_uuid=1;
+    int32 cockpit_id=2;
+    int32 vehicle_id=3;
+};
+
+
 enum CCMessage
 {
    CC_None=0;
@@ -419,7 +431,7 @@ message State
    int32 engine_num =35;        //发动机故障次数
 
    //增加0x28f
-   bytes all_Buff = 36;    //0x28f 信息  
+   bytes all_Buff=36;  
 };
 
 message can_net_frame
@@ -432,4 +444,4 @@ message can_net_frame
 message CCCanMsg
 {
     repeated can_net_frame frams=1;
-};
+};

+ 1 - 0
ZJ_PRO/common/notifier.h

@@ -50,6 +50,7 @@ public:
 
 
 	virtual void OnMessageFrameNotify(ChannelType type,int16_t cmd,int16_t length,const void * data) = 0;
+	virtual void OnMqttUser(std::string user_uid,int32_t cockpitId,int32_t vehicleId) = 0;//增加
 };
 /*
 #ifdef WIN32

+ 17 - 0
ZJ_PRO/common/socket_client.cpp

@@ -27,6 +27,8 @@ bool SocketClient::Start(const char * ip,int32_t Remote_port,int32_t Host_port)
 	FnMap.insert(std::make_pair(RemoNet::SC_NotifyOffer, &SocketClient::OnNotifyOffer));
 	FnMap.insert(std::make_pair(RemoNet::SC_NotifyAnswer, &SocketClient::OnNotifyAnswer));
 	FnMap.insert(std::make_pair(RemoNet::SC_NotifyCandidate, &SocketClient::OnNotifyCandidate));
+	//增加
+	FnMap.insert(std::make_pair(RemoNet::S2V_SendUserInfo, &SocketClient::OnNotifyUserid));
 
 	_ip=ip;
 #ifdef WIN32
@@ -313,6 +315,21 @@ void SocketClient::OnNotifyCandidate(int8_t* Data, int16_t Size)
 	_notify->OnVideoCandidate(Rep.index(), Rep.candidate().c_str(), Rep.sdpmlineindex(), Rep.sdpmid().c_str());
 
 }
+
+void SocketClient::OnNotifyUserid(int8_t* Data, int16_t Size)
+{
+	printf("userid    SERVER TO  VEHICLE-----------------------------------------------------\n");
+
+	RemoNet::UserActivityInfo Rep;
+	Rep.ParseFromArray(Data, Size);
+	std::cout << Rep.user_uuid().c_str() << "  gg " << Rep.cockpit_id() <<"   gg  "<< Rep.vehicle_id() << std::endl;
+	printf("---------****----------\n");
+	// _notify->OnVideoCandidate(Rep.index(), Rep.candidate().c_str(), Rep.sdpmlineindex(), Rep.sdpmid().c_str());
+	_notify->OnMqttUser( Rep.user_uuid().c_str(),Rep.cockpit_id(),Rep.vehicle_id());
+	
+
+}
+
 void SocketClient::OnNotifyOffer(int8_t* Data, int16_t Size)
 {
     printf("进入OnNotifyOffer\n");

+ 2 - 0
ZJ_PRO/common/socket_client.h

@@ -88,6 +88,8 @@ private:
 	void OnNotifyOffer(int8_t* Data, int16_t Size);
 	void OnNotifyAnswer(int8_t* Data, int16_t Size);
 	void OnNotifyCandidate(int8_t* Data, int16_t Size);
+	void OnNotifyUserid(int8_t* Data, int16_t Size);  //增加
+
 	
 #ifdef WIN32
 	void OnRobotRep(int8_t* Data, int16_t Size);

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott