feat: add BLE peripheral mode (advertising + GATT server)#18
Open
alachhman wants to merge 3 commits into
Open
Conversation
- Add GATTCharacteristicProperty, GATTCharacteristicPermission enums - Add GATTCharacteristicConfig, ReadRequestCallback, WriteRequestCallback types - Add 14 peripheral methods to NativeBleNitro interface - Add JS wrapper methods to BleNitroManager (advertising, GATT, requests) - Add 11 new unit tests for peripheral mode - Export new types from package index Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
iOS: - CBPeripheralManager with BleGattServerDelegate - GATT service/characteristic construction from config - Read request handling with 60s native value cache - Write request forwarding to JS callbacks - Central subscription tracking for notifications - Background advertising support via state restoration Android: - BluetoothLeAdvertiser with LOW_POWER mode - BluetoothGattServer with full callback handling - Read request cache (60s TTL) with JS fallback - Write request forwarding with ArrayBuffer wrapping - CCCD descriptor management for notify/indicate - Lazy GATT server initialization Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CBPeripheralManagerwith delegate, GATT service/characteristic management, 60s native value cache for background resilienceBluetoothLeAdvertiser+BluetoothGattServerwith full callback handling, CCCD descriptor managementBleNitroManagerwrapper methods withByteArrayconversionAPI Added
startAdvertising(serviceUUIDs, localName)/stopAdvertising()/isAdvertising()addService(uuid, isPrimary, characteristics)/removeService(uuid)/removeAllServices()updateCharacteristicValue(serviceUUID, charUUID, data)— native-side 60s cacheonReadRequest(callback)/onWriteRequest(callback)— JS callbacks for dynamic characteristicsrespondToRequest(requestId, status, offset, data)— async response to pending requestsnotifyCharacteristic(serviceUUID, charUUID, data)— push to subscribed centralsperipheralState()/subscribeToPeripheralStateChange(callback)New Types
GATTCharacteristicPropertyenum (Read, Write, WriteWithoutResponse, Notify, Indicate)GATTCharacteristicPermissionenum (Readable, Writeable)GATTCharacteristicConfiginterfaceReadRequestCallback/WriteRequestCallbacktypesDesign Notes
value: nulltriggeronReadRequestJS callback (dynamic values)ADVERTISE_MODE_LOW_POWERdefault;BLUETOOTH_ADVERTISEpermission via existingandroidAdvertisingEnabledconfig flagTest Plan
🤖 Generated with Claude Code