Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(ios): wire Wi-Fi config characteristic + actually push creds on Confirm #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Flo5k5 wants to merge 1 commit into m5stack:main
base: main
Choose a base branch
Loading
from Flo5k5:fix/ios-wifi-push-on-confirm
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/StackChan/AppState.swift
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,23 @@ class AppState: ObservableObject {
}
BlufiUtil.shared.characteristicCallback = { characteristic in
if characteristic.properties.contains(.write) || characteristic.properties.contains(.writeWithoutResponse) {

if characteristic.uuid.uuidString == "E2E5E5E2-1234-5678-1234-56789ABCDEF0" {
BlufiUtil.shared.writeExpressionCharacteristic = characteristic
print("✏️ Expression writable characteristic assigned: \(characteristic.uuid)")
}

if characteristic.uuid.uuidString == "E2E5E5E1-1234-5678-1234-56789ABCDEF0" {
BlufiUtil.shared.writeHeadCharacteristic = characteristic
print("✏️ Head writable characteristic assigned: \(characteristic.uuid)")
}

// Config characteristic — used for Wi-Fi provisioning (SSID + password JSON)
// during pairing. Firmware handler is _handle_ble_config_write in hal_ble.cpp.
if characteristic.uuid.uuidString == "E2E5E5E3-1234-5678-1234-56789ABCDEF0" {
BlufiUtil.shared.writeWifiSetCharacteristic = characteristic
print("✏️ Config/Wifi writable characteristic assigned: \(characteristic.uuid)")
}
}
}
}
Expand Down
23 changes: 19 additions & 4 deletions app/StackChan/View/BindingDevice.swift
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -279,23 +279,38 @@ struct ScanningEquipment : View {
}

private func confirmWifi() {

if !BlufiUtil.shared.blueSwitch {
appState.alertTitle = "Please turn on Bluetooth"
appState.showAlert = true
return
}

if wifiName.isEmpty || wifiPassword.isEmpty {
appState.alertTitle = "Please enter Wi-Fi name and password"
appState.showAlert = true
return
}


// Push the Wi-Fi credentials to the StackChan over BLE.
// The firmware expects {"ssid":..., "password":...} on the Config
// characteristic (see hal_ble.cpp:_handle_ble_config_write).
let payload: [String: String] = [
"ssid": wifiName,
"password": wifiPassword,
]
if let data = try? JSONSerialization.data(withJSONObject: payload),
let json = String(data: data, encoding: .utf8) {
BlufiUtil.shared.sendWifiSetData(json)
print("➡️ Wi-Fi credentials sent to device")
} else {
print("⚠️ Failed to serialise Wi-Fi payload")
}

withAnimation{
pairingStatus = .DistributionNetwork
}

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
withAnimation{
pairingStatus = .ChangeTheName
Expand Down

AltStyle によって変換されたページ (->オリジナル) /