Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Update()
}
}

public void DidUpdateState(CBCentralManager central)
void ICBCentralManagerDelegate.DidUpdateState(CBCentralManager central)
{
if (central.State == CBManagerState.PoweredOn)
{
Expand All @@ -48,7 +48,7 @@ public void DidUpdateState(CBCentralManager central)
}
}

public void DidDiscoverPeripheral(CBCentralManager central, CBPeripheral peripheral, int rssi)
void ICBCentralManagerDelegate.DidDiscoverPeripheral(CBCentralManager central, CBPeripheral peripheral, int rssi)
{
_header.SetStateText("Connecting...");
_peripheral = peripheral;
Expand All @@ -57,27 +57,27 @@ public void DidDiscoverPeripheral(CBCentralManager central, CBPeripheral periphe
central.Connect(peripheral);
}

public void DidConnectPeripheral(CBCentralManager central, CBPeripheral peripheral)
void ICBCentralManagerDelegate.DidConnectPeripheral(CBCentralManager central, CBPeripheral peripheral)
{
_header.SetStateText("Connected");
peripheral.DiscoverServices(new string[] { SampleLightControl_Data.ServiceUUID });
}

public void DidFailToConnectPeripheral(CBCentralManager central, CBPeripheral peripheral, CBError error)
void ICBCentralManagerDelegate.DidFailToConnectPeripheral(CBCentralManager central, CBPeripheral peripheral, CBError error)
{
_header.SetStateText("Scanning...");
_lightControlCharacteristic = null;
central.ScanForPeripherals(new string[] { SampleLightControl_Data.ServiceUUID });
}

public void DidDisconnectPeripheral(CBCentralManager central, CBPeripheral peripheral, CBError error)
void ICBCentralManagerDelegate.DidDisconnectPeripheral(CBCentralManager central, CBPeripheral peripheral, CBError error)
{
_header.SetStateText("Scanning...");
_lightControlCharacteristic = null;
central.ScanForPeripherals(new string[] { SampleLightControl_Data.ServiceUUID });
}

public void DidDiscoverServices(CBPeripheral peripheral, CBError error)
void ICBPeripheralDelegate.DidDiscoverServices(CBPeripheral peripheral, CBError error)
{
if (error != null)
{
Expand All @@ -91,7 +91,7 @@ public void DidDiscoverServices(CBPeripheral peripheral, CBError error)
}
}

public void DidDiscoverCharacteristics(CBPeripheral peripheral, CBService service, CBError error)
void ICBPeripheralDelegate.DidDiscoverCharacteristics(CBPeripheral peripheral, CBService service, CBError error)
{
if (error != null)
{
Expand All @@ -110,7 +110,7 @@ public void DidDiscoverCharacteristics(CBPeripheral peripheral, CBService servic
}
}

public void DidWriteValueForCharacteristic(CBPeripheral peripheral, CBCharacteristic characteristic, CBError error)
void ICBPeripheralDelegate.DidWriteValueForCharacteristic(CBPeripheral peripheral, CBCharacteristic characteristic, CBError error)
{
if (error != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void StartAdvertising()
_peripheralManager.StartAdvertising(options);
}

public void DidUpdateState(CBPeripheralManager peripheral)
void ICBPeripheralManagerDelegate.DidUpdateState(CBPeripheralManager peripheral)
{
if (peripheral.State == CBManagerState.PoweredOn)
{
Expand All @@ -56,7 +56,7 @@ public void DidUpdateState(CBPeripheralManager peripheral)
}
}

public void DidAddService(CBPeripheralManager peripheral, CBService service, CBError error)
void ICBPeripheralManagerDelegate.DidAddService(CBPeripheralManager peripheral, CBService service, CBError error)
{
if (error != null)
{
Expand All @@ -67,7 +67,7 @@ public void DidAddService(CBPeripheralManager peripheral, CBService service, CBE
StartAdvertising();
}

public void DidStartAdvertising(CBPeripheralManager peripheral, CBError error)
void ICBPeripheralManagerDelegate.DidStartAdvertising(CBPeripheralManager peripheral, CBError error)
{
if (error != null)
{
Expand All @@ -78,7 +78,7 @@ public void DidStartAdvertising(CBPeripheralManager peripheral, CBError error)
_header.SetStateText("Advertising...");
}

public void DidReceiveWriteRequests(CBPeripheralManager peripheral, CBATTRequest[] requests)
void ICBPeripheralManagerDelegate.DidReceiveWriteRequests(CBPeripheralManager peripheral, CBATTRequest[] requests)
{
var firstRequest = requests[0];
foreach (var request in requests)
Expand Down
44 changes: 22 additions & 22 deletions Assets/CoreBluetooth/Samples/12_Debug/SampleDebug_Central.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@ void Start()
_centralManager = new CBCentralManager(this, initOptions);
}

public void DidDiscoverPeripheral(CBCentralManager central, CBPeripheral peripheral, int rssi)
{
Debug.Log($"[DidDiscoverPeripheral] peripheral: {peripheral} rssi: {rssi}");
_peripheral = peripheral;
peripheral.Delegate = this;
central.StopScan();
central.Connect(peripheral);
}

public void DidUpdateState(CBCentralManager central)
void ICBCentralManagerDelegate.DidUpdateState(CBCentralManager central)
{
Debug.Log($"[DidUpdateState] {central.State}");
if (central.State == CBManagerState.PoweredOn)
Expand All @@ -41,24 +32,33 @@ public void DidUpdateState(CBCentralManager central)
}
}

public void DidConnectPeripheral(CBCentralManager central, CBPeripheral peripheral)
void ICBCentralManagerDelegate.DidDiscoverPeripheral(CBCentralManager central, CBPeripheral peripheral, int rssi)
{
Debug.Log($"[DidDiscoverPeripheral] peripheral: {peripheral} rssi: {rssi}");
_peripheral = peripheral;
peripheral.Delegate = this;
central.StopScan();
central.Connect(peripheral);
}

void ICBCentralManagerDelegate.DidConnectPeripheral(CBCentralManager central, CBPeripheral peripheral)
{
Debug.Log($"[DidConnectPeripheral] peripheral: {peripheral}");
Debug.Log($"[DidConnectPeripheral] mtu: {peripheral.GetMaximumWriteValueLength(CBCharacteristicWriteType.WithResponse)}");
peripheral.DiscoverServices(new string[] { _serviceUUID });
}

public void DidDisconnectPeripheral(CBCentralManager central, CBPeripheral peripheral, CBError error)
void ICBCentralManagerDelegate.DidDisconnectPeripheral(CBCentralManager central, CBPeripheral peripheral, CBError error)
{
Debug.Log($"[DidDisconnectPeripheral] peripheral: {peripheral} error: {error}");
}

public void DidFailToConnectPeripheral(CBCentralManager central, CBPeripheral peripheral, CBError error)
void ICBCentralManagerDelegate.DidFailToConnectPeripheral(CBCentralManager central, CBPeripheral peripheral, CBError error)
{
Debug.Log($"[DidFailToConnectPeripheral] peripheral: {peripheral} error: {error}");
}

public void DidDiscoverServices(CBPeripheral peripheral, CBError error)
void ICBPeripheralDelegate.DidDiscoverServices(CBPeripheral peripheral, CBError error)
{
Debug.Log($"[DidDiscoverServices] peripheral: {peripheral}");
if (error != null)
Expand All @@ -74,7 +74,7 @@ public void DidDiscoverServices(CBPeripheral peripheral, CBError error)
}
}

public void DidDiscoverCharacteristics(CBPeripheral peripheral, CBService service, CBError error)
void ICBPeripheralDelegate.DidDiscoverCharacteristics(CBPeripheral peripheral, CBService service, CBError error)
{
Debug.Log($"[DidDiscoverCharacteristics] peripheral: {peripheral} service: {service}");
if (error != null)
Expand Down Expand Up @@ -104,7 +104,7 @@ public void DidDiscoverCharacteristics(CBPeripheral peripheral, CBService servic
}
}

public void DidUpdateValueForCharacteristic(CBPeripheral peripheral, CBCharacteristic characteristic, CBError error)
void ICBPeripheralDelegate.DidUpdateValueForCharacteristic(CBPeripheral peripheral, CBCharacteristic characteristic, CBError error)
{
Debug.Log($"[DidUpdateValueForCharacteristic] characteristic: {characteristic}");
if (error != null)
Expand All @@ -117,7 +117,7 @@ public void DidUpdateValueForCharacteristic(CBPeripheral peripheral, CBCharacter
Debug.Log($"Data: {str}");
}

public void DidWriteValueForCharacteristic(CBPeripheral peripheral, CBCharacteristic characteristic, CBError error)
void ICBPeripheralDelegate.DidWriteValueForCharacteristic(CBPeripheral peripheral, CBCharacteristic characteristic, CBError error)
{
Debug.Log($"[DidWriteValueForCharacteristic] characteristic: {characteristic}");
if (error != null)
Expand All @@ -127,12 +127,12 @@ public void DidWriteValueForCharacteristic(CBPeripheral peripheral, CBCharacteri
}
}

public void IsReadyToSendWriteWithoutResponse(CBPeripheral peripheral)
void ICBPeripheralDelegate.IsReadyToSendWriteWithoutResponse(CBPeripheral peripheral)
{
Debug.Log($"[IsReadyToSendWriteWithoutResponse] {peripheral}");
}

public void DidUpdateNotificationStateForCharacteristic(CBPeripheral peripheral, CBCharacteristic characteristic, CBError error)
void ICBPeripheralDelegate.DidUpdateNotificationStateForCharacteristic(CBPeripheral peripheral, CBCharacteristic characteristic, CBError error)
{
Debug.Log($"[DidUpdateNotificationStateForCharacteristic] characteristic: {characteristic}");
if (error != null)
Expand All @@ -142,7 +142,7 @@ public void DidUpdateNotificationStateForCharacteristic(CBPeripheral peripheral,
}
}

public void DidReadRSSI(CBPeripheral peripheral, int rssi, CBError error)
void ICBPeripheralDelegate.DidReadRSSI(CBPeripheral peripheral, int rssi, CBError error)
{
Debug.Log($"[DidReadRSSI] rssi: {rssi}");
if (error != null)
Expand All @@ -152,12 +152,12 @@ public void DidReadRSSI(CBPeripheral peripheral, int rssi, CBError error)
}
}

public void DidUpdateName(CBPeripheral peripheral)
void ICBPeripheralDelegate.DidUpdateName(CBPeripheral peripheral)
{
Debug.Log($"[DidUpdateName] {peripheral}");
}

public void DidModifyServices(CBPeripheral peripheral, CBService[] services)
void ICBPeripheralDelegate.DidModifyServices(CBPeripheral peripheral, CBService[] services)
{
var serviceIds = services.Select(s => s.UUID.ToString()).ToArray();
Debug.Log($"[DidModifyServices] services count: {services.Length} serviceIds: {string.Join(", ", serviceIds)}");
Expand Down
16 changes: 8 additions & 8 deletions Assets/CoreBluetooth/Samples/12_Debug/SampleDebug_Peripheral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void Start()
_disposables.Add(_peripheralManager);
}

public void DidUpdateState(CBPeripheralManager peripheral)
void ICBPeripheralManagerDelegate.DidUpdateState(CBPeripheralManager peripheral)
{
Debug.Log($"[DidUpdateState] {peripheral.State}");
if (peripheral.State == CBManagerState.PoweredOn)
Expand All @@ -44,7 +44,7 @@ public void DidUpdateState(CBPeripheralManager peripheral)
}
}

public void DidAddService(CBPeripheralManager peripheral, CBService service, CBError error)
void ICBPeripheralManagerDelegate.DidAddService(CBPeripheralManager peripheral, CBService service, CBError error)
{
Debug.Log($"[DidAddService] peripheral: {peripheral} service: {service} error: {error}");
if (error == null)
Expand All @@ -58,29 +58,29 @@ public void DidAddService(CBPeripheralManager peripheral, CBService service, CBE
}
}

public void DidStartAdvertising(CBPeripheralManager peripheral, CBError error)
void ICBPeripheralManagerDelegate.DidStartAdvertising(CBPeripheralManager peripheral, CBError error)
{
Debug.Log($"[DidStartAdvertising] peripheral: {peripheral} error: {error}");
}

public void DidSubscribeToCharacteristic(CBPeripheralManager peripheral, CBCentral central, CBCharacteristic characteristic)
void ICBPeripheralManagerDelegate.DidSubscribeToCharacteristic(CBPeripheralManager peripheral, CBCentral central, CBCharacteristic characteristic)
{
Debug.Log($"[DidSubscribeToCharacteristic] peripheral: {peripheral} central: {central} characteristic: {characteristic}");
_central = central;
}

public void DidUnsubscribeFromCharacteristic(CBPeripheralManager peripheral, CBCentral central, CBCharacteristic characteristic)
void ICBPeripheralManagerDelegate.DidUnsubscribeFromCharacteristic(CBPeripheralManager peripheral, CBCentral central, CBCharacteristic characteristic)
{
Debug.Log($"[DidUnsubscribeFromCharacteristic] peripheral: {peripheral} central: {central} characteristic: {characteristic}");
_central = null;
}

public void IsReadyToUpdateSubscribers(CBPeripheralManager peripheral)
void ICBPeripheralManagerDelegate.IsReadyToUpdateSubscribers(CBPeripheralManager peripheral)
{
Debug.Log($"[IsReadyToUpdateSubscribers] {peripheral}");
}

public void DidReceiveReadRequest(CBPeripheralManager peripheral, CBATTRequest request)
void ICBPeripheralManagerDelegate.DidReceiveReadRequest(CBPeripheralManager peripheral, CBATTRequest request)
{
if (request.Characteristic.UUID != _characteristicUUID)
{
Expand All @@ -100,7 +100,7 @@ public void DidReceiveReadRequest(CBPeripheralManager peripheral, CBATTRequest r
Debug.Log($"[DidReceiveReadRequest] {System.Text.Encoding.UTF8.GetString(request.Value)}");
}

public void DidReceiveWriteRequests(CBPeripheralManager peripheral, CBATTRequest[] requests)
void ICBPeripheralManagerDelegate.DidReceiveWriteRequests(CBPeripheralManager peripheral, CBATTRequest[] requests)
{
var firstRequest = requests[0];
foreach (var request in requests)
Expand Down