mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #243 from meshtastic/2.0.3_Working_Changes
2.0.3 working changes
This commit is contained in:
commit
f7bbba9a4c
4 changed files with 56 additions and 47 deletions
|
|
@ -45,7 +45,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
var timeoutTimer: Timer?
|
||||
var timeoutTimerCount = 0
|
||||
var positionTimer: Timer?
|
||||
let broadcastNodeNum: UInt32 = 4294967295
|
||||
let emptyNodeNum: UInt32 = 4294967295
|
||||
|
||||
/* Meshtastic Service Details */
|
||||
var TORADIO_characteristic: CBCharacteristic!
|
||||
|
|
@ -487,10 +487,18 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
|
||||
// MyInfo
|
||||
if decodedInfo.myInfo.isInitialized && decodedInfo.myInfo.myNodeNum > 0 {
|
||||
|
||||
let lastDotIndex = decodedInfo.myInfo.firmwareVersion.lastIndex(of: ".")
|
||||
let version = decodedInfo.myInfo.firmwareVersion[...(lastDotIndex ?? String.Index(utf16Offset: 6, in: decodedInfo.myInfo.firmwareVersion))]
|
||||
nowKnown = true
|
||||
connectedVersion = String(version)
|
||||
|
||||
if lastDotIndex == nil {
|
||||
invalidVersion = true
|
||||
connectedVersion = "0.0.0"
|
||||
} else {
|
||||
let version = decodedInfo.myInfo.firmwareVersion[...(lastDotIndex ?? String.Index(utf16Offset: 6, in: decodedInfo.myInfo.firmwareVersion))]
|
||||
nowKnown = true
|
||||
connectedVersion = String(version)
|
||||
}
|
||||
|
||||
let supportedVersion = connectedVersion == "0.0.0" || self.minimumVersion.compare(connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(connectedVersion, options: .numeric) == .orderedSame
|
||||
if !supportedVersion {
|
||||
invalidVersion = true
|
||||
|
|
@ -598,7 +606,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
|
||||
// MARK: Check for an All / Broadcast User and delete it as a transition to multi channel
|
||||
let fetchBCUserRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserEntity")
|
||||
fetchBCUserRequest.predicate = NSPredicate(format: "num == %lld", Int64(broadcastNodeNum))
|
||||
fetchBCUserRequest.predicate = NSPredicate(format: "num == %lld", Int64(emptyNodeNum))
|
||||
|
||||
do {
|
||||
let fetchedUser = try context?.fetch(fetchBCUserRequest) as! [UserEntity]
|
||||
|
|
@ -716,7 +724,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
if toUserNum > 0 {
|
||||
meshPacket.to = UInt32(toUserNum)
|
||||
} else {
|
||||
meshPacket.to = 4294967295
|
||||
meshPacket.to = emptyNodeNum
|
||||
}
|
||||
meshPacket.channel = UInt32(channel)
|
||||
meshPacket.from = UInt32(fromUserNum)
|
||||
|
|
@ -822,7 +830,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
var dataMessage = DataMessage()
|
||||
dataMessage.payload = try! positionPacket.serializedData()
|
||||
dataMessage.portnum = PortNum.positionApp
|
||||
if destNum != broadcastNodeNum {
|
||||
if destNum != emptyNodeNum {
|
||||
dataMessage.wantResponse = true
|
||||
}
|
||||
meshPacket.decoded = dataMessage
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ struct ChannelMessageList: View {
|
|||
NavigationStack {
|
||||
ScrollViewReader { scrollView in
|
||||
ScrollView {
|
||||
LazyVStack {
|
||||
LazyVStack {
|
||||
ForEach( channel.allPrivateMessages ) { (message: MessageEntity) in
|
||||
let currentUser: Bool = (userSettings.preferredNodeNum == message.fromUser?.num ? true : false)
|
||||
if message.replyID > 0 {
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ struct Contacts: View {
|
|||
VStack {
|
||||
NavigationLink(destination: ChannelMessageList(channel: channel)) {
|
||||
|
||||
let mostRecent = channel.allPrivateMessages.last
|
||||
let mostRecent = channel.allPrivateMessages.last(where: { $0.channel == channel.index })
|
||||
let lastMessageTime = Date(timeIntervalSince1970: TimeInterval(Int64((mostRecent?.messageTimestamp ?? 0 ))))
|
||||
let lastMessageDay = Calendar.current.dateComponents([.day], from: lastMessageTime).day ?? 0
|
||||
let currentDay = Calendar.current.dateComponents([.day], from: Date()).day ?? 0
|
||||
HStack {
|
||||
//HStack {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
CircleText(text: String(channel.index), color: .gray, circleSize: 52, fontSize: 40)
|
||||
|
|
@ -80,7 +80,7 @@ struct Contacts: View {
|
|||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: 80, alignment: .leading)
|
||||
|
|
@ -94,7 +94,7 @@ struct Contacts: View {
|
|||
ForEach(users) { (user: UserEntity) in
|
||||
if user.num != bleManager.userSettings?.preferredNodeNum ?? 0 {
|
||||
NavigationLink(destination: UserMessageList(user: user)) {
|
||||
let mostRecent = user.num == bleManager.broadcastNodeNum ? user.messageList.last : user.messageList.last(where: { $0.toUser?.num ?? 0 != bleManager.broadcastNodeNum })
|
||||
let mostRecent = user.messageList.last
|
||||
let lastMessageTime = Date(timeIntervalSince1970: TimeInterval(Int64((mostRecent?.messageTimestamp ?? 0 ))))
|
||||
let lastMessageDay = Calendar.current.dateComponents([.day], from: lastMessageTime).day ?? 0
|
||||
let currentDay = Calendar.current.dateComponents([.day], from: Date()).day ?? 0
|
||||
|
|
|
|||
|
|
@ -42,46 +42,47 @@ struct NodeList: View {
|
|||
let connected: Bool = (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.num == node.num)
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
CircleText(text: node.user?.shortName ?? "???", color: .gray, circleSize: 52, fontSize: 16).offset(y: 1).padding(.trailing, 5)
|
||||
.offset(x: -15)
|
||||
|
||||
Text(node.user?.longName ?? "Unknown").font(.headline).offset(x: -15)
|
||||
}
|
||||
.padding(.bottom, 5)
|
||||
if connected {
|
||||
HStack(alignment: .bottom) {
|
||||
Image(systemName: "repeat.circle.fill")
|
||||
.font(.title2)
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
Text("Currently Connected").font(.callout)
|
||||
}
|
||||
.padding(.bottom, 2)
|
||||
}
|
||||
if node.positions?.count ?? 0 > 0 && (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.num != node.num) {
|
||||
HStack(alignment: .bottom) {
|
||||
let lastPostion = node.positions!.reversed()[0] as! PositionEntity
|
||||
let myCoord = CLLocation(latitude: LocationHelper.currentLocation.latitude, longitude: LocationHelper.currentLocation.longitude)
|
||||
if lastPostion.coordinate != nil {
|
||||
let nodeCoord = CLLocation(latitude: lastPostion.coordinate!.latitude, longitude: lastPostion.coordinate!.longitude)
|
||||
let metersAway = nodeCoord.distance(from: myCoord)
|
||||
Image(systemName: "lines.measurement.horizontal")
|
||||
.font(.title3)
|
||||
CircleText(text: node.user?.shortName ?? "???", color: .gray, circleSize: 52, fontSize: 16)
|
||||
.padding(.trailing, 5)
|
||||
VStack(alignment: .leading) {
|
||||
Text(node.user?.longName ?? "Unknown").font(.headline)
|
||||
.padding(.bottom, 2)
|
||||
if connected {
|
||||
HStack(alignment: .bottom) {
|
||||
Image(systemName: "repeat.circle.fill")
|
||||
.font(.title2)
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
Text("Currently Connected").font(.callout)
|
||||
}
|
||||
.padding(.bottom, 2)
|
||||
}
|
||||
if node.positions?.count ?? 0 > 0 && (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.num != node.num) {
|
||||
HStack(alignment: .bottom) {
|
||||
let lastPostion = node.positions!.reversed()[0] as! PositionEntity
|
||||
let myCoord = CLLocation(latitude: LocationHelper.currentLocation.latitude, longitude: LocationHelper.currentLocation.longitude)
|
||||
if lastPostion.coordinate != nil {
|
||||
let nodeCoord = CLLocation(latitude: lastPostion.coordinate!.latitude, longitude: lastPostion.coordinate!.longitude)
|
||||
let metersAway = nodeCoord.distance(from: myCoord)
|
||||
Image(systemName: "lines.measurement.horizontal")
|
||||
.font(.title3)
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
|
||||
DistanceText(meters: metersAway).font(.subheadline)
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 2)
|
||||
}
|
||||
HStack(alignment: .bottom) {
|
||||
Image(systemName: "clock.badge.checkmark.fill")
|
||||
.font(.headline)
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
|
||||
DistanceText(meters: metersAway).font(.subheadline)
|
||||
LastHeardText(lastHeard: node.lastHeard)
|
||||
.font(.subheadline)
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 2)
|
||||
}
|
||||
HStack(alignment: .bottom) {
|
||||
Image(systemName: "clock.badge.checkmark.fill")
|
||||
.font(.headline)
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
LastHeardText(lastHeard: node.lastHeard)
|
||||
.font(.subheadline)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.padding([.leading, .top, .bottom])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue