Cellular: Fix BG96 offloaded DNS query for new API

Fixed following issues in BG96 offloaded DNS:
- Fixed mbed-os 6 API change for asynchronous DNS callback. Return value is no longer
  an error value but in success case the amount of DNS records
- Asynchronous request returns request ID instead of NSAPI_ERROR_OK. BG96 supports only
  one asynchronouse DNS query at the time, so ID 1 is used.
- BG96 does not support multi-ip DNS responses, so disabled multi-ip tests
pull/12830/head
Kimmo Vaisanen 2020-04-20 12:35:09 +03:00
parent a79d3ce18d
commit fe98dbef94
5 changed files with 18 additions and 4 deletions

View File

@ -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"
@ -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)

View File

@ -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

View File

@ -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)
@ -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);

View File

@ -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"
@ -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)

View File

@ -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) :
@ -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);
}
@ -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)