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

[mw320] Sve2 pr #22915

Merged
merged 40 commits into from
Sep 29, 2022
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c700aee
Add the Software Version Info for TC-BINFO-2.1
crlonxp Jul 25, 2022
0bc7eb3
Add to save the information of the last connected AP
crlonxp Jul 25, 2022
ebff548
Add to support "Manual controlled feature" for TC-OO-2.2
crlonxp Jul 25, 2022
34e62ac
Move mw320_sdk initialization to a function
crlonxp Jul 25, 2022
96e74bc
Add Identify_Timer_Handler() for TC-I-2.2
crlonxp Jul 25, 2022
606a8e9
Add modules: - ConnectivityUtils.* - DeviceInfoProviderImpl.*
crlonxp Jul 25, 2022
92939df
Add the implementation of read/write configuration key to flash
crlonxp Jul 25, 2022
fda2852
Add to report information for TC_DGGEN-3.1
crlonxp Jul 25, 2022
5715b2e
Add the missing functions for handling tc-wifidiag-3.1 Some of them a…
crlonxp Jul 25, 2022
747f5eb
Restyled by clang-format
restyled-commits Jul 25, 2022
b120d7c
Restyled by gn
restyled-commits Jul 25, 2022
e21d6c1
Implement the functions for WiFiDiagnostics / Generic Diagnostics * w…
crlonxp Jul 28, 2022
249b2be
Add to support Identify_Time on multiple endpoints Verify: pass TC_I_…
crlonxp Aug 3, 2022
d66047a
Add "reset watermark" handler
crlonxp Aug 3, 2022
323e4a5
Add to support Ethernet / WiFi network commissioning Test: pass TC-CN…
crlonxp Aug 12, 2022
d16bfe2
* Remove unused module: DeviceInfoProviderImpl.cpp/DeviceInfoProvider…
crlonxp Aug 19, 2022
d608af0
Add to print the version string
crlonxp Aug 19, 2022
823f6aa
* Add the Shutdown handler in PlatformMgr() * Add to register the shu…
crlonxp Aug 24, 2022
027bb17
Add back DeviceInfoProviderImpl.cpp / DeviceInfoProviderImpl.h to pas…
crlonxp Aug 26, 2022
997a950
Change to comparing SSID with characters, instead of ASCII code (prev…
crlonxp Aug 29, 2022
8974b09
Update version number to: mw320-2.9.10-003
crlonxp Sep 1, 2022
ec8fc82
Update README.md
nxptest Sep 1, 2022
0b9aa9d
Correct the printed Rendzvous Information (QR-code, Manual code) from…
crlonxp Sep 1, 2022
435c057
Add the function to change the pincode of mw320: Usage: > pincode [pi…
crlonxp Sep 1, 2022
310e975
Update version number to: mw320-2.9.10-004
crlonxp Sep 1, 2022
e284f78
Limit the maximum supported fabric number == 5
crlonxp Sep 13, 2022
a4c84f4
Add a shell command to save the ssid / password of the default ap
crlonxp Sep 13, 2022
d26a528
Put manual_control implementation into a compile option controlled
crlonxp Sep 16, 2022
3d02525
Add to dump progressing message on mw320
crlonxp Sep 16, 2022
e116690
Update version number to: mw320-2.9.10-005
crlonxp Sep 16, 2022
aa8c95c
Add to support reading the manufacture data from a partition.
crlonxp Sep 23, 2022
d130bb3
Add to support save/get BootReason Verify: step#5 of TC-DGGEN-2.2
crlonxp Sep 26, 2022
d010bd7
Add 2 console commands: * wlan-stat: Show the current dut status > wl…
crlonxp Sep 28, 2022
c12dbb2
Restyled by whitespace
restyled-commits Sep 28, 2022
ee7b2f9
Restyled by clang-format
restyled-commits Sep 28, 2022
f8e2ff3
Restyled by gn
restyled-commits Sep 28, 2022
c8a8ba6
Disable the chip_detail_logging
crlonxp Sep 28, 2022
0fd430d
Add a building option, wifi_conn_abort_support, to make it configurable
crlonxp Sep 28, 2022
69a7e8f
Restyled by gn
restyled-commits Sep 28, 2022
6b26e45
update submodule
crlonxp Sep 29, 2022
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
Prev Previous commit
Next Next commit
Add to save the information of the last connected AP
Signed-off-by: Chin-Ran Lo <chin-ran.lo@nxp.com>
  • Loading branch information
crlonxp committed Sep 28, 2022
commit 0bc7eb36e059711f7f7ad820c210ad4c47ad7aed
80 changes: 74 additions & 6 deletions examples/all-clusters-app/nxp/mw320/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ extern "C" {
******************************************************************************/
#define APP_AES AES
#define CONNECTION_INFO_FILENAME "connection_info.dat"
#define SSID_FNAME "ssid_fname"
#define PSK_FNAME "psk_fname"

enum
{
MCUXPRESSO_WIFI_CLI,
Expand Down Expand Up @@ -280,6 +283,9 @@ bool is_connected = false;
/*******************************************************************************
* Prototypes
******************************************************************************/
static void save_network(char* ssid, char* pwd);
static void load_network(char* ssid, char* pwd);

/*
static void saveProfile(int argc, char **argv);
static void loadProfile(int argc, char **argv);
Expand Down Expand Up @@ -328,6 +334,56 @@ static void APP_AES_Unlock(void)
xSemaphoreGiveRecursive(aesLock);
}

static void save_network(char* ssid, char* pwd)
{
int ret;

ret = save_wifi_network((char *)SSID_FNAME, (uint8_t*)ssid, strlen(ssid)+1);
if (ret != WM_SUCCESS)
{
PRINTF("Error: write ssid to flash failed\r\n");
}

ret = save_wifi_network((char *)PSK_FNAME, (uint8_t*)pwd, strlen(pwd)+1);
if (ret != WM_SUCCESS)
{
PRINTF("Error: write psk to flash failed\r\n");
}

return;
}

static void load_network(char* ssid, char* pwd)
{
int ret;
unsigned char ssid_buf[IEEEtypes_SSID_SIZE + 1];
unsigned char psk_buf[WLAN_PSK_MAX_LENGTH];
uint32_t len;

len = IEEEtypes_SSID_SIZE + 1;
ret = get_saved_wifi_network((char *)SSID_FNAME, ssid_buf, &len);
if (ret != WM_SUCCESS )
{
PRINTF("Error: Read saved SSID\r\n");
strcpy(ssid, "");
} else {
PRINTF("saved_ssid: [%s]\r\n", ssid_buf);
strcpy(ssid, (const char*)ssid_buf);
}

len = WLAN_PSK_MAX_LENGTH;
ret = get_saved_wifi_network((char *)PSK_FNAME, psk_buf, &len);
if (ret != WM_SUCCESS )
{
PRINTF("Error: Read saved PSK\r\n");
strcpy(pwd, "");
} else {
PRINTF("saved_psk: [%s]\r\n", psk_buf);
strcpy(pwd, (const char*)psk_buf);
}

}

/*
static void saveProfile(int argc, char **argv)
{
Expand Down Expand Up @@ -527,7 +583,7 @@ int wlan_event_callback(enum wlan_event_reason reason, void * data)
switch (reason)
{
case WLAN_REASON_INITIALIZED:
// PRINTF("app_cb: WLAN initialized\r\n");
//PRINTF("app_cb: WLAN initialized\r\n");
#ifdef MCUXPRESSO_WIFI_CLI
ret = wlan_basic_cli_init();
if (ret != WM_SUCCESS)
Expand Down Expand Up @@ -586,14 +642,14 @@ int wlan_event_callback(enum wlan_event_reason reason, void * data)
#endif
break;
case WLAN_REASON_INITIALIZATION_FAILED:
// PRINTF("app_cb: WLAN: initialization failed\r\n");
//PRINTF("app_cb: WLAN: initialization failed\r\n");
break;
case WLAN_REASON_SUCCESS:
// PRINTF("app_cb: WLAN: connected to network\r\n");
//PRINTF("app_cb: WLAN: connected to network\r\n");
ret = wlan_get_address(&addr);
if (ret != WM_SUCCESS)
{
// PRINTF("failed to get IP address\r\n");
//PRINTF("failed to get IP address\r\n");
return 0;
}

Expand All @@ -602,12 +658,13 @@ int wlan_event_callback(enum wlan_event_reason reason, void * data)
ret = wlan_get_current_network(&sta_network);
if (ret != WM_SUCCESS)
{
// PRINTF("Failed to get External AP network\r\n");
//PRINTF("Failed to get External AP network\r\n");
return 0;
}

PRINTF("Connected to following BSS:\r\n");
PRINTF("SSID = [%s], IP = [%s]\r\n", sta_network.ssid, ip);
save_network(sta_network.ssid, sta_network.security.psk);

#ifdef CONFIG_IPV6
{
Expand Down Expand Up @@ -1146,8 +1203,19 @@ void ShellCLIMain(void * pvParameter)

// std::string qrCodeText = createSetupPayload();
// PRINTF("SetupQRCode: [%s]\r\n", qrCodeText.c_str());
{
char def_ssid[IEEEtypes_SSID_SIZE + 1];
char def_psk[WLAN_PSK_MAX_LENGTH];
load_network(def_ssid, def_psk);

ConnectivityMgrImpl().ProvisionWiFiNetwork("nxp_matter", "nxp12345");
if ((strlen(def_ssid)<=0) || (strlen(def_psk)<=0)) {
// No saved connected_ap_info => Using the default ssid/password
strcpy(def_ssid, "nxp_matter");
strcpy(def_psk, "nxp12345");
}
PRINTF("Connecting to [%s, %s] \r\n", def_ssid, def_psk);
ConnectivityMgrImpl().ProvisionWiFiNetwork(def_ssid, def_psk);
}

// Run CHIP servers
run_update_chipsrv(chip_srv_all);
Expand Down