Added Debug- Print Statements

This commit is contained in:
severin.memmishofer 2023-07-13 18:50:28 +02:00
parent 8d7d6dd8ea
commit 9b53e1d3e3
4 changed files with 12 additions and 6 deletions

View File

@ -497,7 +497,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"RippleChat/Preview Content\"";
DEVELOPMENT_TEAM = GN2B48NJ47;
DEVELOPMENT_TEAM = B5S58UWR64;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Allow for bluetooth use";
@ -512,7 +512,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = unibas.inetsec.RippleChat1;
PRODUCT_BUNDLE_IDENTIFIER = unibas.inetsec.RippleChat;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;

View File

@ -10,6 +10,7 @@ import CoreBluetooth
class BluetoothPeripheral: NSObject, ObservableObject {
@Published var incomingMsg: String = ""
private var peripheralManager: CBPeripheralManager?
let BLE_SERVICE_UUID = CBUUID(string: "6e400001-7646-4b5b-9a50-71becce51558")
@ -63,7 +64,8 @@ extension BluetoothPeripheral: CBPeripheralManagerDelegate {
do {
let receivedObject = try decoder.decode(String.self, from: receivedData)
// Use the received object to update your app state as needed
print(receivedObject)
print("Received Write")
self.incomingMsg = receivedObject
} catch {
print("Failed to decode JSON: \(error)")
}

View File

@ -60,11 +60,12 @@ extension BluetoothController: CBCentralManagerDelegate {
return
}
print("Writing to Characteristic...")
// Go through
for characteristic in writeCharacteristics {
// Go through connected peripherals and write to their characteristic
for peripheral in peripherals {
peripheral.writeValue(messageData, for: characteristic, type: .withResponse)
peripheral.writeValue(messageData, for: characteristic, type: .withoutResponse)
}
}
}

View File

@ -19,16 +19,19 @@ struct PeeringView: View {
}
.navigationTitle("Peering")
.navigationViewStyle(StackNavigationViewStyle())
Text("Incoming msg: \(btPeripheral.incomingMsg)")
Button(action: {
do {
let WANT_msg = WantMessage(friends: dataStore.friends)
let encoded_msg = try JSONEncoder().encode(WANT_msg)
btController.writeToCharacteristics(message: String(data: encoded_msg, encoding: .utf8)!)
//btController.writeToCharacteristics(message: String(data: encoded_msg, encoding: .utf8)!)
btController.writeToCharacteristics(message: "Test")
print("Pressed Button")
} catch {
fatalError(error.localizedDescription)
}
}) {
Text("Send WANT-Vector")
}
.padding()
}