Compare commits
2 commits
ce81a1a3d8
...
640bc32f92
| Author | SHA1 | Date | |
|---|---|---|---|
| 640bc32f92 | |||
| 157ab6d008 |
3 changed files with 11 additions and 7 deletions
|
|
@ -174,9 +174,12 @@ final class DXSmartProvisioner: NSObject, BeaconProvisioner {
|
|||
await diagnosticLog?.log("write", "[\(index + 1)/\(commands.count)] \(name) (\(packet.count) bytes)")
|
||||
|
||||
// SaveConfig (last command) causes beacon MCU to reboot — it never sends an ACK.
|
||||
// Fire the BLE write and return immediately; the disconnect is expected.
|
||||
// Use .withoutResponse so CoreBluetooth fires the bytes immediately into the
|
||||
// BLE radio buffer without waiting for a GATT round-trip. With .withResponse,
|
||||
// the beacon reboots before the ACK arrives, and CoreBluetooth may silently
|
||||
// drop the write — leaving the config unsaved and the beacon still flashing.
|
||||
if name == "SaveConfig" {
|
||||
peripheral.writeValue(packet, for: writeChar, type: .withResponse)
|
||||
peripheral.writeValue(packet, for: writeChar, type: .withoutResponse)
|
||||
await diagnosticLog?.log("write", "✅ [\(index + 1)/\(commands.count)] SaveConfig sent — beacon will reboot")
|
||||
await diagnosticLog?.log("write", "✅ All commands written successfully")
|
||||
return
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ actor APIClient {
|
|||
uuid: String,
|
||||
major: Int,
|
||||
minor: Int,
|
||||
macAddress: String?,
|
||||
hardwareId: String,
|
||||
beaconType: String,
|
||||
token: String
|
||||
) async throws {
|
||||
|
|
@ -230,9 +230,9 @@ actor APIClient {
|
|||
"UUID": uuid,
|
||||
"Major": major,
|
||||
"Minor": minor,
|
||||
"HardwareId": hardwareId,
|
||||
"BeaconType": beaconType
|
||||
]
|
||||
if let mac = macAddress { body["MacAddress"] = mac }
|
||||
let data = try await post(path: "/beacon-sharding/register_beacon_hardware.php", body: body, token: token, businessId: businessId)
|
||||
let resp = try JSONDecoder().decode(OKResponse.self, from: data)
|
||||
guard resp.OK else {
|
||||
|
|
@ -241,12 +241,13 @@ actor APIClient {
|
|||
}
|
||||
|
||||
func verifyBeaconBroadcast(
|
||||
hardwareId: String,
|
||||
uuid: String,
|
||||
major: Int,
|
||||
minor: Int,
|
||||
token: String
|
||||
) async throws {
|
||||
let body: [String: Any] = ["UUID": uuid, "Major": major, "Minor": minor]
|
||||
let body: [String: Any] = ["HardwareId": hardwareId, "UUID": uuid, "Major": major, "Minor": minor]
|
||||
let data = try await post(path: "/beacon-sharding/verify_beacon_broadcast.php", body: body, token: token)
|
||||
let resp = try JSONDecoder().decode(OKResponse.self, from: data)
|
||||
guard resp.OK else {
|
||||
|
|
|
|||
|
|
@ -706,7 +706,7 @@ struct ScanView: View {
|
|||
uuid: ns.uuid,
|
||||
major: ns.major,
|
||||
minor: Int(config.minor),
|
||||
macAddress: nil,
|
||||
hardwareId: selectedBeacon?.id.uuidString ?? "unknown-ios",
|
||||
beaconType: BeaconType.dxsmart.rawValue,
|
||||
token: token
|
||||
)
|
||||
|
|
@ -739,7 +739,7 @@ struct ScanView: View {
|
|||
uuid: ns.uuid,
|
||||
major: ns.major,
|
||||
minor: Int(config.minor),
|
||||
macAddress: nil,
|
||||
hardwareId: selectedBeacon?.id.uuidString ?? "unknown-ios",
|
||||
beaconType: selectedBeacon?.type.rawValue ?? "Unknown",
|
||||
token: token
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue