/// <summary> /// 初始化系统默认service,系统service以$作为开头 /// </summary> private void InitSysServices() { this.otaService = new OTAService(); this.AddService("$ota", this.otaService); this.timeSyncService = new TimeSyncService(); this.AddService("$time_sync", timeSyncService); }
public void FunTimeSyncSample(string serverUri, int port, string deviceId, string deviceSecret) { // 创建设备 IoTDevice device = new IoTDevice(serverUri, port, deviceId, deviceSecret); if (device.Init() != 0) { return; } TimeSyncService timeSyncService = device.timeSyncService; timeSyncService.listener = this; timeSyncService.RequestTimeSync(); }
public static void Main(string[] args) { GrpcEnvironment.SetLogger(new ConsoleLogger()); Server server = new Server { Services = { AuthService.BindService(new SpotAuthService()), RobotIdService.BindService(new SpotRobotIdService()), DirectoryService.BindService(new SpotDirectoryService()), TimeSyncService.BindService(new SpotTimeSyncService()), EstopService.BindService(new SpotEstopService()), LeaseService.BindService(new SpotLeaseService()), PowerService.BindService(new SpotPowerService()), RobotStateService.BindService(new SpotRobotStateService()), RobotCommandService.BindService(new SpotRobotCommandService()), ImageService.BindService(new SpotImageService()) }, Ports = { new ServerPort( "0.0.0.0", Port, new SslServerCredentials( new List <KeyCertificatePair>() { new KeyCertificatePair( File.ReadAllText(@"server.crt"), File.ReadAllText(@"server.key") ) }, File.ReadAllText(@"ca.crt"), false ) ) }, }; server.Start(); Console.WriteLine("Virtual spot 001 is active on port " + Port); Console.WriteLine("Press any key to shutdown"); Console.ReadKey(); server.ShutdownAsync().Wait(); }