Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Companion App iOS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
card10
Companion App iOS
Commits
62fa6907
Commit
62fa6907
authored
Aug 22, 2019
by
Thomas Mellenthin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch back to withoutResponse, as FW changed this
parent
2004c498
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
card10badge/Bluetooth/BluetoothManager.swift
card10badge/Bluetooth/BluetoothManager.swift
+10
-10
No files found.
card10badge/Bluetooth/BluetoothManager.swift
View file @
62fa6907
...
...
@@ -186,7 +186,7 @@ class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate
let
time
=
UInt64
(
bigEndian
:
badgeTimeInMilliseconds
)
print
(
"setTimeOnPeripheral
\(
peripheral
.
identifier
)
to
\(
currentDate
)
(
\(
badgeTimeInMilliseconds
)
)"
)
self
.
connectedPeripheral
?
.
writeValue
(
time
.
data
,
for
:
characteristic
,
type
:
.
withResponse
)
self
.
connectedPeripheral
?
.
writeValue
(
time
.
data
,
for
:
characteristic
,
type
:
.
with
out
Response
)
}
public
func
setVibrate
(
milliseconds
:
UInt16
)
{
...
...
@@ -198,7 +198,7 @@ class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate
}
print
(
"setVibrate
\(
milliseconds
)
ms on
\(
peripheral
.
identifier
)
"
)
self
.
connectedPeripheral
?
.
writeValue
(
milliseconds
.
data
,
for
:
characteristic
,
type
:
.
withResponse
)
self
.
connectedPeripheral
?
.
writeValue
(
milliseconds
.
data
,
for
:
characteristic
,
type
:
.
with
out
Response
)
}
public
func
illuminateRocketsWithBrightness
(
rocketOne
:
UInt8
,
rocketTwo
:
UInt8
,
rocketThree
:
UInt8
)
{
...
...
@@ -210,7 +210,7 @@ class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate
}
print
(
"set rockets to
\(
rocketOne
)
,
\(
rocketTwo
)
,
\(
rocketThree
)
on
\(
peripheral
.
identifier
)
"
)
self
.
connectedPeripheral
?
.
writeValue
(
Data
([
rocketOne
,
rocketTwo
,
rocketThree
]),
for
:
characteristic
,
type
:
.
withResponse
)
self
.
connectedPeripheral
?
.
writeValue
(
Data
([
rocketOne
,
rocketTwo
,
rocketThree
]),
for
:
characteristic
,
type
:
.
with
out
Response
)
}
public
func
setBackgroundLEDs
(
topLeft
:
RGBLED
,
topRight
:
RGBLED
,
bottomRight
:
RGBLED
,
bottomLeft
:
RGBLED
)
{
...
...
@@ -232,10 +232,10 @@ class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate
return
}
self
.
connectedPeripheral
?
.
writeValue
(
topLeft
.
data
,
for
:
tlCharacteristic
,
type
:
.
withResponse
)
self
.
connectedPeripheral
?
.
writeValue
(
topRight
.
data
,
for
:
trCharacteristic
,
type
:
.
withResponse
)
self
.
connectedPeripheral
?
.
writeValue
(
bottomRight
.
data
,
for
:
brCharacteristic
,
type
:
.
withResponse
)
self
.
connectedPeripheral
?
.
writeValue
(
bottomLeft
.
data
,
for
:
blCharacteristic
,
type
:
.
withResponse
)
self
.
connectedPeripheral
?
.
writeValue
(
topLeft
.
data
,
for
:
tlCharacteristic
,
type
:
.
with
out
Response
)
self
.
connectedPeripheral
?
.
writeValue
(
topRight
.
data
,
for
:
trCharacteristic
,
type
:
.
with
out
Response
)
self
.
connectedPeripheral
?
.
writeValue
(
bottomRight
.
data
,
for
:
brCharacteristic
,
type
:
.
with
out
Response
)
self
.
connectedPeripheral
?
.
writeValue
(
bottomLeft
.
data
,
for
:
blCharacteristic
,
type
:
.
with
out
Response
)
}
/// Set's the 11 RGB leds at the top. Parameters are from left to right.
...
...
@@ -261,7 +261,7 @@ class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate
self
.
connectedPeripheral
?
.
writeValue
(
mergeLedsAboveIntoData
(
a
:
a
,
b
:
b
,
c
:
c
,
d
:
d
,
e
:
e
,
f
:
f
,
g
:
g
,
h
:
h
,
i
:
i
,
j
:
j
,
k
:
k
),
for
:
aboveCharacteristic
,
type
:
.
withResponse
)
type
:
.
with
out
Response
)
}
private
func
mergeLedsAboveIntoData
(
a
:
RGBLED
,
...
...
@@ -344,7 +344,7 @@ class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate
// I failed to scan for the CBUUD 42230100-2342-2342-2342-234223422342 :-/
guard
let
name
=
peripheral
.
name
,
name
.
hasPrefix
(
"card10"
)
else
{
return
}
print
(
"did discover:
\(
name
)
\(
peripheral
.
identifier
)
),
\(
advertisementData
[
CBAdvertisementDataLocalNameKey
]
)
"
)
print
(
"did discover:
\(
name
)
\(
peripheral
.
identifier
)
),
CBAdvertisementDataLocalNameKey:
\(
String
(
describing
:
advertisementData
[
CBAdvertisementDataLocalNameKey
])
)
"
)
// sort & unique foundPeripherals
foundPeripheral
.
append
(
peripheral
)
...
...
@@ -431,7 +431,7 @@ class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate
guard
let
characteristic
=
self
.
findCharacteristic
(
on
:
peripheral
,
forServiceUUID
:
card10RxTxServiceUUID
,
forCharacteristicUUID
:
card10TXWriteCharacteristicUUID
)
else
{
return
}
self
.
connectedPeripheral
?
.
writeValue
(
package
,
for
:
characteristic
,
type
:
.
with
out
Response
)
self
.
connectedPeripheral
?
.
writeValue
(
package
,
for
:
characteristic
,
type
:
.
withResponse
)
}
func
didUpdateState
(
_
state
:
TransferState
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment