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

Commit 04c6699

Browse files
Correctly fetch DNS addresses from RX65N cloud kit wifi chip when more than one entry. (#351)
1 parent 7ffb25f commit 04c6699

File tree

6 files changed

+60
-40
lines changed

6 files changed

+60
-40
lines changed

‎Renesas/RX65N_Cloud_Kit/app/rx_networking.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define NETX_PACKET_COUNT 60
1818
#define NETX_PACKET_SIZE 1500
1919
#define NETX_POOL_SIZE ((NETX_PACKET_SIZE + sizeof(NX_PACKET)) * NETX_PACKET_COUNT)
20+
#define NETX_DNS_COUNT 3
2021

2122
#define NETX_IPV4_ADDRESS IP_ADDRESS(0, 0, 0, 0)
2223
#define NETX_IPV4_MASK IP_ADDRESS(255, 255, 255, 0)
@@ -110,30 +111,32 @@ static UINT dhcp_connect()
110111
static UINT dns_connect()
111112
{
112113
UINT status;
113-
uint32_t dns_address_1;
114+
uint32_t dns_address[NETX_DNS_COUNT];
115+
uint32_t dns_address_count = NETX_DNS_COUNT;
114116

115117
printf("\r\nInitializing DNS client\r\n");
116118

117-
if (R_WIFI_SX_ULPGN_GetDnsServerAddress(&dns_address_1) != WIFI_SUCCESS)
119+
if (R_WIFI_SX_ULPGN_GetDnsServerAddress(&dns_address, &dns_address_count) != WIFI_SUCCESS)
118120
{
119121
printf("ERROR: Failed to fetch Wifi DNS\r\n");
120122
return NX_NOT_SUCCESSFUL;
121123
}
122124

123-
// Output DNS Server address
124-
print_address("DNS address", dns_address_1);
125-
126125
if ((status = nx_dns_server_remove_all(&nx_dns_client)))
127126
{
128127
printf("ERROR: nx_dns_server_remove_all (0x%08x)\r\n", status);
129128
return status;
130129
}
131130

132-
// Add an IPv4 server address to the Client list.
133-
if ((status = nx_dns_server_add(&nx_dns_client, dns_address_1)))
131+
for (int i = 0; i < dns_address_count; ++i)
134132
{
135-
printf("ERROR: nx_dns_server_add (0x%08x)\r\n", status);
136-
return status;
133+
print_address("DNS address", dns_address[i]);
134+
135+
if ((status = nx_dns_server_add(&nx_dns_client, dns_address[i])))
136+
{
137+
printf("ERROR: nx_dns_server_add (0x%08x)\r\n", status);
138+
return status;
139+
}
137140
}
138141

139142
printf("SUCCESS: DNS client initialized\r\n");

‎Renesas/RX65N_Cloud_Kit/lib/rx_driver_package/src/r_wifi_sx_ulpgn/r_wifi_sx_ulpgn_config.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* Generated configuration header file - do not edit */
12
/**********************************************************************************************************************
23
* DISCLAIMER
34
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
@@ -38,7 +39,7 @@
3839

3940
#define WIFI_CFG_SCI_CHANNEL (0)
4041

41-
#define WIFI_CFG_SCI_INTERRUPT_LEVEL (4)
42+
#define WIFI_CFG_SCI_INTERRUPT_LEVEL (14)
4243

4344
#define WIFI_CFG_SCI_SECOND_CHANNEL (1)
4445

@@ -56,7 +57,7 @@
5657

5758
#define WIFI_CFG_CREATABLE_SOCKETS (4)
5859

59-
#define WIFI_CFG_SOCKETS_RECEIVE_BUFFER_SIZE (8192)
60+
#define WIFI_CFG_SOCKETS_RECEIVE_BUFFER_SIZE (4096)
6061

6162
#define WIFI_CFG_USE_CALLBACK_FUNCTION (0)
6263

‎Renesas/RX65N_Cloud_Kit/lib/rx_driver_package/src/r_wifi_sx_ulpgn/r_wifi_sx_ulpgn_if.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
/* Driver Version Number. */
4242
#define WIFI_SX_ULPGN_CFG_VERSION_MAJOR (1)
43-
#define WIFI_SX_ULPGN_CFG_VERSION_MINOR (13)
43+
#define WIFI_SX_ULPGN_CFG_VERSION_MINOR (14)
4444

4545
/* Configuration */
4646
#define WIFI_SOCKET_IP_PROTOCOL_TCP (0) // Socket type = TCP
@@ -452,6 +452,6 @@ wifi_err_t R_WIFI_SX_ULPGN_EraseAllServerCertificate (void);
452452
*********************************************************************************************************************/
453453
wifi_err_t R_WIFI_SX_ULPGN_SetCertificateProfile (uint8_t certificate_id, uint32_t ipaddress, char * servername);
454454

455-
wifi_err_t R_WIFI_SX_ULPGN_GetDnsServerAddress(uint32_t *dns_address);
455+
wifi_err_t R_WIFI_SX_ULPGN_GetDnsServerAddress(uint32_t *dns_address, uint32_t*dns_address_count);
456456

457457
#endif /* R_WIFI_SX_ULPGN_CFG_IF_H */

‎Renesas/RX65N_Cloud_Kit/lib/rx_driver_package/src/r_wifi_sx_ulpgn/src/r_wifi_sx_ulpgn_api.c‎

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ wifi_err_t R_WIFI_SX_ULPGN_Scan(wifi_scan_result_t * ap_results, uint32_t max_ne
532532
int32_t i;
533533
static uint8_t retry_max = 3;
534534
static uint8_t ssid_tmp[33];
535+
uint32_t vals[6];
535536

536537
/* Disconnected WiFi module? */
537538
if (MODULE_DISCONNECTED == wifi_system_state_get())
@@ -586,14 +587,21 @@ wifi_err_t R_WIFI_SX_ULPGN_Scan(wifi_scan_result_t * ap_results, uint32_t max_ne
586587

587588
/* bssid */
588589
at_read("bssid = %2x:%2x:%2x:%2x:%2x:%2x\r\n",
589-
&ap_results[i].bssid[0], &ap_results[i].bssid[1], &ap_results[i].bssid[2],
590-
&ap_results[i].bssid[3], &ap_results[i].bssid[4], &ap_results[i].bssid[5]);
590+
&vals[0], &vals[1], &vals[2], &vals[3], &vals[4], &vals[5]);
591+
ap_results[i].bssid[0] = (uint8_t)(vals[0] & 0xff);
592+
ap_results[i].bssid[1] = (uint8_t)(vals[1] & 0xff);
593+
ap_results[i].bssid[2] = (uint8_t)(vals[2] & 0xff);
594+
ap_results[i].bssid[3] = (uint8_t)(vals[3] & 0xff);
595+
ap_results[i].bssid[4] = (uint8_t)(vals[4] & 0xff);
596+
ap_results[i].bssid[5] = (uint8_t)(vals[5] & 0xff);
591597

592598
/* channel */
593-
at_read("channel = %d\r\n", &ap_results[i].channel);
599+
at_read("channel = %d\r\n", &vals[0]);
600+
ap_results[i].channel = (int8_t)(vals[0] & 0xff);
594601

595602
/* indicator */
596-
at_read("indicator = %d\r\n", &ap_results[i].rssi);
603+
at_read("indicator = %d\r\n", &vals[0]);
604+
ap_results[i].rssi = (int8_t)(vals[0] & 0xff);
597605

598606
/* security */
599607
if (0 == strncmp((const char *)at_get_current_line(), "security = NONE!", 16))
@@ -841,6 +849,7 @@ wifi_err_t R_WIFI_SX_ULPGN_GetMacAddress(uint8_t * mac_address)
841849
{
842850
wifi_err_t api_ret = WIFI_SUCCESS;
843851
uint32_t mac[6];
852+
uint32_t i;
844853

845854
/* Disconnected WiFi module? */
846855
if (MODULE_DISCONNECTED == wifi_system_state_get())
@@ -861,17 +870,15 @@ wifi_err_t R_WIFI_SX_ULPGN_GetMacAddress(uint8_t * mac_address)
861870
}
862871

863872
/* Show current Wi-Fi status. */
864-
memset(mac, 0xAA, sizeof(mac));
873+
memset(mac, 0, sizeof(mac));
865874
if (AT_OK == at_exec(g_cmd_port, "ATW\r"))
866875
{
867876
/* Get MAC address */
868877
at_read("Mac Addr = %2x:%2x:%2x:%2x:%2x:%2x\r\n", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
869-
mac_address[0] = mac[0];
870-
mac_address[1] = mac[1];
871-
mac_address[2] = mac[2];
872-
mac_address[3] = mac[3];
873-
mac_address[4] = mac[4];
874-
mac_address[5] = mac[5];
878+
for (i = 0; i < 6; i++)
879+
{
880+
mac_address[i] = (uint8_t)(mac[i] & 0xff);
881+
}
875882
}
876883
else
877884
{
@@ -1678,7 +1685,7 @@ int32_t R_WIFI_SX_ULPGN_GetTcpSocketStatus(uint8_t socket_number)
16781685
int32_t ret = (-1);
16791686
static char sock_status[24];
16801687
static char sock_type[8];
1681-
static uint8_t sock_ver;
1688+
static uint32_t sock_ver;
16821689
uint16_t i;
16831690

16841691
static const uint8_t * p_sock_sts_tbl[ULPGN_SOCKET_STATUS_MAX] =
@@ -2433,6 +2440,7 @@ static int32_t get_server_certificate(wifi_certificate_infomation_t * p_cert)
24332440
{
24342441
uint8_t i;
24352442
int32_t ret = E_FAIL;
2443+
uint32_t num_of_files;
24362444

24372445
/* Initialize */
24382446
memset(p_cert, 0, sizeof(wifi_certificate_infomation_t));
@@ -2441,7 +2449,8 @@ static int32_t get_server_certificate(wifi_certificate_infomation_t * p_cert)
24412449
if (AT_OK == at_exec(g_cmd_port, "ATNSSLCERT=?\r"))
24422450
{
24432451
at_move_to_next_line();
2444-
at_read_wo_prefix("%d\r\n", &p_cert->num_of_files);
2452+
at_read_wo_prefix("%d\r\n", &num_of_files);
2453+
p_cert->num_of_files = (uint8_t)(num_of_files & 0xff);
24452454
for (i = 0; i < p_cert->num_of_files; i++ )
24462455
{
24472456
at_move_to_next_line();
@@ -3146,34 +3155,44 @@ static byteq_err_t wrap_byteq_put(uint8_t sock_idx, uint8_t const byte)
31463155
* End of function wrap_byteq_put
31473156
*********************************************************************************************************************/
31483157

3149-
static uint32_t get_dnsaddr(uint32_t *dns_address)
3158+
static uint32_t get_dnsaddr(uint32_t *dns_address, uint32_t*dns_address_count)
31503159
{
31513160
uint32_t ret;
31523161
uint32_t rslt;
31533162
uint32_t dnsaddr[4];
31543163

3164+
*dns_address = 0;
3165+
memset(dns_address, 0, *dns_address_count * sizeof(uint32_t));
3166+
31553167
/* Perform DNS query. */
31563168
ret = at_exec(g_cmd_port, "ATNDNSSVR=\?\r");
3157-
31583169
if (AT_OK == ret)
31593170
{
31603171
at_move_to_next_line();
31613172
at_read_wo_prefix("%d\r\n", &rslt);
31623173

3163-
/* success? */
3164-
if (1 == rslt)
3165-
{
3174+
// we can only return as many as we have asked for
3175+
if (rslt > *dns_address_count)
3176+
{
3177+
rslt = *dns_address_count;
3178+
}
3179+
3180+
for (uint32_t i = 0; i < rslt; ++i)
3181+
{
31663182
at_move_to_next_line();
31673183
at_read_wo_prefix("%d.%d.%d.%d\r\n", &dnsaddr[0], &dnsaddr[1], &dnsaddr[2], &dnsaddr[3]);
3168-
*dns_address = IPADR_UB_TO_UL(dnsaddr[0], dnsaddr[1], dnsaddr[2], dnsaddr[3]);
3169-
}
3184+
dns_address[i] = IPADR_UB_TO_UL(dnsaddr[0], dnsaddr[1], dnsaddr[2], dnsaddr[3]);
3185+
}
3186+
3187+
// return the number of entries processed
3188+
*dns_address_count = rslt;
31703189
}
31713190

31723191
return ret;
31733192
}
31743193

31753194

3176-
wifi_err_t R_WIFI_SX_ULPGN_GetDnsServerAddress(uint32_t *dns_address)
3195+
wifi_err_t R_WIFI_SX_ULPGN_GetDnsServerAddress(uint32_t *dns_address, uint32_t*dns_address_count)
31773196
{
31783197
wifi_err_t api_ret = WIFI_SUCCESS;
31793198

@@ -3196,7 +3215,7 @@ wifi_err_t R_WIFI_SX_ULPGN_GetDnsServerAddress(uint32_t *dns_address)
31963215
}
31973216

31983217
/* Get IP address */
3199-
if (AT_OK != get_dnsaddr(dns_address))
3218+
if (AT_OK != get_dnsaddr(dns_address, dns_address_count))
32003219
{
32013220
api_ret = WIFI_ERR_MODULE_COM;
32023221
}
@@ -3206,4 +3225,3 @@ wifi_err_t R_WIFI_SX_ULPGN_GetDnsServerAddress(uint32_t *dns_address)
32063225

32073226
return api_ret;
32083227
}
3209-

‎Renesas/RX65N_Cloud_Kit/lib/rx_driver_package/src/r_wifi_sx_ulpgn/src/r_wifi_sx_ulpgn_private.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@
6565
#define CERT_PROFILE_MAX (5) // Number of Certificate profiles
6666
#define CERT_HOSTNAME_MAX (256) // Number of Certificate host name
6767

68-
/* Reduce timeout to 3 seconds which will force an error on socket status check when disconnected */
69-
//#define ATCMD_RESP_TIMEOUT (15000) // Timeout threshold for AT command response (msec)
70-
#define ATCMD_RESP_TIMEOUT (3000) // Timeout threshold for AT command response (msec)
68+
#define ATCMD_RESP_TIMEOUT (15000) // Timeout threshold for AT command response (msec)
7169
#define SX_ULPGN_AT_CMD_BUF_MAX (512)
7270
#define SX_ULPGN_AT_RESP_BUF_MAX (2048)
7371
#define SX_ULPGN_AT_TIMEOUT (10000)

‎tools/get-toolchain-rx.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ echo "`nInstalling prerequisites. Please leave the window open until the install
77

88
$gccrx_path = 'http://gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx'
99
$gccrx_file = 'gcc-8.3.0.202004-GNURX-ELF.exe'
10-
$gccrx_name = 'GCC-RX 8.3.0.20204'
10+
$gccrx_name = 'GCC-RX 8.3.0.202004'
1111
$gccrx_hash = 'C3340B4915208361A33885505CFB89B69E1607A07F89FBF2A79096182D293978'
1212

1313
$cmake_path = 'https://github.com/Kitware/CMake/releases/download/v3.21.4'

0 commit comments

Comments
(0)

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