Skip to content

Cellular: Fix BG96 offloaded DNS query for new API #12830

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

Merged
merged 1 commit into from
Apr 21, 2020
Merged
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
4 changes: 2 additions & 2 deletions TESTS/netsocket/dns/asynchronous_dns_multi_ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

#if defined(MBED_CONF_RTOS_PRESENT)
#if defined(MBED_CONF_RTOS_PRESENT) && !defined(MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES)

#include "mbed.h"
#include "greentea-client/test_env.h"
Expand Down Expand Up @@ -118,4 +118,4 @@ void ASYNCHRONOUS_DNS_MULTI_IP()
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}
#endif // defined(MBED_CONF_RTOS_PRESENT)
#endif // defined(MBED_CONF_RTOS_PRESENT) && !defined(MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES)
3 changes: 3 additions & 0 deletions TESTS/netsocket/dns/dns_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ struct dns_application_data_multi_ip {

extern const char dns_test_hosts[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN];
extern const char dns_test_hosts_second[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN];

#ifndef MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES
extern const char dns_test_hosts_multi_ip[MBED_CONF_APP_DNS_SIMULT_QUERIES][DNS_TEST_HOST_LEN];
#endif

/*
* Utility functions
Expand Down
5 changes: 5 additions & 0 deletions TESTS/netsocket/dns/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ NetworkInterface *net;

const char dns_test_hosts[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN] = MBED_CONF_APP_DNS_TEST_HOSTS;
const char dns_test_hosts_second[MBED_CONF_APP_DNS_TEST_HOSTS_NUM][DNS_TEST_HOST_LEN] = MBED_CONF_APP_DNS_TEST_HOSTS_SECOND;

#ifndef MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES
const char dns_test_hosts_multi_ip[MBED_CONF_APP_DNS_SIMULT_QUERIES][DNS_TEST_HOST_LEN] = MBED_CONF_APP_DNS_TEST_MULTI_IP_HOSTS;
#endif

// Callback used for asynchronous DNS result
void hostbyname_cb(void *data, nsapi_error_t result, SocketAddress *address)
Expand Down Expand Up @@ -221,8 +224,10 @@ Case cases[] = {
Case("SYNCHRONOUS_DNS", SYNCHRONOUS_DNS),
Case("SYNCHRONOUS_DNS_MULTIPLE", SYNCHRONOUS_DNS_MULTIPLE),
Case("SYNCHRONOUS_DNS_INVALID", SYNCHRONOUS_DNS_INVALID),
#ifndef MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES
Case("SYNCHRONOUS_DNS_MULTI_IP", SYNCHRONOUS_DNS_MULTI_IP),
Case("ASYNCHRONOUS_DNS_MULTI_IP", ASYNCHRONOUS_DNS_MULTI_IP),
#endif
};

Specification specification(test_setup, cases, greentea_teardown, greentea_continue_handlers);
Expand Down
4 changes: 4 additions & 0 deletions TESTS/netsocket/dns/synchronous_dns_multi_ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*/

#if !defined(MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES)

#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
Expand Down Expand Up @@ -84,3 +86,5 @@ void SYNCHRONOUS_DNS_MULTI_IP()
TEST_ASSERT_EQUAL(0, result_dns_failure);
TEST_ASSERT_EQUAL(0, result_exp_timeout);
}

#endif // !defined(MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES)
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ static const char BG96_SUPPORTED_CIPHER_SUITE[] = "0xFFFF"; // Support all
// Later can be expanded to support multiple contexts. Modem supports IDs 0-5.
static const int sslctxID = 0;

static const int BG96_ASYNC_DNS_QUERY_ID = 1; // BG96 driver only supports one request, so using id 1

using namespace mbed;

QUECTEL_BG96_CellularStack::QUECTEL_BG96_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
Expand Down Expand Up @@ -191,7 +193,7 @@ void QUECTEL_BG96_CellularStack::urc_qiurc_dnsgip()
}
SocketAddress address;
if (read_dnsgip(address, _dns_version)) {
_dns_callback(NSAPI_ERROR_OK, &address);
_dns_callback(1, &address);
} else {
_dns_callback(NSAPI_ERROR_DNS_FAILURE, NULL);
}
Expand Down Expand Up @@ -496,7 +498,7 @@ nsapi_value_or_error_t QUECTEL_BG96_CellularStack::gethostbyname_async(const cha
_dns_version = version;
}

return _at.unlock_return_error() ? NSAPI_ERROR_DNS_FAILURE : NSAPI_ERROR_OK;
return _at.unlock_return_error() ? NSAPI_ERROR_DNS_FAILURE : BG96_ASYNC_DNS_QUERY_ID;
}

nsapi_error_t QUECTEL_BG96_CellularStack::gethostbyname_async_cancel(int id)
Expand Down