強烈建議大家把 CBCentralManager.h 里面的代理方法全部看一遍(就是翻譯一遍,別偷懶)。@file CBCentralManager.h


/*先注釋再編寫

 * @file CBCentralManager.h

 * @framework CoreBluetooth

 *

 *  @discussion Entry point to the central role.

 *

 * @copyright 2011 Apple, Inc. All rights reserved.

 */

 

#ifndef _CORE_BLUETOOTH_H_

#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.

#endif

 

#import <CoreBluetooth/CBDefines.h>

#import <CoreBluetooth/CBAdvertisementData.h>

#import <CoreBluetooth/CBCentralManagerConstants.h>

#import <Foundation/Foundation.h>

 

NS_ASSUME_NONNULL_BEGIN //NS假設null開始

 

/*!

 *  @enum CBCentralManagerState//中心控制管理者狀態

 *

 *  @discussion Represents the current state of a CBCentralManager. //討論了CB CentralManager的當前狀態。

 *

 *  @constant CBCentralManagerStateUnknown       State unknown, update imminent.

 *  @constant CBCentralManagerStateResetting     The connection with the system service was momentarily lost, update imminent.

 *  @constant CBCentralManagerStateUnsupported   The platform doesn't support the Bluetooth Low Energy Central/Client role.

 *  @constant CBCentralManagerStateUnauthorized  The application is not authorized to use the Bluetooth Low Energy Central/Client role.

 *  @constant CBCentralManagerStatePoweredOff    Bluetooth is currently powered off.

 *  @constant CBCentralManagerStatePoweredOn     Bluetooth is currently powered on and available to use.

 *

 */

typedef NS_ENUM(NSInteger, CBCentralManagerState) {

CBCentralManagerStateUnknown = 0,//CB中央管理器狀態未知= 0

CBCentralManagerStateResetting,//CB中央管理器狀態重置

CBCentralManagerStateUnsupported,//CB中央管理器不支持的狀態

CBCentralManagerStateUnauthorized,//未經授權的CB中央管理器狀態

CBCentralManagerStatePoweredOff,//CB中央管理器關閉狀態

CBCentralManagerStatePoweredOn,//CB中央管理器啟動狀態

};

 

@protocol CBCentralManagerDelegate;

@class CBUUID, CBPeripheral;

 

/*!

 *  @class CBCentralManager

 *

 *  @discussion Entry point to the central role. Commands should only be issued when its state is <code>CBCentralManagerStatePoweredOn</code>.//@discussion入口點的中心角色。命令只能發布其狀態時<代碼> CBCentralManagerStatePoweredOn > < /代碼。

 *

 */

NS_CLASS_AVAILABLE(10_7, 5_0)

CB_EXTERN_CLASS @interface CBCentralManager : NSObject

 

/*!

 *  @property delegate

 *

 *  @discussion The delegate object that will receive central events.//討論接收中心事件的委托對象。

 *

 */

@property(assign, nonatomic, nullable) id<CBCentralManagerDelegate> delegate;

 

/*!

 *  @property state//狀態

 *

 *  @discussion The current state of the central, initially set to <code>CBCentralManagerStateUnknown</code>. Updates are provided by required//討論當前狀態的中央,最初設置為<代碼> CBCentralManagerStateUnknown > < /代碼。更新提供必需的

 *              delegate method {@link centralManagerDidUpdateState:}.//代理 方法 連接 中央管理器所做的更新狀態

 *

 */

@property(readonly) CBCentralManagerState state;//狀態只讀

 

/*!

 *  @property isAdvertising//是廣告

 *

 *  @discussion Whether or not the central is currently scanning.//討論是否中央目前掃描。

 *

 */

@property(readonly) BOOL isScanning NS_AVAILABLE(NA, 9_0);

 

/*!

 *  @method initWithDelegate:queue://方法initWithDelegate:隊列:

 *

 *  @param delegate The delegate that will receive central role events.//參數代表接收中心作用事件委托。

 *  @param queue    The dispatch queue on which the events will be dispatched.//param隊列的調度隊列事件將派遣。

 *

 *  @discussion     The initialization call. The events of the central role will be dispatched on the provided queue.//討論了初始化。事件的核心作用將派遣提供隊列。

 *                  If <i>nil</i>, the main queue will be used.//如果<我> nil < / i >,主隊列將被使用。

 *

 */

- (instancetype)initWithDelegate:(nullable id<CBCentralManagerDelegate>)delegate

  queue:(nullable dispatch_queue_t)queue;

 

/*!

 *  @method initWithDelegate:queue:options://方法initWithDelegate:隊列:選項:

 *

 *  @param delegate The delegate that will receive central role events.//參數代表接收中心作用事件委托。

 *  @param queue    The dispatch queue on which the events will be dispatched.//param隊列的調度隊列事件將派遣。

 *  @param options  An optional dictionary specifying options for the manager.//參數選項指定一個可選的詞典選項的經理。

 *

 *  @discussion     The initialization call. The events of the central role will be dispatched on the provided queue.//討論了初始化。事件的核心作用將派遣提供隊列。

 *                  If <i>nil</i>, the main queue will be used.//如果<我> nil < / i >,主隊列將被使用。

 *

 * @seealso CBCentralManagerOptionShowPowerAlertKey//參見CB AlertKey中央管理器選項顯示力量

 * @seealso CBCentralManagerOptionRestoreIdentifierKey//參見CB恢復IdentifierKey中央管理器選項

 *

 */

- (instancetype)initWithDelegate:(nullable id<CBCentralManagerDelegate>)delegate

  queue:(nullable dispatch_queue_t)queue

options:(nullable NSDictionary<NSString *, id> *)options NS_AVAILABLE(NA, 7_0) NS_DESIGNATED_INITIALIZER;

 

/*!

 *  @method retrievePeripheralsWithIdentifiers://方法檢索外圍設備標識符:

 *

 *  @param identifiers A list of <code>NSUUID</code> objects.//參數標識符的列表<代碼> NSUUID > < /代碼對象

 *

 *  @discussion Attempts to retrieve the <code>CBPeripheral</code> object(s) with the corresponding <i>identifiers</i>.

 *//討論試圖檢索<代碼> CBPeripheral > < /代碼對象(s)與相應的<我> < / i >標識符。

 * @return A list of <code>CBPeripheral</code> objects.//返回一個列表的<代碼> CBPeripheral > < /代碼對象。

 *

 */

- (NSArray<CBPeripheral *> *)retrievePeripheralsWithIdentifiers:(NSArray<NSUUID *> *)identifiers NS_AVAILABLE(NA, 7_0);

 

/*!

 *  @method retrieveConnectedPeripheralsWithServices//方法檢索連接外圍設備與服務

 *

 *  @discussion Retrieves all peripherals that are connected to the system and implement any of the services listed in <i>serviceUUIDs</i>.//討論檢索所有外圍設備連接到系統和實現任何的服務列在<我> < / i >服務uuid

 * Note that this set can include peripherals which were connected by other applications, which will need to be connected locally//注意,這個集合包括外圍設備連接的其他應用程序,將需要在本地連接

 * via {@link connectPeripheral:options:} before they can be used.//通過{ @link connectPeripheral:選擇:}才可以使用。

 *

 * @return A list of <code>CBPeripheral</code> objects.//返回一個列表的<代碼> CBPeripheral > < /代碼對象。

 *

 */

- (NSArray<CBPeripheral *> *)retrieveConnectedPeripheralsWithServices:(NSArray<CBUUID *> *)serviceUUIDs NS_AVAILABLE(NA, 7_0);

 

/*!

 *  @method scanForPeripheralsWithServices:options://方法掃描外圍設備與服務:選項:

 *

 *  @param serviceUUIDs A list of <code>CBUUID</code> objects representing the service(s) to scan for.//param服務uuid的列表<代碼> CBUUID > < /代碼對象代表服務(s)掃描。

 *  @param options      An optional dictionary specifying options for the scan.//參數選項指定一個可選的詞典選項掃描。

 *

 *  @discussion         Starts scanning for peripherals that are advertising any of the services listed in <i>serviceUUIDs</i>. Although strongly discouraged,//討論開始掃描的外設廣告的任何服務列在<我> serviceUUIDs < / i >。雖然強烈的沮喪,

 *                      if <i>serviceUUIDs</i> is <i>nil</i> all discovered peripherals will be returned. If the central is already scanning with different//如果<我> serviceUUIDs < / i > <我>零< / i >將返回所有發現的外圍設備。如果中央已經掃描與不同

 *                      <i>serviceUUIDs</i> or <i>options</i>, the provided parameters will replace them.//服務uuid < / i >或<我> < / i >選項,將取代他們所提供的參數。

 *                      Applications that have specified the <code>bluetooth-central</code> background mode are allowed to scan while backgrounded, with two//應用程序指定的<代碼> bluetooth-central < /代碼>背景模式允許掃描末尾時,有兩個

 *                      caveats: the scan must specify one or more service types in <i>serviceUUIDs</i>, and the <code>CBCentralManagerScanOptionAllowDuplicatesKey</code>//警告:掃描必須指定一個或多個服務類型在<我> < / i >服務uuid、和<代碼> CB中央管理器掃描選項允許重復關鍵代碼> < /

 *                      scan option will be ignored.//掃描選項將被忽略。

 *

 *  @see                centralManager:didDiscoverPeripheral:advertisementData:RSSI://看到中央管理器:發現外圍:廣告數據:RSSI:

 *  @seealso            CBCentralManagerScanOptionAllowDuplicatesKey//參見CB中央管理器掃描選項允許復制鑰匙

 * @seealso CBCentralManagerScanOptionSolicitedServiceUUIDsKey//參見CB中央管理器請求服務uuid鍵掃描選項

 *

 */

- (void)scanForPeripheralsWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs options:(nullable NSDictionary<NSString *, id> *)options;

 

/*!

 *  @method stopScan://方法停止掃描:

 *

 *  @discussion Stops scanning for peripherals.//討論了掃描外圍設備。

 *

 */

- (void)stopScan;

 

/*!

 *  @method connectPeripheral:options://方法連接外圍:選項:

 *

 *  @param peripheral   The <code>CBPeripheral</code> to be connected.//param外圍<代碼> CB外圍> < /代碼被連接。

 *  @param options      An optional dictionary specifying connection behavior options.//參數選項指定一個可選的詞典連接行為選項。

 *

 *  @discussion         Initiates a connection to <i>peripheral</i>. Connection attempts never time out and, depending on the outcome, will result//討論發起一個連接到<我> < / i >外圍。連接嘗試從來沒有時間出去,根據結果,將結果

 *                      in a call to either {@link centralManager:didConnectPeripheral:} or {@link centralManager:didFailToConnectPeripheral:error:}.//在調用{ @link中央管理器:連接外圍:}或{ @link中央管理器:外圍連接失敗:錯誤:}。

 *                      Pending attempts are cancelled automatically upon deallocation of <i>peripheral</i>, and explicitly via {@link cancelPeripheralConnection}.等待嘗試取消自動回收的<我> < / i >外圍,並通過{ @link取消外圍連接}明確。

 *

 *  @see                centralManager:didConnectPeripheral://看到中央管理器:連接周邊:

 *  @see                centralManager:didFailToConnectPeripheral:error://看到中央管理器:外圍連接失敗:錯誤:

 *  @seealso            CBConnectPeripheralOptionNotifyOnConnectionKey//參見CB連接外圍選項通知連接的關鍵

 *  @seealso            CBConnectPeripheralOptionNotifyOnDisconnectionKey//參見CB連接外圍選項通知斷開關鍵

 *  @seealso            CBConnectPeripheralOptionNotifyOnNotificationKey//參見CB連接外圍選項通知通知關鍵

 *

 */

- (void)connectPeripheral:(CBPeripheral *)peripheral options:(nullable NSDictionary<NSString *, id> *)options;

 

/*!

 *  @method cancelPeripheralConnection://方法取消外圍連接:

 *

 *  @param peripheral   A <code>CBPeripheral</code>.//param外圍<代碼> CBPeripheral > < /代碼。

 *

 *  @discussion         Cancels an active or pending connection to <i>peripheral</i>. Note that this is non-blocking, and any <code>CBPeripheral</code>//討論取消一個活動或等待連接到<我> < / i >外圍。注意,這是阻塞,任何<代碼> CBPeripheral > < /代碼

 *                      commands that are still pending to <i>peripheral</i> may or may not complete.//命令,仍懸而未決的<我> < / i >外圍可能或不可能完成。

 *

 *  @see                centralManager:didDisconnectPeripheral:error://看到中央管理器:斷開外圍:錯誤:

 *

 */

- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral;

 

@end

 

 

/*!

 *  @protocol CBCentralManagerDelegate//CB中央管理器委托協議

 *

 *  @discussion The delegate of a {@link CBCentralManager} object must adopt the <code>CBCentralManagerDelegate</code> protocol.//討論委托的CB中央管理器} { @鏈接對象必須采用<代碼> CB中央管理器委托代碼> < /協議。 The

 *              single required method indicates the availability of the central manager, while the optional methods allow for the discovery and//所需的單一方法表明中央管理器的可用性,同時允許發現和可選的方法

 *              connection of peripherals.//連接的外圍設備。

 *

 */

@protocol CBCentralManagerDelegate <NSObject>

 

@required

 

/*!

 *  @method centralManagerDidUpdateState://方法是中央管理器更新狀態:

 *

 *  @param central  The central manager whose state has changed.//param中央中央管理器的狀態已經改變了。

 *

 *  @discussion     Invoked whenever the central manager's state has been updated. Commands should only be issued when the state is//討論當中央管理器調用的狀態已更新。只能狀態時發出的命令

 *                  <code>CBCentralManagerStatePoweredOn</code>.//<代碼> CB中央管理器狀態啟動> < /代碼。 A state below <code>CBCentralManagerStatePoweredOn</code>//狀態下<代碼> CB中央管理器狀態啟動代碼> < /

 *                  implies that scanning has stopped and any connected peripherals have been disconnected. If the state moves below//意味着掃描已經停止和任何連接外圍設備已經斷開連接。如果在移動狀態下

 *                  <code>CBCentralManagerStatePoweredOff</code>, //CB中央管理器關閉狀態 all <code>CBPeripheral</code> objects obtained from this central//所有CB 外圍的對象從這個中心獲得

 *                  manager become invalid and must be retrieved or discovered again.//經理再次成為無效的和必須檢索或發現。

 *

 *  @see            state//觀察,狀態

 *

 */

- (void)centralManagerDidUpdateState:(CBCentralManager *)central;

 

@optional

 

/*!

 *  @method centralManager:willRestoreState://中央管理器方法:將恢復狀態:

 *

 *  @param central      The central manager providing this information.//param中央中央管理器提供這些信息。

 *  @param dict A dictionary containing information about <i>central</i> that was preserved by the system at the time the app was terminated.//param dict字典包含<我> < / i >中部信息保存的系統應用時終止。

 *

 *  @discussion For apps that opt-in to state preservation and restoration, this is the first method invoked when your app is relaunched into//討論應用程序選擇國家保護和恢復,這是第一個方法調用應用程序重新啟動時

 * the background to complete some Bluetooth-related task. Use this method to synchronize your app's state with the state of the//完成一些Bluetooth-related任務的背景。使用這種方法同步應用程序的狀態的狀態

 * Bluetooth system.//藍牙系統

 *

 *  @seealso            CBCentralManagerRestoredStatePeripheralsKey;//參見CB中央管理器恢復國家外圍設備的關鍵;

 *  @seealso            CBCentralManagerRestoredStateScanServicesKey;//參見CB中央管理器恢復狀態掃描服務的關鍵;

 *  @seealso            CBCentralManagerRestoredStateScanOptionsKey;//參見CB中央管理器恢復狀態掃描選項鍵;

 *

 */

- (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary<NSString *, id> *)dict;

 

/*!

 *  @method centralManager:didDiscoverPeripheral:advertisementData:RSSI://中央管理器方法:發現外圍:廣告數據:RSSI:

 *

 *  @param central              The central manager providing this update.//param中央中央管理器提供此更新。

 *  @param peripheral           A <code>CBPeripheral</code> object.//param外圍<代碼> CBPeripheral > < /代碼對象。

 *  @param advertisementData    A dictionary containing any advertisement and scan response data.//param廣告數據字典包含任何廣告和掃描響應數據。

 *  @param RSSI                 The current RSSI of <i>peripheral</i>, in dBm. A value of <code>127</code> is reserved and indicates the RSSI//param RSSI的當前RSSI <我> < / i >外圍,dBm。值<代碼> 127 > < /代碼保留和RSSI表示

 * was not available.//沒有可用的。

 *

 *  @discussion                 This method is invoked while scanning, upon the discovery of <i>peripheral</i> by <i>central</i>. A discovered peripheral must//討論這個方法被調用時掃描,發現<我> < / i >外圍的<我> < / i >中部。發現外圍必須

 *                              be retained in order to use it; otherwise, it is assumed to not be of interest and will be cleaned up by the central manager. //被保留,為了使用它;否則,它假定不感興趣的,將由中央管理器清理。For

 *                              a list of <i>advertisementData</i> keys, see {@link CBAdvertisementDataLocalNameKey} and other similar constants.//<我>廣告列表數據< / i >鍵,看到CB廣告數據本地名稱鍵} { @聯系和其他類似的常數。

 *

 *  @seealso                    CBAdvertisementData.h//參見CBAdvertisementData.h

 *

 */

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *, id> *)advertisementData RSSI:(NSNumber *)RSSI;

 

/*!

 *  @method centralManager:didConnectPeripheral://中央管理器方法:連接周邊:

 *

 *  @param central      The central manager providing this information.//param中央中央管理器提供這些信息。

 *  @param peripheral   The <code>CBPeripheral</code> that has connected.//param外圍<代碼> CB外圍連接> < /代碼。

 *

 *  @discussion         This method is invoked when a connection initiated by {@link connectPeripheral:options:} has succeeded.//討論時調用此方法連接由{ @鏈接連接外圍:選項:}已經成功了。

 *

 */

- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral;

 

/*!

 *  @method centralManager:didFailToConnectPeripheral:error://方法中央管理器:外圍連接失敗:錯誤:

 *

 *  @param central      The central manager providing this information.param中央中央管理器提供這些信息。

 *  @param peripheral   The <code>CBPeripheral</code> that has failed to connect.//param外圍<代碼> CB外圍> < /代碼,連接失敗。

 *  @param error        The cause of the failure.//參數錯誤失敗的原因。

 *

 *  @discussion         This method is invoked when a connection initiated by {@link connectPeripheral:options:} has failed to complete. As connection attempts do not//討論時調用此方法連接由{ @鏈接連接外圍:選項:}未能完成。作為連接嘗試

 *                      timeout, the failure of a connection is atypical and usually indicative of a transient issue.//超時、失敗的典型連接,通常表明一個瞬態問題。

 *

 */

- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error;

 

/*!

 *  @method centralManager:didDisconnectPeripheral:error://中央管理器方法:斷開外圍:錯誤:

 *

 *  @param central      The central manager providing this information.//param中央中央管理器提供這些信息。

 *  @param peripheral   The <code>CBPeripheral</code> that has disconnected.//param外圍<代碼> CB外圍> < /代碼已經斷開連接

 *  @param error        If an error occurred, the cause of the failure.//參數錯誤,如果一個錯誤發生,失敗的原因。

 *

 *  @discussion         This method is invoked upon the disconnection of a peripheral that was connected by {@link connectPeripheral:options:}. If the disconnection

 *                      was not initiated by {@link cancelPeripheralConnection}, the cause will be detailed in the <i>error</i> parameter. Once this method has been//討論這個方法被調用的斷開連接的外圍{ @鏈接連接外圍:選項:}。如果斷開

 *                      called, no more methods will be invoked on <i>peripheral</i>'s <code>CBPeripheralDelegate</code>.

 *//叫,沒有更多的方法將被調用<我> < / i >外圍的<代碼> CB外圍委托> < /代碼。

 */

- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error;

 

@end

 

NS_ASSUME_NONNULL_END

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM