Skip to content

Commit

Permalink
Merge pull request #153 from alex-taffe/receive-spelling-fix
Browse files Browse the repository at this point in the history
Fix the spelling of receive
  • Loading branch information
colemancda authored Sep 14, 2024
2 parents 974ee43 + 8fc2a4f commit 004b27a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Sources/Bluetooth/L2CAPSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public protocol L2CAPSocket {
func send(_ data: Data) async throws

/// Reads from the socket.
func recieve(_ bufferSize: Int) async throws -> Data
func receive(_ bufferSize: Int) async throws -> Data

/// Attempt to accept an incoming connection.
func accept() async throws -> Self
Expand Down
26 changes: 13 additions & 13 deletions Sources/BluetoothGATT/ATTConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,35 @@ internal actor ATTConnection {

let bytesToRead = Int(self.maximumTransmissionUnit.rawValue)

let recievedData = try await socket.recieve(bytesToRead)
let receivedData = try await socket.receive(bytesToRead)

//log?("Recieved data (\(recievedData.count) bytes)")
//log?("Received data (\(receivedData.count) bytes)")

// valid PDU data length
guard recievedData.count >= 1 // at least 1 byte for ATT opcode
else { throw ATTConnectionError.garbageResponse(recievedData) }
guard receivedData.count >= 1 // at least 1 byte for ATT opcode
else { throw ATTConnectionError.garbageResponse(receivedData) }

let opcodeByte = recievedData[0]
let opcodeByte = receivedData[0]

// valid opcode
guard let opcode = ATTOpcode(rawValue: opcodeByte)
else { throw ATTConnectionError.garbageResponse(recievedData) }
else { throw ATTConnectionError.garbageResponse(receivedData) }

//log?("Recieved opcode \(opcode)")
//log?("Received opcode \(opcode)")

// Act on the received PDU based on the opcode type
switch opcode.type {
case .response:
try await handle(response: recievedData, opcode: opcode)
try await handle(response: receivedData, opcode: opcode)
case .confirmation:
try handle(confirmation: recievedData, opcode: opcode)
try handle(confirmation: receivedData, opcode: opcode)
case .request:
try await handle(request: recievedData, opcode: opcode)
try await handle(request: receivedData, opcode: opcode)
case .command,
.notification,
.indication:
// For all other opcodes notify the upper layer of the PDU and let them act on it.
try await handle(notify: recievedData, opcode: opcode)
try await handle(notify: receivedData, opcode: opcode)
}
}

Expand Down Expand Up @@ -330,7 +330,7 @@ internal actor ATTConnection {
// clear current pending request
defer { self.pendingRequest = nil }

/// Verify the recieved response belongs to the pending request
/// Verify the received response belongs to the pending request
guard sendOperation.opcode == requestOpcode else {
throw ATTConnectionError.unexpectedResponse(data)
}
Expand Down Expand Up @@ -507,7 +507,7 @@ internal actor ATTConnection {
/// ATT Connection Error
public enum ATTConnectionError: Error {

/// The recieved data could not be parsed correctly.
/// The received data could not be parsed correctly.
case garbageResponse(Data)

/// Response is unexpected.
Expand Down
6 changes: 3 additions & 3 deletions Sources/BluetoothGATT/GATTClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ public actor GATTClient {
inLongWrite = false
throw GATTClientError.errorResponse(errorResponse)
case let .success(pdu):
// append recieved data
// append received data
operation.receivedData += pdu.partValue

// verify data sent
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public actor GATTClient {

private func notification(_ notification: ATTHandleValueNotification) {
guard let handler = notifications[notification.handle] else {
log?("Recieved notification for unregistered handle \(notification.handle)")
log?("Received notification for unregistered handle \(notification.handle)")
return
}
// callback
Expand All @@ -1061,7 +1061,7 @@ public actor GATTClient {
await send(confirmation)
// callback
guard let handler = indications[indication.handle] else {
log?("Recieved indication for unregistered handle \(indication.handle)")
log?("Received indication for unregistered handle \(indication.handle)")
return
}
handler(indication.value)
Expand Down
4 changes: 2 additions & 2 deletions Sources/BluetoothHCI/BluetoothHostController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public protocol BluetoothHostControllerInterface: AnyObject {
func deviceRequest <CP: HCICommandParameter, Return: HCICommandReturnParameter> (_ commandParameter: CP, _ commandReturnType: Return.Type, timeout: HCICommandTimeout) async throws -> Return

/// Polls and waits for events.
func recieve<Event>(_ eventType: Event.Type) async throws -> Event where Event: HCIEventParameter, Event.HCIEventType == HCIGeneralEvent
func receive<Event>(_ eventType: Event.Type) async throws -> Event where Event: HCIEventParameter, Event.HCIEventType == HCIGeneralEvent
}

/// Bluetooth HCI errors
Expand All @@ -56,7 +56,7 @@ public enum BluetoothHostControllerError: Error {
/// The second error is the error while trying to restore the filter.
case couldNotRestoreFilter(Error, Error)

/// The recieved data could not be parsed correctly.
/// The received data could not be parsed correctly.
case garbageResponse(Data)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/BluetoothHCI/HCILESetScanEnable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public extension BluetoothHostControllerInterface {
// poll for scanned devices
while Task.isCancelled == false {

let metaEvent = try await self.recieve(HCILowEnergyMetaEvent.self)
let metaEvent = try await self.receive(HCILowEnergyMetaEvent.self)

// only want advertising report
guard metaEvent.subevent == .advertisingReport
Expand Down
12 changes: 6 additions & 6 deletions Tests/BluetoothTests/GATTTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -936,15 +936,15 @@ final class GATTTests: XCTestCase {
XCTAssert(descriptors.isEmpty == false, "No descriptors found")

// notifications
var recievedNotifications = [Data]()
var recievedIndications = [Data]()
var receivedNotifications = [Data]()
var receivedIndications = [Data]()

func notification(_ data: Data) {
recievedNotifications.append(data)
receivedNotifications.append(data)
}

func indication(_ data: Data) {
recievedIndications.append(data)
receivedIndications.append(data)
}

try await client.clientCharacteristicConfiguration(
Expand All @@ -971,10 +971,10 @@ final class GATTTests: XCTestCase {
let maxLength = 20 //MTU-3
let expectedNotificationValues = newData.map { Data($0.prefix(maxLength)) }
if notificationCharacteristic.properties.contains(.notify) {
XCTAssertEqual(recievedNotifications, expectedNotificationValues)
XCTAssertEqual(receivedNotifications, expectedNotificationValues)
}
if notificationCharacteristic.properties.contains(.indicate) {
XCTAssertEqual(recievedIndications, expectedNotificationValues)
XCTAssertEqual(receivedIndications, expectedNotificationValues)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/BluetoothTests/L2CAPSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ internal actor TestL2CAPSocket: L2CAPSocket {
}

/// Reads from the socket.
func recieve(_ bufferSize: Int) async throws -> Data {
func receive(_ bufferSize: Int) async throws -> Data {

print("L2CAP Socket: \(name) will read \(bufferSize) bytes")

Expand All @@ -155,7 +155,7 @@ internal actor TestL2CAPSocket: L2CAPSocket {

fileprivate func receive(_ data: Data) {
receivedData.append(data)
print("L2CAP Socket: \(name) recieved \([UInt8](data))")
print("L2CAP Socket: \(name) received \([UInt8](data))")
eventContinuation.yield(.read)
}

Expand Down

0 comments on commit 004b27a

Please sign in to comment.