mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Finished all the tasks from issue #1, completing all the tasks for the BLE helper and Bluetooth Connect view
This commit is contained in:
parent
be1881c6eb
commit
7726914ad1
5 changed files with 48 additions and 37 deletions
|
|
@ -643,7 +643,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.092;
|
||||
MARKETING_VERSION = 1.093;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
|
|
@ -669,7 +669,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.092;
|
||||
MARKETING_VERSION = 1.093;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
|
||||
if decodedInfo.myInfo.myNodeNum != 0
|
||||
{
|
||||
meshData.load()
|
||||
print("Save a myInfo")
|
||||
do {
|
||||
print(try decodedInfo.myInfo.jsonString())
|
||||
|
|
@ -252,34 +253,35 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
do {
|
||||
|
||||
if meshData.nodes.contains(where: {$0.id == decodedInfo.nodeInfo.num}) {
|
||||
// it exists, do something
|
||||
}
|
||||
else {
|
||||
|
||||
meshData.nodes.append(
|
||||
NodeInfoModel(
|
||||
num: decodedInfo.nodeInfo.num,
|
||||
user: NodeInfoModel.User(
|
||||
id: decodedInfo.nodeInfo.user.id,
|
||||
longName: decodedInfo.nodeInfo.user.longName,
|
||||
shortName: decodedInfo.nodeInfo.user.shortName,
|
||||
//macaddr: decodedInfo.nodeInfo.user.macaddr,
|
||||
hwModel: String(describing: decodedInfo.nodeInfo.user.hwModel)
|
||||
.uppercased()),
|
||||
|
||||
position: NodeInfoModel.Position(
|
||||
latitudeI: decodedInfo.nodeInfo.position.latitudeI,
|
||||
longitudeI: decodedInfo.nodeInfo.position.longitudeI,
|
||||
altitude: decodedInfo.nodeInfo.position.altitude,
|
||||
batteryLevel: decodedInfo.nodeInfo.position.batteryLevel,
|
||||
time: decodedInfo.nodeInfo.position.time),
|
||||
|
||||
lastHeard: decodedInfo.nodeInfo.lastHeard,
|
||||
snr: decodedInfo.nodeInfo.snr)
|
||||
)
|
||||
meshData.save()
|
||||
|
||||
let nodeIndex = meshData.nodes.firstIndex(where: { $0.id == decodedInfo.nodeInfo.num })
|
||||
meshData.nodes.remove(at: nodeIndex!)
|
||||
meshData.save()
|
||||
}
|
||||
|
||||
meshData.nodes.append(
|
||||
NodeInfoModel(
|
||||
num: decodedInfo.nodeInfo.num,
|
||||
user: NodeInfoModel.User(
|
||||
id: decodedInfo.nodeInfo.user.id,
|
||||
longName: decodedInfo.nodeInfo.user.longName,
|
||||
shortName: decodedInfo.nodeInfo.user.shortName,
|
||||
//macaddr: decodedInfo.nodeInfo.user.macaddr,
|
||||
hwModel: String(describing: decodedInfo.nodeInfo.user.hwModel)
|
||||
.uppercased()),
|
||||
|
||||
position: NodeInfoModel.Position(
|
||||
latitudeI: decodedInfo.nodeInfo.position.latitudeI,
|
||||
longitudeI: decodedInfo.nodeInfo.position.longitudeI,
|
||||
altitude: decodedInfo.nodeInfo.position.altitude,
|
||||
batteryLevel: decodedInfo.nodeInfo.position.batteryLevel,
|
||||
time: decodedInfo.nodeInfo.position.time),
|
||||
|
||||
lastHeard: decodedInfo.nodeInfo.lastHeard,
|
||||
snr: decodedInfo.nodeInfo.snr)
|
||||
)
|
||||
meshData.save()
|
||||
|
||||
print(try decodedInfo.nodeInfo.jsonString())
|
||||
} catch {
|
||||
fatalError("Failed to decode json")
|
||||
|
|
@ -298,6 +300,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
|
||||
if decodedInfo.configCompleteID != 0 {
|
||||
print(decodedInfo)
|
||||
meshData.load()
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -32,7 +32,18 @@ struct Connect: View {
|
|||
.symbolRenderingMode(.hierarchical)
|
||||
.imageScale(.large).foregroundColor(.green)
|
||||
.padding(.trailing)
|
||||
Text((bleManager.connectedPeripheral.name != nil) ? bleManager.connectedPeripheral.name! : "Unknown").font(.title3)
|
||||
Text((bleManager.connectedPeripheral.name != nil) ? bleManager.connectedPeripheral.name! : "Unknown").font(.title2)
|
||||
}
|
||||
.padding()
|
||||
.swipeActions {
|
||||
Button {
|
||||
bleManager.disconnectDevice()
|
||||
} label: {
|
||||
VStack {
|
||||
Label("Disconnect", systemImage: "antenna.radiowaves.left.and.right.slash")
|
||||
}
|
||||
}
|
||||
.tint(.red)
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -43,11 +54,12 @@ struct Connect: View {
|
|||
.padding(.trailing)
|
||||
Text("No device connected").font(.title3)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
}.textCase(nil)
|
||||
|
||||
Section(header: Text("New Devices").font(.title)) {
|
||||
Section(header: Text("Available Devices").font(.title)) {
|
||||
ForEach(bleManager.peripherals.sorted(by: { $0.rssi > $1.rssi })) { peripheral in
|
||||
HStack {
|
||||
Image(systemName: "circle.fill")
|
||||
|
|
@ -62,14 +74,10 @@ struct Connect: View {
|
|||
}
|
||||
Spacer()
|
||||
Text(String(peripheral.rssi) + " dB").font(.title3)
|
||||
}
|
||||
}.padding([.bottom,.top])
|
||||
}
|
||||
}.textCase(nil)
|
||||
|
||||
Section(header: Text("Known Devices").font(.title)) {
|
||||
|
||||
}.textCase(nil)
|
||||
|
||||
}
|
||||
|
||||
HStack (alignment: .center) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ struct ConnectedDevice: View {
|
|||
Text("Bluetooth Off").font(.caption).foregroundColor(.red)
|
||||
}
|
||||
}
|
||||
}.offset(x: 10, y: -10)
|
||||
}.offset(x: 5, y: -10)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ struct NodeDetail: View {
|
|||
Text("ago").font(.title3)
|
||||
}.padding()
|
||||
Divider()
|
||||
if node.position.latitudeI != nil {
|
||||
if node.position.coordinate != nil {
|
||||
HStack(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/, spacing: 14) {
|
||||
Image(systemName: "mappin").font(.title).foregroundColor(.blue)
|
||||
VStack(alignment: .leading) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue