Selaa lähdekoodia

change server_fwupdate. not complete.

yuchuli 1 vuosi sitten
vanhempi
commit
7507675831

+ 1 - 1
src/driver/driver_group_grpc_server/main.cpp

@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
 
     iv::xmlparam::Xmlparam xp("./driver_group_grpc_server.xml");
 
-    gstrserver = xp.GetParam("server","0.0.0.0:31001");
+    gstrlsserver = xp.GetParam("server","0.0.0.0:31001");
     gbSaveToDB = xp.GetParam("savetodb",true);
     gstrdbpath = xp.GetParam("dbpath",getdefdbpath());
 

+ 41 - 0
src/include/proto3/commonrpc.proto

@@ -0,0 +1,41 @@
+// Copyright 2015 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "io.grpc.adc.commonrpc";
+option java_outer_classname = "CommonRPCProto";
+option objc_class_prefix = "HLW";
+
+package iv;
+
+// The Upload service definition.
+service CommonRPC {
+  // Sends a Upload
+  rpc rpcquery (queryrpcReq) returns (queryrpcReply) {}
+  
+}
+
+
+
+message queryrpcReq {
+  bytes data = 1; 
+}
+
+message queryrpcReply {
+    bytes data = 1;
+}
+
+

+ 5 - 0
src/tool/server_fwupdate/Readme.md

@@ -0,0 +1,5 @@
+cd to proto3 folder:
+
+protoc -I . --plugin=protoc-gen-grpc=/home/yuchuli/git/grpc-framework/build2/grpc_cpp_plugin --grpc_out=. commonrpc.proto
+
+

+ 86 - 0
src/tool/server_fwupdate/commonrpc.grpc.pb.cc

@@ -0,0 +1,86 @@
+// Generated by the gRPC C++ plugin.
+// If you make any local change, they will be lost.
+// source: commonrpc.proto
+
+#include "commonrpc.pb.h"
+#include "commonrpc.grpc.pb.h"
+
+#include <functional>
+#include <grpcpp/impl/codegen/async_stream.h>
+#include <grpcpp/impl/codegen/async_unary_call.h>
+#include <grpcpp/impl/codegen/channel_interface.h>
+#include <grpcpp/impl/codegen/client_unary_call.h>
+#include <grpcpp/impl/codegen/client_callback.h>
+#include <grpcpp/impl/codegen/message_allocator.h>
+#include <grpcpp/impl/codegen/method_handler.h>
+#include <grpcpp/impl/codegen/rpc_service_method.h>
+#include <grpcpp/impl/codegen/server_callback.h>
+#include <grpcpp/impl/codegen/server_callback_handlers.h>
+#include <grpcpp/impl/codegen/server_context.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/impl/codegen/sync_stream.h>
+namespace iv {
+
+static const char* CommonRPC_method_names[] = {
+  "/iv.CommonRPC/rpcquery",
+};
+
+std::unique_ptr< CommonRPC::Stub> CommonRPC::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
+  (void)options;
+  std::unique_ptr< CommonRPC::Stub> stub(new CommonRPC::Stub(channel));
+  return stub;
+}
+
+CommonRPC::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
+  : channel_(channel), rpcmethod_rpcquery_(CommonRPC_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
+  {}
+
+::grpc::Status CommonRPC::Stub::rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::iv::queryrpcReply* response) {
+  return ::grpc::internal::BlockingUnaryCall< ::iv::queryrpcReq, ::iv::queryrpcReply, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_rpcquery_, context, request, response);
+}
+
+void CommonRPC::Stub::experimental_async::rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response, std::function<void(::grpc::Status)> f) {
+  ::grpc::internal::CallbackUnaryCall< ::iv::queryrpcReq, ::iv::queryrpcReply, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_rpcquery_, context, request, response, std::move(f));
+}
+
+void CommonRPC::Stub::experimental_async::rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response, ::grpc::experimental::ClientUnaryReactor* reactor) {
+  ::grpc::internal::ClientCallbackUnaryFactory::Create< ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_rpcquery_, context, request, response, reactor);
+}
+
+::grpc::ClientAsyncResponseReader< ::iv::queryrpcReply>* CommonRPC::Stub::PrepareAsyncrpcqueryRaw(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) {
+  return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::iv::queryrpcReply, ::iv::queryrpcReq, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_rpcquery_, context, request);
+}
+
+::grpc::ClientAsyncResponseReader< ::iv::queryrpcReply>* CommonRPC::Stub::AsyncrpcqueryRaw(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) {
+  auto* result =
+    this->PrepareAsyncrpcqueryRaw(context, request, cq);
+  result->StartCall();
+  return result;
+}
+
+CommonRPC::Service::Service() {
+  AddMethod(new ::grpc::internal::RpcServiceMethod(
+      CommonRPC_method_names[0],
+      ::grpc::internal::RpcMethod::NORMAL_RPC,
+      new ::grpc::internal::RpcMethodHandler< CommonRPC::Service, ::iv::queryrpcReq, ::iv::queryrpcReply, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
+          [](CommonRPC::Service* service,
+             ::grpc::ServerContext* ctx,
+             const ::iv::queryrpcReq* req,
+             ::iv::queryrpcReply* resp) {
+               return service->rpcquery(ctx, req, resp);
+             }, this)));
+}
+
+CommonRPC::Service::~Service() {
+}
+
+::grpc::Status CommonRPC::Service::rpcquery(::grpc::ServerContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response) {
+  (void) context;
+  (void) request;
+  (void) response;
+  return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
+
+}  // namespace iv
+

