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

[rtl872x] Use security type from usb message for joining hidden networks #2724

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

scott-brust
Copy link
Member

Problem

Joining a hidden wifi network via USB JoinNewNetworkRequest message fails even if the fields are populated correctly, ie hidden is true, and security is set to the correct value.

Solution

P2 platforms will use the provided SSID to scan for the network, and infer the security type from the actual network. I believe this was done to workaround CLI/app issues when P2 platform was being brought up.

If the network is not found, or it is hidden, then no security value will be used and any wifi connection attempts will fail.
The solution is to use the provided security type from the USB message if the network is hidden, or is not detected during a scan.

Steps to Test

  1. Flash firmware with this branch
  2. Use example node.js snippet to send the pbuf encoded message:
import * as usb from 'particle-usb';

const devices = await usb.getDevices();
console.log(devices);

for (let device of devices) {
  console.log("Device Type: ", device.type);
}

let p2_device = devices[0];
await p2_device.open();

let messages = [
	{
		ssid: "TP-Link_F6E0", // <-- Your hidden SSID Here
		bssid: null,
		security: 4, //   WPA_WPA2_PSK = 4
		hidden: true,
		credentials: {
			type: 1, // CredentialsType.PASSWORD
			password: "78019348". // <--- Your password here
		},
	}
]

for (let i in messages) {
	let msg = messages[i];
	console.log("Sending: ", msg);
	
	let rep = await p2_device._sendAndHandleProtobufRequest('wifi.JoinNewNetworkRequest', msg, { timeout: 30000 });
	
	console.log("Response ", rep);
}

await p2_device.close();

output:

Device Type:  p2
Sending:  {
  ssid: 'TP-Link_F6E0',
  bssid: null,
  security: 4,
  hidden: true,
  credentials: { type: 1, password: '78019348' }
}
Response  { pass: true, replyObject: JoinNewNetworkReply {} }

Example App

Any

References

Original hidden network support PR


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@avtolstoy avtolstoy merged commit b667ec3 into develop Jan 18, 2024
1 check passed
@avtolstoy avtolstoy deleted the fix/join-hidden-wifi-via-usb branch January 18, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants