Skip to content
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

Inner value of CWPHYMode appears to change between integer and bitflags index between macOS versions #662

Open
keabarnes opened this issue Oct 14, 2024 · 2 comments
Labels
A-framework Affects the framework crates and the translator for them bug Something isn't working

Comments

@keabarnes
Copy link

keabarnes commented Oct 14, 2024

In the code below, the inner value of CWPHYMode which is returned by interface.activePHYMode() differs based on the macOS version.

unsafe {
  let client = CWWiFiClient::sharedWiFiClient();

  let interface = client.interface().unwrap();

  let phy_mode = interface.activePHYMode();
}

From observation I've noticed that

  • on macOS 14.5 the inner value is represented by an integer that maps well to the const ... Self(n) constants on the enum
  • on macOS 15.0 it seems like the value represents the naive conversion from a bitflag to an integer
    • 802.11n is returned as CWPHYMode(16) but should be CWPHYMode(4)
    • 802.11ax is returned as CWPHYMode(64) but should be CWPHYMode(6)

Cargo.toml for context

objc2 = { version = "0.5", features = ["apple"] }
objc2-foundation = { version = "0.2", features = ["apple"] }
objc2-core-wlan = { version = "0.2", features = [
  "CWInterface",
  "CWNetwork",
  "CWWiFiClient",
  "CWChannel",
  "CoreWLANTypes",
] }
@simlay
Copy link
Collaborator

simlay commented Oct 16, 2024

Huh. This is interesting. I ran the example code. I'm on macOS 15 with an 802.11ac network. I get a CWPHYMode(32) when I presume it should be CWPHYMode(5). I get the same incorrect result mentioned above with an 802.11n network.

The mapping looks like:

  • CWPHYMode(4) is returned as CWPHYMode(16)
  • CWPHYMode(5) is returned as CWPHYMode(32)
  • CWPHYMode(6) is returned as CWPHYMode(64).

Looks like the pattern is a bitmask rather than an integer?

@madsmtm
Copy link
Owner

madsmtm commented Oct 21, 2024

I'm still on macOS 14.7, and can't test this in a virtual machine (since the virtual machines don't have WiFi), so could I get one of you to test the following:

  1. RUSTFLAGS="-Clinker-flavor=ld" cargo run (in case this is dependent on the minos/sdk version in the binary)
  2. The equivalent Swift code:
    import CoreWLAN
    
    let client = CWWiFiClient.shared()
    let interface = client.interface()!
    let phy_mode = interface.activePHYMode()
    print(phy_mode.rawValue)

@madsmtm madsmtm added bug Something isn't working A-framework Affects the framework crates and the translator for them labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants