Package apple.corebluetooth
Class CBPeripheralManager
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.corebluetooth.CBManager
-
- apple.corebluetooth.CBPeripheralManager
-
- All Implemented Interfaces:
NSObject
public class CBPeripheralManager extends CBManager
CBPeripheralManager TheCBPeripheralManagerclass is an abstraction of the Peripheral and Broadcaster GAP roles, and the GATT Server role. Its primary function is to allow you to manage published services within the GATT database, and to advertise these services to other devices. Each application has sandboxed access to the shared GATT database. You can add services to the database by calling {@link addService:}; they can be removed via {@link removeService:} andremoveAllServices(), as appropriate. While a service is in the database, it is visible to and can be accessed by any connected GATT Client. However, applications that have not specified the "bluetooth-peripheral" background mode will have the contents of their service(s) "disabled" when in the background. Any remote device trying to access characteristic values or descriptors during this time will receive an error response. Once you've published services that you want to share, you can ask to advertise their availability and allow other devices to connect to you by calling {@link startAdvertising:}. Like the GATT database, advertisement is managed at the system level and shared by all applications. This means that even if you aren't advertising at the moment, someone else might be!
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class apple.NSObject
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCBPeripheralManager(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanaccessInstanceVariablesDirectly()voidaddService(CBMutableService service)addService: Publishes a service and its associated characteristic(s) to the local database.static CBPeripheralManageralloc()static java.lang.ObjectallocWithZone(org.moe.natj.general.ptr.VoidPtr zone)static longauthorization_static()static longauthorizationStatus()authorizationStatus This method does not prompt the user for access.static booleanautomaticallyNotifiesObserversForKey(java.lang.String key)static voidcancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)static voidcancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)static NSArray<java.lang.String>classFallbacksForKeyedArchiver()static org.moe.natj.objc.ClassclassForKeyedUnarchiver()static java.lang.StringdebugDescription_static()CBPeripheralManagerDelegatedelegate()[@property] delegate The delegate object that will receive peripheral events.static java.lang.Stringdescription_static()static longhash_static()CBPeripheralManagerinit()CBPeripheralManagerinitWithDelegateQueue(CBPeripheralManagerDelegate delegate, NSObject queue)initWithDelegate:queue: The initialization call.CBPeripheralManagerinitWithDelegateQueueOptions(CBPeripheralManagerDelegate delegate, NSObject queue, NSDictionary<java.lang.String,?> options)initWithDelegate:queue:options: The initialization call.static NSObject.Function_instanceMethodForSelector_retinstanceMethodForSelector(org.moe.natj.objc.SEL aSelector)static NSMethodSignatureinstanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)static booleaninstancesRespondToSelector(org.moe.natj.objc.SEL aSelector)booleanisAdvertising()[@property] isAdvertising Whether or not the peripheral is currently advertising data.static booleanisSubclassOfClass(org.moe.natj.objc.Class aClass)static NSSet<java.lang.String>keyPathsForValuesAffectingValueForKey(java.lang.String key)static java.lang.Objectnew_objc()voidpublishL2CAPChannelWithEncryption(boolean encryptionRequired)publishL2CAPChannelWithEncryption: Create a listener for incoming L2CAP Channel connections.voidremoveAllServices()removeAllServices Removes all published services from the local database.voidremoveService(CBMutableService service)removeService: Removes a published service from the local database.static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)voidrespondToRequestWithResult(CBATTRequest request, long result)respondToRequest:withResult: Used to respond to request(s) received via the @link peripheralManager:didReceiveReadRequest: @/link or [@link] peripheralManager:didReceiveWriteRequests: @/link delegate methods.voidsetDelegate(CBPeripheralManagerDelegate value)[@property] delegate The delegate object that will receive peripheral events.voidsetDelegate_unsafe(CBPeripheralManagerDelegate value)[@property] delegate The delegate object that will receive peripheral events.voidsetDesiredConnectionLatencyForCentral(long latency, CBCentral central)setDesiredConnectionLatency:forCentral: Sets the desired connection latency for an existing connection to central.static voidsetVersion_static(long aVersion)voidstartAdvertising(NSDictionary<java.lang.String,?> advertisementData)startAdvertising: Starts advertising.voidstopAdvertising()stopAdvertising Stops advertising.static org.moe.natj.objc.Classsuperclass_static()voidunpublishL2CAPChannel(char PSM)unpublishL2CAPChannel: Removes a published service from the local system.booleanupdateValueForCharacteristicOnSubscribedCentrals(NSData value, CBMutableCharacteristic characteristic, NSArray<? extends CBCentral> centrals)updateValue:forCharacteristic:onSubscribedCentrals: Sends an updated characteristic value to one or more centrals, via a notification or indication.static longversion_static()-
Methods inherited from class apple.corebluetooth.CBManager
authorization, state
-
Methods inherited from class apple.NSObject
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKey
-
-
-
-
Method Detail
-
accessInstanceVariablesDirectly
public static boolean accessInstanceVariablesDirectly()
-
alloc
public static CBPeripheralManager alloc()
-
allocWithZone
public static java.lang.Object allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
-
authorizationStatus
public static long authorizationStatus()
authorizationStatus This method does not prompt the user for access. You can use it to detect restricted access and simply hide UI instead of prompting for access.- Returns:
- The current authorization status for sharing data while backgrounded. For the constants returned, see
CBPeripheralManagerAuthorizationStatus. - See Also:
CBPeripheralManagerAuthorizationStatus
-
automaticallyNotifiesObserversForKey
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
-
cancelPreviousPerformRequestsWithTarget
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
-
cancelPreviousPerformRequestsWithTargetSelectorObject
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)
-
classFallbacksForKeyedArchiver
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
-
classForKeyedUnarchiver
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
hash_static
public static long hash_static()
-
instanceMethodForSelector
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
-
instanceMethodSignatureForSelector
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
-
instancesRespondToSelector
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
-
isSubclassOfClass
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
-
keyPathsForValuesAffectingValueForKey
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
-
new_objc
public static java.lang.Object new_objc()
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
setVersion_static
public static void setVersion_static(long aVersion)
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
version_static
public static long version_static()
-
addService
public void addService(CBMutableService service)
addService: Publishes a service and its associated characteristic(s) to the local database. If the service contains included services, they must be published first.- Parameters:
service- A GATT service.
-
delegate
public CBPeripheralManagerDelegate delegate()
[@property] delegate The delegate object that will receive peripheral events.
-
init
public CBPeripheralManager init()
-
initWithDelegateQueue
public CBPeripheralManager initWithDelegateQueue(CBPeripheralManagerDelegate delegate, NSObject queue)
initWithDelegate:queue: The initialization call. The events of the peripheral role will be dispatched on the provided queue. If nil, the main queue will be used.- Parameters:
delegate- The delegate that will receive peripheral role events.queue- The dispatch queue on which the events will be dispatched.
-
initWithDelegateQueueOptions
public CBPeripheralManager initWithDelegateQueueOptions(CBPeripheralManagerDelegate delegate, NSObject queue, NSDictionary<java.lang.String,?> options)
initWithDelegate:queue:options: The initialization call. The events of the peripheral role will be dispatched on the provided queue. If nil, the main queue will be used.- Parameters:
delegate- The delegate that will receive peripheral role events.queue- The dispatch queue on which the events will be dispatched.options- An optional dictionary specifying options for the manager.- See Also:
CBPeripheralManagerOptionShowPowerAlertKey,CBPeripheralManagerOptionRestoreIdentifierKey
-
isAdvertising
public boolean isAdvertising()
[@property] isAdvertising Whether or not the peripheral is currently advertising data.
-
removeAllServices
public void removeAllServices()
removeAllServices Removes all published services from the local database.
-
removeService
public void removeService(CBMutableService service)
removeService: Removes a published service from the local database. If the service is included by other service(s), they must be removed first.- Parameters:
service- A GATT service.
-
respondToRequestWithResult
public void respondToRequestWithResult(CBATTRequest request, long result)
respondToRequest:withResult: Used to respond to request(s) received via the @link peripheralManager:didReceiveReadRequest: @/link or [@link] peripheralManager:didReceiveWriteRequests: @/link delegate methods.- Parameters:
request- The original request that was received from the central.result- The result of attempting to fulfill request.
-
setDelegate_unsafe
public void setDelegate_unsafe(CBPeripheralManagerDelegate value)
[@property] delegate The delegate object that will receive peripheral events.
-
setDelegate
public void setDelegate(CBPeripheralManagerDelegate value)
[@property] delegate The delegate object that will receive peripheral events.
-
setDesiredConnectionLatencyForCentral
public void setDesiredConnectionLatencyForCentral(long latency, CBCentral central)setDesiredConnectionLatency:forCentral: Sets the desired connection latency for an existing connection to central. Connection latency changes are not guaranteed, so the resultant latency may vary. If a desired latency is not set, the latency chosen by central at the time of connection establishment will be used. Typically, it is not necessary to change the latency.- Parameters:
latency- The desired connection latency.central- A connected central.- See Also:
CBPeripheralManagerConnectionLatency
-
startAdvertising
public void startAdvertising(NSDictionary<java.lang.String,?> advertisementData)
startAdvertising: Starts advertising. Supported advertising data types areCBAdvertisementDataLocalNameKeyandCBAdvertisementDataServiceUUIDsKey. When in the foreground, an application can utilize up to 28 bytes of space in the initial advertisement data for any combination of the supported advertising data types. If this space is used up, there are an additional 10 bytes of space in the scan response that can be used only for the local name. Note that these sizes do not include the 2 bytes of header information that are required for each new data type. Any service UUIDs that do not fit in the allotted space will be added to a special "overflow" area, and can only be discovered by an iOS device that is explicitly scanning for them. While an application is in the background, the local name will not be used and all service UUIDs will be placed in the "overflow" area. However, applications that have not specified the "bluetooth-peripheral" background mode will not be able to advertise anything while in the background.- Parameters:
advertisementData- An optional dictionary containing the data to be advertised.- See Also:
CBAdvertisementData.h
-
stopAdvertising
public void stopAdvertising()
stopAdvertising Stops advertising.
-
updateValueForCharacteristicOnSubscribedCentrals
public boolean updateValueForCharacteristicOnSubscribedCentrals(NSData value, CBMutableCharacteristic characteristic, NSArray<? extends CBCentral> centrals)
updateValue:forCharacteristic:onSubscribedCentrals: Sends an updated characteristic value to one or more centrals, via a notification or indication. If value exceedsmaximumUpdateValueLength, it will be truncated to fit.- Parameters:
value- The value to be sent via a notification/indication.characteristic- The characteristic whose value has changed.centrals- A list ofCBCentralobjects to receive the update. Note that centrals which have not subscribed to characteristic will be ignored. If nil, all centrals that are subscribed to characteristic will be updated.- Returns:
- YES if the update could be sent, or NO if the underlying transmit queue is full. If NO was returned, the delegate method @link peripheralManagerIsReadyToUpdateSubscribers: @/link will be called once space has become available, and the update should be re-sent if so desired.
- See Also:
maximumUpdateValueLength
-
publishL2CAPChannelWithEncryption
public void publishL2CAPChannelWithEncryption(boolean encryptionRequired)
publishL2CAPChannelWithEncryption: Create a listener for incoming L2CAP Channel connections. The system will determine an unused PSM at the time of publishing, which will be returned with @link peripheralManager:didPublishL2CAPChannel:error: @/link. L2CAP Channels are not discoverable by themselves, so it is the application's responsibility to handle PSM discovery on the client.- Parameters:
encryptionRequired- YES if the service requires the link to be encrypted before a stream can be established. NO if the service can be used over an unsecured link.
-
unpublishL2CAPChannel
public void unpublishL2CAPChannel(char PSM)
unpublishL2CAPChannel: Removes a published service from the local system. No new connections for this PSM will be accepted, and any existing L2CAP channels using this PSM will be closed.- Parameters:
PSM- The service PSM to be removed from the system.
-
authorization_static
public static long authorization_static()
-
-