-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #387 from ps2/dev
Release 2.0
- Loading branch information
Showing
181 changed files
with
7,591 additions
and
7,381 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ DerivedData | |
*.ipa | ||
*.xcuserstate | ||
*.xcscmblueprint | ||
project.xcworkspace | ||
.DS_Store | ||
*.log | ||
|
||
|
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// NumberFormatter.swift | ||
// RileyLink | ||
// | ||
// Copyright © 2017 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension NumberFormatter { | ||
func decibleString(from decibles: Int?) -> String? { | ||
if let decibles = decibles, let formatted = string(from: NSNumber(value: decibles)) { | ||
return String(format: NSLocalizedString("%@ dB", comment: "Unit format string for an RSSI value in decibles"), formatted) | ||
} else { | ||
return nil | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// OSLog.swift | ||
// Loop | ||
// | ||
// Copyright © 2017 LoopKit Authors. All rights reserved. | ||
// | ||
|
||
import os.log | ||
|
||
|
||
extension OSLog { | ||
convenience init(category: String) { | ||
self.init(subsystem: "com.ps2.rileylink", category: category) | ||
} | ||
|
||
func debug(_ message: StaticString, _ args: CVarArg...) { | ||
log(message, type: .debug, args) | ||
} | ||
|
||
func info(_ message: StaticString, _ args: CVarArg...) { | ||
log(message, type: .info, args) | ||
} | ||
|
||
func error(_ message: StaticString, _ args: CVarArg...) { | ||
log(message, type: .error, args) | ||
} | ||
|
||
private func log(_ message: StaticString, type: OSLogType, _ args: [CVarArg]) { | ||
switch args.count { | ||
case 0: | ||
os_log(message, log: self, type: type) | ||
case 1: | ||
os_log(message, log: self, type: type, args[0]) | ||
case 2: | ||
os_log(message, log: self, type: type, args[0], args[1]) | ||
case 3: | ||
os_log(message, log: self, type: type, args[0], args[1], args[2]) | ||
case 4: | ||
os_log(message, log: self, type: type, args[0], args[1], args[2], args[3]) | ||
default: | ||
os_log(message, log: self, type: type, args) | ||
} | ||
} | ||
} |
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* (No Comment) */ | ||
"CFBundleName" = "$(PRODUCT_NAME)"; | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* No Localized Strings */ |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// | ||
// FourByteSixByteEncoding.swift | ||
// RileyLink | ||
// | ||
// Created by Pete Schwamb on 2/27/16. | ||
// Copyright © 2016 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
fileprivate let codes = [21, 49, 50, 35, 52, 37, 38, 22, 26, 25, 42, 11, 44, 13, 14, 28] | ||
|
||
fileprivate let codesRev = Dictionary<Int, UInt8>(uniqueKeysWithValues: codes.enumerated().map({ ($1, UInt8($0)) })) | ||
|
||
public extension Sequence where Element == UInt8 { | ||
|
||
public func decode4b6b() -> [UInt8]? { | ||
var buffer = [UInt8]() | ||
var availBits = 0 | ||
var bitAccumulator = 0 | ||
for byte in self { | ||
if byte == 0 { | ||
break | ||
} | ||
|
||
bitAccumulator = (bitAccumulator << 8) + Int(byte) | ||
availBits += 8 | ||
if availBits >= 12 { | ||
guard let hiNibble = codesRev[bitAccumulator >> (availBits - 6)], | ||
let loNibble = codesRev[(bitAccumulator >> (availBits - 12)) & 0b111111] | ||
else { | ||
return nil | ||
} | ||
let decoded = UInt8((hiNibble << 4) + loNibble) | ||
buffer.append(decoded) | ||
availBits -= 12 | ||
bitAccumulator = bitAccumulator & (0xffff >> (16-availBits)) | ||
} | ||
} | ||
return buffer | ||
} | ||
|
||
public func encode4b6b() -> [UInt8] { | ||
var buffer = [UInt8]() | ||
var bitAccumulator = 0x0 | ||
var bitcount = 0 | ||
for byte in self { | ||
bitAccumulator <<= 6 | ||
bitAccumulator |= codes[Int(byte >> 4)] | ||
bitcount += 6 | ||
|
||
bitAccumulator <<= 6 | ||
bitAccumulator |= codes[Int(byte & 0x0f)] | ||
bitcount += 6 | ||
|
||
while bitcount >= 8 { | ||
buffer.append(UInt8(bitAccumulator >> (bitcount-8)) & 0xff) | ||
bitcount -= 8 | ||
bitAccumulator &= (0xffff >> (16-bitcount)) | ||
} | ||
} | ||
if bitcount > 0 { | ||
bitAccumulator <<= (8-bitcount) | ||
buffer.append(UInt8(bitAccumulator) & 0xff) | ||
} | ||
return buffer | ||
} | ||
} | ||
|
Oops, something went wrong.