+ 311 - 0
src/tool/server_fwupdate/commonrpc.grpc.pb.h

@@ -0,0 +1,311 @@
+// Generated by the gRPC C++ plugin.
+// If you make any local change, they will be lost.
+// source: commonrpc.proto
+// Original file comments:
+// Copyright 2015 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef GRPC_commonrpc_2eproto__INCLUDED
+#define GRPC_commonrpc_2eproto__INCLUDED
+
+#include "commonrpc.pb.h"
+
+#include <functional>
+#include <grpc/impl/codegen/port_platform.h>
+#include <grpcpp/impl/codegen/async_generic_service.h>
+#include <grpcpp/impl/codegen/async_stream.h>
+#include <grpcpp/impl/codegen/async_unary_call.h>
+#include <grpcpp/impl/codegen/client_callback.h>
+#include <grpcpp/impl/codegen/client_context.h>
+#include <grpcpp/impl/codegen/completion_queue.h>
+#include <grpcpp/impl/codegen/message_allocator.h>
+#include <grpcpp/impl/codegen/method_handler.h>
+#include <grpcpp/impl/codegen/proto_utils.h>
+#include <grpcpp/impl/codegen/rpc_method.h>
+#include <grpcpp/impl/codegen/server_callback.h>
+#include <grpcpp/impl/codegen/server_callback_handlers.h>
+#include <grpcpp/impl/codegen/server_context.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/impl/codegen/status.h>
+#include <grpcpp/impl/codegen/stub_options.h>
+#include <grpcpp/impl/codegen/sync_stream.h>
+
+namespace iv {
+
+// The Upload service definition.
+class CommonRPC final {
+ public:
+  static constexpr char const* service_full_name() {
+    return "iv.CommonRPC";
+  }
+  class StubInterface {
+   public:
+    virtual ~StubInterface() {}
+    // Sends a Upload
+    virtual ::grpc::Status rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::iv::queryrpcReply* response) = 0;
+    std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::iv::queryrpcReply>> Asyncrpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) {
+      return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::iv::queryrpcReply>>(AsyncrpcqueryRaw(context, request, cq));
+    }
+    std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::iv::queryrpcReply>> PrepareAsyncrpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) {
+      return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::iv::queryrpcReply>>(PrepareAsyncrpcqueryRaw(context, request, cq));
+    }
+    class experimental_async_interface {
+     public:
+      virtual ~experimental_async_interface() {}
+      // Sends a Upload
+      virtual void rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response, std::function<void(::grpc::Status)>) = 0;
+      #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      virtual void rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response, ::grpc::ClientUnaryReactor* reactor) = 0;
+      #else
+      virtual void rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response, ::grpc::experimental::ClientUnaryReactor* reactor) = 0;
+      #endif
+    };
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+    typedef class experimental_async_interface async_interface;
+    #endif
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+    async_interface* async() { return experimental_async(); }
+    #endif
+    virtual class experimental_async_interface* experimental_async() { return nullptr; }
+  private:
+    virtual ::grpc::ClientAsyncResponseReaderInterface< ::iv::queryrpcReply>* AsyncrpcqueryRaw(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) = 0;
+    virtual ::grpc::ClientAsyncResponseReaderInterface< ::iv::queryrpcReply>* PrepareAsyncrpcqueryRaw(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) = 0;
+  };
+  class Stub final : public StubInterface {
+   public:
+    Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
+    ::grpc::Status rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::iv::queryrpcReply* response) override;
+    std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::iv::queryrpcReply>> Asyncrpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) {
+      return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::iv::queryrpcReply>>(AsyncrpcqueryRaw(context, request, cq));
+    }
+    std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::iv::queryrpcReply>> PrepareAsyncrpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) {
+      return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::iv::queryrpcReply>>(PrepareAsyncrpcqueryRaw(context, request, cq));
+    }
+    class experimental_async final :
+      public StubInterface::experimental_async_interface {
+     public:
+      void rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response, std::function<void(::grpc::Status)>) override;
+      #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      void rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response, ::grpc::ClientUnaryReactor* reactor) override;
+      #else
+      void rpcquery(::grpc::ClientContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response, ::grpc::experimental::ClientUnaryReactor* reactor) override;
+      #endif
+     private:
+      friend class Stub;
+      explicit experimental_async(Stub* stub): stub_(stub) { }
+      Stub* stub() { return stub_; }
+      Stub* stub_;
+    };
+    class experimental_async_interface* experimental_async() override { return &async_stub_; }
+
+   private:
+    std::shared_ptr< ::grpc::ChannelInterface> channel_;
+    class experimental_async async_stub_{this};
+    ::grpc::ClientAsyncResponseReader< ::iv::queryrpcReply>* AsyncrpcqueryRaw(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) override;
+    ::grpc::ClientAsyncResponseReader< ::iv::queryrpcReply>* PrepareAsyncrpcqueryRaw(::grpc::ClientContext* context, const ::iv::queryrpcReq& request, ::grpc::CompletionQueue* cq) override;
+    const ::grpc::internal::RpcMethod rpcmethod_rpcquery_;
+  };
+  static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
+
+  class Service : public ::grpc::Service {
+   public:
+    Service();
+    virtual ~Service();
+    // Sends a Upload
+    virtual ::grpc::Status rpcquery(::grpc::ServerContext* context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response);
+  };
+  template <class BaseClass>
+  class WithAsyncMethod_rpcquery : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    WithAsyncMethod_rpcquery() {
+      ::grpc::Service::MarkMethodAsync(0);
+    }
+    ~WithAsyncMethod_rpcquery() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status rpcquery(::grpc::ServerContext* /*context*/, const ::iv::queryrpcReq* /*request*/, ::iv::queryrpcReply* /*response*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    void Requestrpcquery(::grpc::ServerContext* context, ::iv::queryrpcReq* request, ::grpc::ServerAsyncResponseWriter< ::iv::queryrpcReply>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+      ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
+    }
+  };
+  typedef WithAsyncMethod_rpcquery<Service > AsyncService;
+  template <class BaseClass>
+  class ExperimentalWithCallbackMethod_rpcquery : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    ExperimentalWithCallbackMethod_rpcquery() {
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      ::grpc::Service::
+    #else
+      ::grpc::Service::experimental().
+    #endif
+        MarkMethodCallback(0,
+          new ::grpc::internal::CallbackUnaryHandler< ::iv::queryrpcReq, ::iv::queryrpcReply>(
+            [this](
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+                   ::grpc::CallbackServerContext*
+    #else
+                   ::grpc::experimental::CallbackServerContext*
+    #endif
+                     context, const ::iv::queryrpcReq* request, ::iv::queryrpcReply* response) { return this->rpcquery(context, request, response); }));}
+    void SetMessageAllocatorFor_rpcquery(
+        ::grpc::experimental::MessageAllocator< ::iv::queryrpcReq, ::iv::queryrpcReply>* allocator) {
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(0);
+    #else
+      ::grpc::internal::MethodHandler* const handler = ::grpc::Service::experimental().GetHandler(0);
+    #endif
+      static_cast<::grpc::internal::CallbackUnaryHandler< ::iv::queryrpcReq, ::iv::queryrpcReply>*>(handler)
+              ->SetMessageAllocator(allocator);
+    }
+    ~ExperimentalWithCallbackMethod_rpcquery() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status rpcquery(::grpc::ServerContext* /*context*/, const ::iv::queryrpcReq* /*request*/, ::iv::queryrpcReply* /*response*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+    virtual ::grpc::ServerUnaryReactor* rpcquery(
+      ::grpc::CallbackServerContext* /*context*/, const ::iv::queryrpcReq* /*request*/, ::iv::queryrpcReply* /*response*/)
+    #else
+    virtual ::grpc::experimental::ServerUnaryReactor* rpcquery(
+      ::grpc::experimental::CallbackServerContext* /*context*/, const ::iv::queryrpcReq* /*request*/, ::iv::queryrpcReply* /*response*/)
+    #endif
+      { return nullptr; }
+  };
+  #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+  typedef ExperimentalWithCallbackMethod_rpcquery<Service > CallbackService;
+  #endif
+
+  typedef ExperimentalWithCallbackMethod_rpcquery<Service > ExperimentalCallbackService;
+  template <class BaseClass>
+  class WithGenericMethod_rpcquery : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    WithGenericMethod_rpcquery() {
+      ::grpc::Service::MarkMethodGeneric(0);
+    }
+    ~WithGenericMethod_rpcquery() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status rpcquery(::grpc::ServerContext* /*context*/, const ::iv::queryrpcReq* /*request*/, ::iv::queryrpcReply* /*response*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+  };
+  template <class BaseClass>
+  class WithRawMethod_rpcquery : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    WithRawMethod_rpcquery() {
+      ::grpc::Service::MarkMethodRaw(0);
+    }
+    ~WithRawMethod_rpcquery() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status rpcquery(::grpc::ServerContext* /*context*/, const ::iv::queryrpcReq* /*request*/, ::iv::queryrpcReply* /*response*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    void Requestrpcquery(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+      ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
+    }
+  };
+  template <class BaseClass>
+  class ExperimentalWithRawCallbackMethod_rpcquery : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    ExperimentalWithRawCallbackMethod_rpcquery() {
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      ::grpc::Service::
+    #else
+      ::grpc::Service::experimental().
+    #endif
+        MarkMethodRawCallback(0,
+          new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
+            [this](
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+                   ::grpc::CallbackServerContext*
+    #else
+                   ::grpc::experimental::CallbackServerContext*
+    #endif
+                     context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->rpcquery(context, request, response); }));
+    }
+    ~ExperimentalWithRawCallbackMethod_rpcquery() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status rpcquery(::grpc::ServerContext* /*context*/, const ::iv::queryrpcReq* /*request*/, ::iv::queryrpcReply* /*response*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+    virtual ::grpc::ServerUnaryReactor* rpcquery(
+      ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/)
+    #else
+    virtual ::grpc::experimental::ServerUnaryReactor* rpcquery(
+      ::grpc::experimental::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/)
+    #endif
+      { return nullptr; }
+  };
+  template <class BaseClass>
+  class WithStreamedUnaryMethod_rpcquery : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    WithStreamedUnaryMethod_rpcquery() {
+      ::grpc::Service::MarkMethodStreamed(0,
+        new ::grpc::internal::StreamedUnaryHandler<
+          ::iv::queryrpcReq, ::iv::queryrpcReply>(
+            [this](::grpc::ServerContext* context,
+                   ::grpc::ServerUnaryStreamer<
+                     ::iv::queryrpcReq, ::iv::queryrpcReply>* streamer) {
+                       return this->Streamedrpcquery(context,
+                         streamer);
+                  }));
+    }
+    ~WithStreamedUnaryMethod_rpcquery() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable regular version of this method
+    ::grpc::Status rpcquery(::grpc::ServerContext* /*context*/, const ::iv::queryrpcReq* /*request*/, ::iv::queryrpcReply* /*response*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    // replace default version of method with streamed unary
+    virtual ::grpc::Status Streamedrpcquery(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::iv::queryrpcReq,::iv::queryrpcReply>* server_unary_streamer) = 0;
+  };
+  typedef WithStreamedUnaryMethod_rpcquery<Service > StreamedUnaryService;
+  typedef Service SplitStreamedService;
+  typedef WithStreamedUnaryMethod_rpcquery<Service > StreamedService;
+};
+
+}  // namespace iv
+
+
+#endif  // GRPC_commonrpc_2eproto__INCLUDED

+ 110 - 0
src/tool/server_fwupdate/fwdb.cpp

@@ -0,0 +1,110 @@
+#include "fwdb.h"
+
+fwdb::fwdb()
+{
+    mpthread = new std::thread(&fwdb::threaddb,this);
+}
+
+fwdb::~fwdb()
+{
+    mbthreadrun = false;
+    mpthread->join();
+}
+
+void fwdb::OpenDataBase()
+{
+
+    mstrdbpath = "fw.db";
+
+    if(QSqlDatabase::contains("sqliteadc"))
+        mdatabase = QSqlDatabase::database("sqliteadc");
+    else
+        mdatabase = QSqlDatabase::addDatabase("QSQLITE","sqliteadc");
+//    mdatabase = QSqlDatabase::addDatabase("QSQLITE");
+
+
+//    if(QSqlDatabase::contains("sqlite"))
+//        mdatabase = QSqlDatabase::database("sqlite");
+//    else
+//        mdatabase = QSqlDatabase::addDatabase("QSQLITE","sqlite");
+
+
+
+    mdatabase.setDatabaseName(mstrdbpath.data());
+    if (!mdatabase.open())
+    {
+        qDebug("Error: Failed to connect database. error is %s ",mdatabase.lastError());
+        return;
+    }
+    else
+    {
+
+        qDebug("Succeed to connect database.");
+    }
+
+
+
+    QSqlQuery sql_query(mdatabase);
+
+    bool bHaveTable = true;
+
+    //查询数据
+    sql_query.exec("select count(*)  from sqlite_master where type='table' and name = 'accountdata'");
+    if(!sql_query.exec())
+    {
+        qDebug("%s",sql_query.lastError());
+        return;
+    }
+    else
+    {
+
+        if(sql_query.next())
+        {
+            int count = sql_query.value(0).toInt();
+//            qDebug("count %d ",count);
+            if(count < 1)bHaveTable = false;
+        }
+    }
+
+
+
+    if(bHaveTable == false)
+    {
+        if(!sql_query.exec("create table accountdata(id INTEGER primary key AUTOINCREMENT,username TEXT, password TEXT,"
+                           "phone TEXT, passneedchange BOOL, passerrorcount INTEGER,"
+                           "usercreatetime DATETIME)"))
+        {
+            qDebug() << "Error: Fail to create table."<< sql_query.lastError();
+            return;
+        }
+//        if(!sql_query.exec("CREATE INDEX index_vehid ON groupdata (vehid)"))
+//        {
+//            qDebug() << "Error: Fail to create index_vehid."<< sql_query.lastError();
+//            return;
+//        }
+//        if(!sql_query.exec("CREATE INDEX index_recvtime ON groupdata (recvtime)"))
+//        {
+//            qDebug() << "Error: Fail to create index_recvtime."<< sql_query.lastError();
+//            return;
+//        }
+//        if(!sql_query.exec("CREATE INDEX index_recordid ON groupdata (recordid)"))
+//        {
+//            qDebug() << "Error: Fail to create index_recordid."<< sql_query.lastError();
+//            return;
+//        }
+        char strsen[1000];
+        QDateTime now = QDateTime::currentDateTime();
+
+        QString strnow = now.toString("yyyy-MM-dd hh:mm:ss");
+        snprintf(strsen,1000,"INSERT INTO accountdata(username,password,passerrorcount,usercreatetime)"
+                 " VALUES(\"%s\",\"%s\",%d,\"%s\")",
+                                     "admin","adc",0,strnow.toLatin1().data());
+        sql_query.exec(strsen);
+        qDebug("Create Table groupdata successfully.");
+    }
+}
+
+void fwdb::threaddb()
+{
+    OpenDataBase();
+}

+ 36 - 0
src/tool/server_fwupdate/fwdb.h

@@ -0,0 +1,36 @@
+#ifndef FWDB_H
+#define FWDB_H
+
+
+#include <QSqlDatabase>
+#include <QSqlError>
+#include <QSqlQuery>
+#include <QDebug>
+#include <QFile>
+#include <QThread>
+#include <QDateTime>
+
+#include <vector>
+#include <mutex>
+#include <thread>
+
+class fwdb
+{
+public:
+    fwdb();
+    ~fwdb();
+
+private:
+    std::thread * mpthread;
+    bool mbthreadrun = true;
+    std::string mstrdbpath;
+    QSqlDatabase mdatabase;
+
+private:
+    void threaddb();
+    void OpenDataBase();
+
+
+};
+
+#endif // FWDB_H

+ 78 - 0
src/tool/server_fwupdate/main.cpp

@@ -1,9 +1,87 @@
 #include "mainwindow.h"
 #include <QApplication>
 
+#include <iostream>
+#include <vector>
+
+#include <iostream>
+#include <memory>
+#include <string>
+#include <thread>
+
+#include <grpcpp/grpcpp.h>
+#include <grpcpp/health_check_service_interface.h>
+#include <grpcpp/ext/proto_server_reflection_plugin.h>
+
+#include "commonrpc.grpc.pb.h"
+
+using grpc::Server;
+using grpc::ServerBuilder;
+using grpc::ServerContext;
+using grpc::Status;
+
+static std::unique_ptr<Server> gserver_grpc;
+static std::string gstrserver;
+
+#include "xmlparam.h"
+
+// Logic and data behind the server's behavior.
+class CommonRPCServiceImpl final : public iv::CommonRPC::Service{
+  Status rpcquery(ServerContext* context, const iv::queryrpcReq * request,
+                  iv::queryrpcReply * reply) override {
+
+
+    return Status::OK;
+  }
+
+};
+
+void RunServer() {
+  std::string server_address = gstrserver ;//("0.0.0.0:31001");
+  CommonRPCServiceImpl service;
+
+  grpc::EnableDefaultHealthCheckService(true);
+//  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+  ServerBuilder builder;
+  // Listen on the given address without any authentication mechanism.
+  builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
+
+  builder.SetMaxReceiveMessageSize(300000000);
+ // builder.SetMaxMessageSize(100000000);
+
+
+//  builder.SetMaxSendMessageSize(100000000);
+  // Register "service" as the instance through which we'll communicate with
+  // clients. In this case it corresponds to an *synchronous* service.
+  builder.RegisterService(&service);
+  // Finally assemble the server.
+ // std::unique_ptr<Server> server(builder.BuildAndStart());
+  gserver_grpc = builder.BuildAndStart();
+  std::cout << "Server listening on " << server_address << std::endl;
+
+  // Wait for the server to shutdown. Note that some other thread must be
+  // responsible for shutting down the server for this call to ever return.
+//  server->Wait();
+  gserver_grpc->Wait();
+}
+
+void threadrpc()
+{
+    RunServer();
+}
+
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
+
+
+    iv::xmlparam::Xmlparam xp("./server_fwupdate.xml");
+
+    gstrserver = xp.GetParam("server","0.0.0.0:19111");
+
+    std::thread * pthreadrpc = new std::thread(&threadrpc);
+    (void)pthreadrpc;
+
     MainWindow w;
     w.show();
 

+ 3 - 0
src/tool/server_fwupdate/mainwindow.cpp

@@ -12,11 +12,14 @@ MainWindow::MainWindow(QWidget *parent) :
     m_tcpserverFW->setMaxPendingConnections(2000);
     connect(m_tcpserverFW,SIGNAL(newConnection()), this,SLOT(newfwupdateConnect()));
 
+    mpfwdb = new fwdb();
+
     setWindowTitle("Shenlan Firmware update auth server.");
 }
 
 MainWindow::~MainWindow()
 {
+    delete mpfwdb;
     delete ui;
 }
 

+ 4 - 0
src/tool/server_fwupdate/mainwindow.h

@@ -9,6 +9,8 @@
 #include <mutex>
 #include <QTcpSocket>
 
+#include "fwdb.h"
+
 namespace Ui {
 class MainWindow;
 }
@@ -45,6 +47,8 @@ private:
 
     QTcpServer * m_tcpserverFW;
 
+    fwdb * mpfwdb;
+
 };
 
 #endif // MAINWINDOW_H

+ 22 - 3
src/tool/server_fwupdate/server_fwupdate.pro

@@ -6,7 +6,7 @@
 
 QT       += core gui  network
 
-
+QT += sql
 
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
@@ -27,10 +27,29 @@ DEFINES += QT_DEPRECATED_WARNINGS
 
 SOURCES += \
         main.cpp \
-        mainwindow.cpp
+        mainwindow.cpp \
+    fwdb.cpp \
+    commonrpc.grpc.pb.cc \
+    ../../include/msgtype/commonrpc.pb.cc
 
 HEADERS += \
-        mainwindow.h
+        mainwindow.h \
+    fwdb.h \
+    commonrpc.grpc.pb.h \
+    ../../include/msgtype/commonrpc.pb.h
 
 FORMS += \
         mainwindow.ui
+
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+}
+
+!include(../../../include/ivgrpc.pri ) {
+    error( "Couldn't find the ivgrpc.pri file!" )
+}
+