/// <summary>
        /// 设备类请求处理
        /// </summary>
        /// <param name="rpcRequest"></param>
        /// <returns></returns>
        private RpcResponse HandleDeviceRequest(RpcRequest rpcRequest)
        {
            var masProtocol = rpcRequest.ToRequest <GatewayRpcRequest>().MasProtocol;
            //调用驱动 处理业务
            DeviceProtocol deviceProtocol = masProtocol.Deserialize <DeviceProtocol>();
            string         driverCode     = GatewayMapper.GetDriverCodeByDeviceCode(deviceProtocol.DeviceCode);

            GatewayManager.DriverManager.HandleProtocolData(driverCode, masProtocol);

            return(RpcResponse.Response <GatewayRpcResponse>(new GatewayRpcResponse()));
        }
예제 #2
0
 public LeafDeviceBuilder(
     string iothubConnectionString,
     string eventhubCompatibleEndpointWithEntityPath,
     string deviceId,
     string trustedCACertificateFileName,
     string edgeHostName,
     string edgeDeviceId,
     DeviceProtocol protocol)
 {
     this.iothubConnectionString = Preconditions.CheckNotNull(iothubConnectionString);
     this.eventhubCompatibleEndpointWithEntityPath = Preconditions.CheckNotNull(eventhubCompatibleEndpointWithEntityPath);
     this.deviceId = Preconditions.CheckNotNull(deviceId);
     this.trustedCACertificateFileName = Preconditions.CheckNotNull(trustedCACertificateFileName);
     this.edgeHostName = Preconditions.CheckNotNull(edgeHostName);
     this.edgeDeviceId = Preconditions.CheckNotNull(edgeDeviceId);
     this.protocol     = protocol;
     this.usePrimaryThumbprintClientCert = false;
 }
예제 #3
0
 LeafDevice(
     string iothubConnectionString,
     string eventhubCompatibleEndpointWithEntityPath,
     string deviceId,
     string trustedCACertificateFileName,
     string edgeHostName,
     string edgeDeviceId,
     DeviceProtocol protocol,
     Option <DeviceCertificate> deviceCertificate,
     Option <IList <string> > thumbprintCertificates)
     : base(
         iothubConnectionString,
         eventhubCompatibleEndpointWithEntityPath,
         deviceId,
         trustedCACertificateFileName,
         edgeHostName,
         edgeDeviceId,
         protocol,
         deviceCertificate,
         thumbprintCertificates)
 {
 }
예제 #4
0
        protected Details(
            string iothubConnectionString,
            string eventhubCompatibleEndpointWithEntityPath,
            string deviceId,
            string trustedCACertificateFileName,
            string edgeHostName,
            string edgeDeviceId,
            DeviceProtocol protocol,
            Option <DeviceCertificate> clientCertificatePaths,
            Option <IList <string> > thumbprintCertificatePaths)
        {
            this.iothubConnectionString = iothubConnectionString;
            this.eventhubCompatibleEndpointWithEntityPath = eventhubCompatibleEndpointWithEntityPath;
            this.deviceId = deviceId;
            this.trustedCACertificateFileName = trustedCACertificateFileName;
            this.edgeHostName = edgeHostName;
            if (!edgeDeviceId.IsNullOrWhiteSpace())
            {
                this.edgeDeviceId = Option.Some(edgeDeviceId);
            }

            (this.authType,
             this.clientCertificate,
             this.clientCertificateChain,
             this.thumbprints) = ObtainAuthDetails(clientCertificatePaths, thumbprintCertificatePaths);

            if (protocol == DeviceProtocol.AmqpWS || protocol == DeviceProtocol.MqttWs)
            {
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp_WebSocket_Only;
                this.eventHubClientTransportType = EventHubClientTransportType.AmqpWebSockets;
                if (protocol == DeviceProtocol.MqttWs)
                {
                    this.deviceTransportSettings = new ITransportSettings[] { new MqttTransportSettings(DeviceClientTransportType.Mqtt_WebSocket_Only) };
                }
                else
                {
                    this.deviceTransportSettings = new ITransportSettings[] { new AmqpTransportSettings(DeviceClientTransportType.Amqp_WebSocket_Only) };
                }
            }
            else
            {
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp;
                this.eventHubClientTransportType = EventHubClientTransportType.Amqp;
                if (protocol == DeviceProtocol.Mqtt)
                {
                    this.deviceTransportSettings = new ITransportSettings[] { new MqttTransportSettings(DeviceClientTransportType.Mqtt_Tcp_Only) };
                }
                else
                {
                    this.deviceTransportSettings = new ITransportSettings[] { new AmqpTransportSettings(DeviceClientTransportType.Amqp_Tcp_Only) };
                }
            }

            Console.WriteLine(
                $"Leaf Device Client: \n"
                + $"\t[authType={this.authType}] \n"
                + $"\t[clientCertificate subject name={this.clientCertificate.Match(c => c.SubjectName.ToString(), () => string.Empty)}] \n"
                + $"\t[clientCertificateChain count={this.clientCertificateChain.Match(c => c.Count(), () => 0)}] \n"
                + $"\t[service client transport type={this.serviceClientTransportType}]\n"
                + $"\t[event hub client transport type={this.eventHubClientTransportType}]\n"
                + $"\t[device transport type={this.deviceTransportSettings.First().GetTransportType()}]");
        }
예제 #5
0
 public CommunicationResource(ResourceType rt, DeviceProtocol dp, string rn)
 {
     resource_type   = rt;
     resource_name   = rn;
     device_protocol = dp;
 }