Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Apr 26, 2018
1 parent cfd7318 commit 70057d3
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 6 deletions.
Binary file added Assets/LowEnergyAdvertisingDataExample1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Sources/BitMaskOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ extension BitMaskOptionSet: ExpressibleByArrayLiteral {

// MARK: - ExpressibleByIntegerLiteral

/// Swift 3 works better than Swift 4 compiler
// Swift 3 works better than Swift 4 compiler

#if swift(>=3.2)

Expand Down
88 changes: 84 additions & 4 deletions Sources/GenericAccessProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public enum GAP {

/// Generic Access Profile Data Type
///
/// ​​Assigned numbers are used in GAP for inquiry response, EIR data type values, manufacturer-specific data, advertising data,
/// low energy UUIDs and appearance characteristics, and class of device.
/// ​​Assigned numbers are used in GAP for inquiry response, EIR data type values, manufacturer-specific data,
/// advertising data, low energy UUIDs and appearance characteristics, and class of device.
///
/// - SeeAlso:
/// [Generic Access Profile](https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile)
Expand Down Expand Up @@ -81,7 +81,83 @@ public protocol GAPData {
var byteValue: [UInt8] { get }
}

/// GAP Complete Local Name
public struct GAPFlags: GAPData {

public static let length = 1

public init?(byteValue: [UInt8]) {

fatalError()
}

public var byteValue: [UInt8] {

return []
}
}

/**
GAP Flag

The Flags data type contains one bit Boolean flags. The Flags data type shall be included when any of the Flag bits are non-zero and the advertising packet is connectable, otherwise the Flags data type may be omitted. All 0x00 octets after the last non-zero octet shall be omitted from the value transmitted.

- Note: If the Flags AD type is not present in a non-connectable advertisement, the Flags should be considered as unknown and no assumptions should be made by the scanner.

Flags used over the LE physical channel are:

• Limited Discoverable Mode

• General Discoverable Mode

• BR/EDR Not Supported

• Simultaneous LE and BR/EDR to Same Device Capable (Controller)

• Simultaneous LE and BR/EDR to Same Device Capable (Host)

The LE Limited Discoverable Mode and LE General Discoverable Mode flags shall be ignored when received over the BR/EDR physical channel. The ‘BR/ EDR Not Supported’ flag shall be set to 0 when sent over the BR/EDR physical channel.

The Flags field may be zero or more octets long. This allows the Flags field to be extended while using the minimum number of octets within the data packet.
*/
public enum GAPFlag: UInt8, BitMaskOption {

/// LE Limited Discoverable Mode
case lowEnergyLimitedDiscoverableMode = 0b01

/// LE General Discoverable Mode
case lowEnergyGeneralDiscoverableMode = 0b10

/// BR/EDR Not Supported.
///
/// Bit 37 of LMP Feature Mask Definitions (Page 0)
case notSupportedBREDR = 0b100

/// Simultaneous LE and BR/EDR to Same Device Capable (Controller).
///
/// Bit 49 of LMP Feature Mask Definitions (Page 0)
case simultaneousController = 0b1000

/// Simultaneous LE and BR/EDR to Same Device Capable (Host).
///
/// Bit 66 of LMP Feature Mask Definitions (Page 1)
case simultaneousHost = 0b10000

public static let all: Set<GAPFlag> = [
.lowEnergyLimitedDiscoverableMode,
.lowEnergyGeneralDiscoverableMode,
.notSupportedBREDR,
.simultaneousController,
.simultaneousHost
]
}

/**
GAP Shortened Local Name

The Local Name data type shall be the same as, or a shortened version of, the local name assigned to the device. The Local Name data type value indicates if the name is complete or shortened. If the name is shortened, the complete name can be read using the remote name request procedure over BR/EDR or by reading the device name characteristic after the connection has been established using GATT.

A shortened name shall only contain contiguous characters from the beginning of the full name. For example, if the device name is ‘BT_Device_Name’ then the shortened name could be ‘BT_Device’ or ‘BT_Dev’.
*/
public struct GAPShortLocalName: GAPData, RawRepresentable {

public static let dataType: GAPDataType = .shortLocalName
Expand All @@ -107,7 +183,11 @@ public struct GAPShortLocalName: GAPData, RawRepresentable {
}
}

/// GAP Complete Local Name
/**
GAP Complete Local Name

The Local Name data type shall be the same as, or a shortened version of, the local name assigned to the device. The Local Name data type value indicates if the name is complete or shortened. If the name is shortened, the complete name can be read using the remote name request procedure over BR/EDR or by reading the device name characteristic after the connection has been established using GATT.
*/
public struct GAPCompleteLocalName: GAPData, RawRepresentable {

public static let dataType: GAPDataType = .completeLocalName
Expand Down
4 changes: 3 additions & 1 deletion Sources/LowEnergyAdvertisingData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

import Foundation

// Bluetooth Low Energy Advertising Data.
/// Bluetooth Low Energy Advertising Data.
///
/// ![Image](https://github.com/PureSwift/Bluetooth/raw/master/Assets/LowEnergyAdvertisingDataExample1.png)
public struct LowEnergyAdvertisingData: ByteValue {

// MARK: - ByteValue
Expand Down

0 comments on commit 70057d3

Please sign in to comment.