zoukankan      html  css  js  c++  java
  • TBluetoothLE.OnDisconnectDevice

    自己作为广播方,连接我的设备断开收到的事件。

    TBluetoothLE.OnDisconnectDevice

     TBluetoothLEDevice

    BluetoothLE1->DiscoveredDevices->Items[i]->DisposeOf();

     BluetoothLE1.DiscoveredDevices[0].OnConnect;

     BluetoothLE1.DiscoveredDevices[0].OnDisconnect;

    procedure TForm7.myDisConnect( Sender : TObject );
    begin
    
    end;
    
    procedure TForm7.FormCreate( Sender : TObject );
    begin
        BluetoothLE1.DiscoveredDevices[ 0 ].OnDisconnect := myDisConnect;
    end;


    和下面这个是相反的。

    System.Mac.Bluetooth.pas
    
    { TInternalBluetoothLEManager }
    
    procedure TInternalBluetoothLEManager.centralManagerDidConnectPeripheral(central: CBCentralManager; peripheral: CBPeripheral);
    begin
      FLastError := 0;
      FConnected := True;
      if Assigned(FOnDeviceConnect) then
        FOnDeviceConnect(Self, peripheral);
    end;
    
    procedure TInternalBluetoothLEManager.centralManagerdidDisconnectPeripheral(central: CBCentralManager; peripheral: CBPeripheral;
      error: NSError);
    begin
      FLastError := error.code;
      FConnected := True;
      if Assigned(FOnDeviceDisconnect) then
        FOnDeviceDisconnect(Self, peripheral);
    end;

    property OnDeviceDisconnect: TDeviceConnectionChangeEvent read FOnDeviceDisconnect write FOnDeviceDisconnect;
    property OnDeviceConnect: TDeviceConnectionChangeEvent read FOnDeviceConnect write FOnDeviceConnect;

         FOnConnect: TNotifyEvent;
        FOnDisconnect: TNotifyEvent;

    所以可以用TNotifyEvent自定义通知事件来解决。

    TNotifyEvent is used for events that do not require parameters.

    The TNotifyEvent type is the type for events that have no event-specific parameters. These events simply notify the component that a specific event occurred. For example, OnClick, which is of type TNotifyEvent, notifies the control that a click event occurred on the control.

    The Sender parameter is the object whose event handler is called. For example, with the OnClick event of a button, the Sender parameter is the button component that is clicked.

    property OnDisconnect: TNotifyEvent read FOnDisconnect write FOnDisconnect;
    // will be invoked once disconnected
    
    -(void)centralManager:(CBCentralManager *)central
      didDisconnectPeripheral:(CBPeripheral *)peripheral 
                             error:(NSError *)error;
  • 相关阅读:
    python--模块与包
    内置函数 的总结
    迭代器 生成器 列表推导式 生成器表达式的一些总结
    函数的有用信息 带参数的装饰器 多个装饰器装饰一个函数
    函数名的应用(第一对象) 闭包 装饰器
    动态参数 名称空间 作用域 作用域链 加载顺序 函数的嵌套 global nonlocal 等的用法总结
    函数的初识 函数的返回值 参数
    文件操作 常用操作方法 文件的修改
    遍历字典的集中方法 集合的作用 以及增删查的方法
    计算机硬件的小知识
  • 原文地址:https://www.cnblogs.com/cb168/p/5151867.html
Copyright © 2011-2022 走看看