mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
V 1.26.0 Preferred Radio v1
This commit is contained in:
parent
614d9f0f9e
commit
5d12cca775
4 changed files with 74 additions and 26 deletions
|
|
@ -660,7 +660,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.25.10;
|
||||
MARKETING_VERSION = 1.26.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
|
|
@ -687,7 +687,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.25.10;
|
||||
MARKETING_VERSION = 1.26.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
|
|
|
|||
|
|
@ -107,11 +107,10 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
if let name = advertisementData[CBAdvertisementDataLocalNameKey] as? String {
|
||||
peripheralName = name
|
||||
}
|
||||
|
||||
let newPeripheral = Peripheral(id: peripheral.identifier.uuidString, name: peripheralName, rssi: RSSI.intValue, peripheral: peripheral, myInfo: nil)
|
||||
|
||||
peripherals.append(newPeripheral)
|
||||
print("Adding peripheral: \(peripheralName)");
|
||||
|
||||
let newPeripheral = Peripheral(id: peripheral.identifier.uuidString, name: peripheralName, rssi: RSSI.intValue, peripheral: peripheral, myInfo: nil)
|
||||
peripherals.append(newPeripheral)
|
||||
print("Adding peripheral: \(peripheralName)");
|
||||
}
|
||||
|
||||
// called when a peripheral is connected
|
||||
|
|
|
|||
|
|
@ -18,9 +18,13 @@ struct Connect: View {
|
|||
@EnvironmentObject var meshData: MeshData
|
||||
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
|
||||
@ObservedObject var userSettings = UserSettings()
|
||||
@State var isPreferredRadio: Bool = false
|
||||
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
|
||||
NavigationView {
|
||||
|
||||
VStack {
|
||||
if bleManager.isSwitchedOn {
|
||||
|
|
@ -46,24 +50,51 @@ struct Connect: View {
|
|||
}
|
||||
Text("FW Version: ").font(.caption)+Text(bleManager.connectedPeripheral.myInfo?.firmwareVersion ?? "(null)").font(.caption).foregroundColor(Color.gray)
|
||||
}
|
||||
Spacer()
|
||||
VStack (alignment: .center) {
|
||||
Text("Preferred").font(.caption2)
|
||||
Text("Radio").font(.caption2)
|
||||
Toggle("Preferred Radio", isOn: $isPreferredRadio)
|
||||
.toggleStyle(SwitchToggleStyle(tint: .green))
|
||||
.labelsHidden()
|
||||
.onChange(of: isPreferredRadio) { value in
|
||||
if value {
|
||||
if bleManager.connectedNode != nil {
|
||||
userSettings.preferredPeripheralName = "\(bleManager.connectedNode.user.longName) / \(bleManager.connectedPeripheral.peripheral.name ?? "")"
|
||||
}
|
||||
else {
|
||||
|
||||
userSettings.preferredPeripheralName = bleManager.connectedPeripheral.peripheral.name ?? "Unknown Device"
|
||||
}
|
||||
|
||||
userSettings.preferredPeripheralId = bleManager.connectedPeripheral!.peripheral.identifier.uuidString
|
||||
|
||||
} else {
|
||||
|
||||
userSettings.preferredPeripheralId = ""
|
||||
userSettings.preferredPeripheralName = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Text((bleManager.connectedPeripheral!.peripheral.name != nil) ? bleManager.connectedPeripheral!.peripheral.name! : "Unknown").font(.title2)
|
||||
}
|
||||
}
|
||||
.swipeActions {
|
||||
|
||||
Button(role: .destructive) {
|
||||
if bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.peripheral.state == CBPeripheralState.connected
|
||||
{
|
||||
|
||||
bleManager.disconnectDevice()
|
||||
}
|
||||
} label: {
|
||||
Label("Delete", systemImage: "antenna.radiowaves.left.and.right.slash")
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.padding([.top, .bottom])
|
||||
.swipeActions {
|
||||
|
||||
Button(role: .destructive) {
|
||||
if bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.peripheral.state == CBPeripheralState.connected
|
||||
{
|
||||
|
||||
bleManager.disconnectDevice()
|
||||
}
|
||||
} label: {
|
||||
Label("Delete", systemImage: "antenna.radiowaves.left.and.right.slash")
|
||||
}
|
||||
}
|
||||
//.padding()
|
||||
}
|
||||
else {
|
||||
HStack{
|
||||
|
|
@ -91,6 +122,10 @@ struct Connect: View {
|
|||
self.bleManager.disconnectDevice()
|
||||
}
|
||||
self.bleManager.connectTo(peripheral: peripheral.peripheral)
|
||||
if userSettings.preferredPeripheralId == peripheral.peripheral.identifier.uuidString {
|
||||
|
||||
isPreferredRadio = true
|
||||
}
|
||||
}) {
|
||||
Text(peripheral.name).font(.title3)
|
||||
}
|
||||
|
|
@ -147,7 +182,15 @@ struct Connect: View {
|
|||
)
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
.onAppear(perform: { bleManager.startScanning() } )
|
||||
.onAppear(perform: {
|
||||
|
||||
if bleManager.connectedPeripheral != nil && userSettings.preferredPeripheralId == bleManager.connectedPeripheral.peripheral.identifier.uuidString {
|
||||
isPreferredRadio = true
|
||||
}
|
||||
else {
|
||||
bleManager.startScanning()
|
||||
}
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,15 +68,19 @@ class UserSettings: ObservableObject {
|
|||
|
||||
struct AppSettings: View {
|
||||
|
||||
@State private var preferredDeviceConnected = false
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@ObservedObject var userSettings = UserSettings()
|
||||
|
||||
var body: some View {
|
||||
|
||||
NavigationView {
|
||||
|
||||
GeometryReader { bounds in
|
||||
|
||||
Form {
|
||||
Section(header: Text("USER DETAILS")) {
|
||||
|
||||
HStack{
|
||||
|
||||
Text("User Name")
|
||||
|
|
@ -87,10 +91,12 @@ struct AppSettings: View {
|
|||
|
||||
Text("Provide location to mesh")
|
||||
}
|
||||
}
|
||||
Section(header: Text("PREFERRED PERIPHERAL")) {
|
||||
Text("The preferred peripheral will automatically reconnect if it becomes disconnected and is still within range. This device is assumed to be the primary messaging device for the app.").font(.caption).foregroundColor(.gray)
|
||||
.listRowSeparator(.visible)
|
||||
Text("Preferred Radio")
|
||||
.listRowSeparator(.hidden)
|
||||
Text(userSettings.preferredPeripheralName)
|
||||
.foregroundColor(.gray)
|
||||
Text("The preferred radio will automatically reconnect if it becomes disconnected and is still within range. This device is assumed to be the primary radio used for messaging.").font(.caption2).foregroundColor(.gray)
|
||||
|
||||
}
|
||||
Section(header: Text("MESSAGING OPTIONS")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue