public class CBPeripheralManager extends CBManager
The CBPeripheralManager class 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 addService:;
they can be removed via removeService: and removeAllServices, 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 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!
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
CBPeripheralManager(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
accessInstanceVariablesDirectly() |
void |
addService(CBMutableService service)
addService:
|
static CBPeripheralManager |
alloc() |
static CBPeripheralManager |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static long |
authorization_static() |
static long |
authorizationStatus()
authorizationStatus
|
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(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.Class |
classForKeyedUnarchiver() |
static java.lang.String |
debugDescription_static() |
CBPeripheralManagerDelegate |
delegate()
[@property] delegate
|
static java.lang.String |
description_static() |
static long |
hash_static() |
CBPeripheralManager |
init() |
CBPeripheralManager |
initWithDelegateQueue(CBPeripheralManagerDelegate delegate,
NSObject queue)
initWithDelegate:queue:
|
CBPeripheralManager |
initWithDelegateQueueOptions(CBPeripheralManagerDelegate delegate,
NSObject queue,
NSDictionary<java.lang.String,?> options)
initWithDelegate:queue:options:
|
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
boolean |
isAdvertising()
[@property] isAdvertising
|
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
static CBPeripheralManager |
new_objc() |
void |
publishL2CAPChannelWithEncryption(boolean encryptionRequired)
publishL2CAPChannelWithEncryption:
|
void |
removeAllServices()
removeAllServices
|
void |
removeService(CBMutableService service)
removeService:
|
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
void |
respondToRequestWithResult(CBATTRequest request,
long result)
respondToRequest:withResult:
|
void |
setDelegate_unsafe(CBPeripheralManagerDelegate value)
[@property] delegate
|
void |
setDelegate(CBPeripheralManagerDelegate value)
[@property] delegate
|
void |
setDesiredConnectionLatencyForCentral(long latency,
CBCentral central)
setDesiredConnectionLatency:forCentral:
|
static void |
setVersion_static(long aVersion) |
void |
startAdvertising(NSDictionary<java.lang.String,?> advertisementData)
startAdvertising:
|
void |
stopAdvertising()
stopAdvertising
|
static org.moe.natj.objc.Class |
superclass_static() |
void |
unpublishL2CAPChannel(char PSM)
unpublishL2CAPChannel:
|
boolean |
updateValueForCharacteristicOnSubscribedCentrals(NSData value,
CBMutableCharacteristic characteristic,
NSArray<? extends CBCentral> centrals)
updateValue:forCharacteristic:onSubscribedCentrals:
|
static long |
version_static() |
authorization, stateaccessibilityActivate, 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, willChangeValuesAtIndexesForKeyprotected CBPeripheralManager(org.moe.natj.general.Pointer peer)
public static boolean accessInstanceVariablesDirectly()
public static CBPeripheralManager alloc()
public static CBPeripheralManager allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static long 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.
CBPeripheralManagerAuthorizationStatus.CBPeripheralManagerAuthorizationStatuspublic static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public static long hash_static()
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public static CBPeripheralManager new_objc()
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public static void setVersion_static(long aVersion)
public static org.moe.natj.objc.Class superclass_static()
public static long version_static()
public void addService(CBMutableService service)
Publishes a service and its associated characteristic(s) to the local database. If the service contains included services, they must be published first.
service - A GATT service.peripheralManager:didAddService:error:public CBPeripheralManagerDelegate delegate()
The delegate object that will receive peripheral events.
public CBPeripheralManager init()
public CBPeripheralManager initWithDelegateQueue(CBPeripheralManagerDelegate delegate, NSObject 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.
delegate - The delegate that will receive peripheral role events.queue - The dispatch queue on which the events will be dispatched.public CBPeripheralManager initWithDelegateQueueOptions(CBPeripheralManagerDelegate delegate, NSObject queue, NSDictionary<java.lang.String,?> 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.
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.CBPeripheralManagerOptionShowPowerAlertKey,
CBPeripheralManagerOptionRestoreIdentifierKeypublic boolean isAdvertising()
Whether or not the peripheral is currently advertising data.
public void removeAllServices()
Removes all published services from the local database.
public void removeService(CBMutableService service)
Removes a published service from the local database. If the service is included by other service(s), they must be removed first.
service - A GATT service.public void respondToRequestWithResult(CBATTRequest request, long result)
Used to respond to request(s) received via the @link peripheralManager:didReceiveReadRequest: @/link or [@link] peripheralManager:didReceiveWriteRequests: @/link delegate methods.
request - The original request that was received from the central.result - The result of attempting to fulfill request.peripheralManager:didReceiveReadRequest:,
peripheralManager:didReceiveWriteRequests:public void setDelegate_unsafe(CBPeripheralManagerDelegate value)
The delegate object that will receive peripheral events.
public void setDelegate(CBPeripheralManagerDelegate value)
The delegate object that will receive peripheral events.
public void setDesiredConnectionLatencyForCentral(long latency,
CBCentral central)
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.
latency - The desired connection latency.central - A connected central.CBPeripheralManagerConnectionLatencypublic void startAdvertising(NSDictionary<java.lang.String,?> advertisementData)
Starts advertising. Supported advertising data types are CBAdvertisementDataLocalNameKey
and CBAdvertisementDataServiceUUIDsKey.
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.
advertisementData - An optional dictionary containing the data to be advertised.peripheralManagerDidStartAdvertising:error:,
CBAdvertisementData.hpublic void stopAdvertising()
Stops advertising.
public boolean updateValueForCharacteristicOnSubscribedCentrals(NSData value, CBMutableCharacteristic characteristic, NSArray<? extends CBCentral> centrals)
Sends an updated characteristic value to one or more centrals, via a notification or indication. If value exceeds
maximumUpdateValueLength, it will be truncated to fit.
value - The value to be sent via a notification/indication.characteristic - The characteristic whose value has changed.centrals - A list of CBCentral objects 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.maximumUpdateValueLength,
peripheralManager:central:didSubscribeToCharacteristic:,
peripheralManager:central:didUnsubscribeFromCharacteristic:,
peripheralManagerIsReadyToUpdateSubscribers:public void publishL2CAPChannelWithEncryption(boolean encryptionRequired)
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.
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.public void unpublishL2CAPChannel(char PSM)
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.
PSM - The service PSM to be removed from the system.public static long authorization_static()