WIFI_EMAC class renamed to OdinWiFiEMAC, Formatting

Revert "in ODIN emac initialization required before connection"
pull/6847/head
Asif Rizwan 2018-05-18 14:15:52 +05:00 committed by Kevin Bracey
parent 7e4eb5c24b
commit 657ac3f643
20 changed files with 670 additions and 794 deletions

View File

@ -108,9 +108,7 @@ nsapi_error_t EmacTestNetworkStack::add_ethernet_interface(EMAC &emac, bool defa
{
// Test network stack supports only one interface
TEST_ASSERT_MESSAGE(!m_interface, "Only one interface supported!");
#ifdef TARGET_UBLOX_EVK_ODIN_W2
emac_if_init();
#endif
m_interface = &EmacTestNetworkStack::Interface::get_instance();
TEST_ASSERT_MESSAGE(m_interface, "Invalid interface!");

View File

@ -19,27 +19,12 @@
#include "lwip/def.h"
#include "lwip_random.h"
#if defined(DEVICE_TRNG)
#include "hal/trng_api.h"
#endif
#include "randLIB.h"
void lwip_seed_random(void)
{
#if defined(DEVICE_TRNG)
uint32_t result;
size_t olen;
trng_t trng_obj;
trng_init(&trng_obj);
trng_get_bytes(&trng_obj, (uint8_t*)&result, sizeof result, &olen);
trng_free(&trng_obj);
srand(result);
#else
randLIB_seed_random();
#endif
}
void lwip_add_random_seed(uint64_t seed)

View File

@ -12,7 +12,7 @@
#include "cb_otp.h"
#include "cb_main.h"
#define WIFI_EMAC_MTU_SIZE (1500U)
#define OdinWiFiEMAC_MTU_SIZE (1500U)
static const char _ifname[] = "WL0";
cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame);
@ -37,7 +37,7 @@ static const cbWLANTARGET_Callback _wlanTargetCallback =
void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data)
{
WIFI_EMAC &instance = WIFI_EMAC::get_instance();
OdinWiFiEMAC &instance = OdinWiFiEMAC::get_instance();
bool linkUp = false;
bool sendCb = true;
(void)dummy;
@ -65,7 +65,7 @@ void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status,
void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo)
{
WIFI_EMAC &instance = WIFI_EMAC::get_instance();
OdinWiFiEMAC &instance = OdinWiFiEMAC::get_instance();
(void)dummy;
if (instance.emac_link_input_cb) {
@ -75,17 +75,17 @@ void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packet
cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
EMACMemoryManager *mem = OdinWiFiEMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
//emac_mem_buf_t* phead = (emac_mem_buf_t *)frame;
emac_mem_buf_t* pbuf = (emac_mem_buf_t *)frame;
emac_mem_buf_t* phead = static_cast<emac_mem_buf_t *>(frame);
emac_mem_buf_t* pbuf;
uint32_t copySize, bytesCopied = 0, pbufOffset = 0;
MBED_ASSERT(frame != NULL);
MBED_ASSERT(buffer != NULL);
//pbuf = mem->get_next(phead);
pbuf = phead;
while (pbuf != NULL) {
if ((pbufOffset + mem->get_len(pbuf)) >= offsetInFrame) {
copySize = cb_MIN(size, mem->get_len(pbuf) - (offsetInFrame - pbufOffset));
@ -114,17 +114,17 @@ cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataF
cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_t* buffer, uint32_t size, uint32_t offsetInFrame)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
EMACMemoryManager *mem = OdinWiFiEMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
//emac_mem_buf_t* phead = (emac_mem_buf_t *)frame;
emac_mem_buf_t* pbuf = (emac_mem_buf_t *)frame;
emac_mem_buf_t* phead = static_cast<emac_mem_buf_t *>(frame);
emac_mem_buf_t* pbuf;
uint32_t copySize, bytesCopied = 0, pbufOffset = 0;
MBED_ASSERT(frame != NULL);
MBED_ASSERT(buffer != NULL);
//pbuf = mem->get_next(phead);
pbuf = phead;
while (pbuf != NULL) {
if ((pbufOffset + mem->get_len(pbuf)) >= offsetInFrame) {
copySize = cb_MIN(size, mem->get_len(pbuf) - (offsetInFrame - pbufOffset));
@ -153,23 +153,23 @@ cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_
cbWLANTARGET_dataFrame* handleWlanTargetAllocDataFrame(uint32_t size)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
EMACMemoryManager *mem = OdinWiFiEMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
return (cbWLANTARGET_dataFrame*)mem->alloc_pool(size, 0);
}
void handleWlanTargetFreeDataFrame(cbWLANTARGET_dataFrame* frame)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
EMACMemoryManager *mem = OdinWiFiEMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
mem->free((emac_mem_buf_t*)frame);
mem->free(static_cast<emac_mem_buf_t *>(frame));
}
uint32_t handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
EMACMemoryManager *mem = OdinWiFiEMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
return mem->get_total_len((emac_mem_buf_t*)frame);
return mem->get_total_len(static_cast<emac_mem_buf_t *>(frame));
}
uint8_t handleWlanTargetGetDataFrameTID(cbWLANTARGET_dataFrame* frame)
@ -178,7 +178,7 @@ uint8_t handleWlanTargetGetDataFrameTID(cbWLANTARGET_dataFrame* frame)
return (uint8_t)cbWLAN_AC_BE;
}
WIFI_EMAC::WIFI_EMAC()
OdinWiFiEMAC::OdinWiFiEMAC()
{
emac_link_input_cb = NULL;
emac_link_state_cb = NULL;
@ -190,9 +190,9 @@ void send_wlan_packet(void *buf)
cbWLAN_sendPacket(buf);
}
bool WIFI_EMAC::link_out(emac_mem_buf_t *buf)
bool OdinWiFiEMAC::link_out(emac_mem_buf_t *buf)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
EMACMemoryManager *mem = OdinWiFiEMAC::get_instance().memory_manager;
// Break call chain to avoid the driver affecting stack usage for the IP stack thread too much
emac_mem_buf_t *new_buf = mem->alloc_pool(mem->get_total_len(buf), 0);
@ -209,40 +209,40 @@ bool WIFI_EMAC::link_out(emac_mem_buf_t *buf)
return true;
}
bool WIFI_EMAC::power_up()
bool OdinWiFiEMAC::power_up()
{
/* Initialize the hardware */
/* No-op at this stage */
return true;
}
uint32_t WIFI_EMAC::get_mtu_size() const
uint32_t OdinWiFiEMAC::get_mtu_size() const
{
return WIFI_EMAC_MTU_SIZE;
return OdinWiFiEMAC_MTU_SIZE;
}
void WIFI_EMAC::get_ifname(char *name, uint8_t size) const
void OdinWiFiEMAC::get_ifname(char *name, uint8_t size) const
{
memcpy(name, _ifname, (size < sizeof(_ifname)) ? size : sizeof(_ifname));
}
uint8_t WIFI_EMAC::get_hwaddr_size() const
uint8_t OdinWiFiEMAC::get_hwaddr_size() const
{
return sizeof(cbWLAN_MACAddress);
}
bool WIFI_EMAC::get_hwaddr(uint8_t *addr) const
bool OdinWiFiEMAC::get_hwaddr(uint8_t *addr) const
{
cbOTP_read(cbOTP_MAC_WLAN, sizeof(cbWLAN_MACAddress), addr);
return true;
}
void WIFI_EMAC::set_hwaddr(const uint8_t *addr)
void OdinWiFiEMAC::set_hwaddr(const uint8_t *addr)
{
/* No-op at this stage */
}
void WIFI_EMAC::set_link_input_cb(emac_link_input_cb_t input_cb)
void OdinWiFiEMAC::set_link_input_cb(emac_link_input_cb_t input_cb)
{
emac_link_input_cb = input_cb;
@ -251,7 +251,7 @@ void WIFI_EMAC::set_link_input_cb(emac_link_input_cb_t input_cb)
cbMAIN_driverUnlock();
}
void WIFI_EMAC::set_link_state_cb(emac_link_state_change_cb_t state_cb)
void OdinWiFiEMAC::set_link_state_cb(emac_link_state_change_cb_t state_cb)
{
emac_link_state_cb = state_cb;
@ -260,45 +260,39 @@ void WIFI_EMAC::set_link_state_cb(emac_link_state_change_cb_t state_cb)
cbMAIN_driverUnlock();
}
void WIFI_EMAC::power_down()
void OdinWiFiEMAC::power_down()
{
/* No-op at this stage */
}
void WIFI_EMAC::set_memory_manager(EMACMemoryManager &mem_mngr)
void OdinWiFiEMAC::set_memory_manager(EMACMemoryManager &mem_mngr)
{
memory_manager = &mem_mngr;
}
uint32_t WIFI_EMAC::get_align_preference() const
uint32_t OdinWiFiEMAC::get_align_preference() const
{
return 1; // TODO not sure if there is a requirement but don't think so
return 1;
}
void WIFI_EMAC::add_multicast_group(const uint8_t *address)
void OdinWiFiEMAC::add_multicast_group(const uint8_t *address)
{
// TODO anything to do here for WiFi?
}
void WIFI_EMAC::remove_multicast_group(const uint8_t *address)
void OdinWiFiEMAC::remove_multicast_group(const uint8_t *address)
{
// TODO anything to do here for WiFi?
}
void WIFI_EMAC::set_all_multicast(bool all)
void OdinWiFiEMAC::set_all_multicast(bool all)
{
// TODO anything to do here for WiFi?
}
WIFI_EMAC &WIFI_EMAC::get_instance() {
static WIFI_EMAC emac;
OdinWiFiEMAC &OdinWiFiEMAC::get_instance() {
static OdinWiFiEMAC emac;
return emac;
}
// Weak so a module can override
MBED_WEAK EMAC &EMAC::get_default_instance()
{
return WIFI_EMAC::get_instance();
}
#endif // DEVICE_WIFI

View File

@ -9,11 +9,11 @@
#include "cb_wlan_target_data.h"
#include "cb_wlan.h"
class WIFI_EMAC : public EMAC {
class OdinWiFiEMAC : public EMAC {
public:
WIFI_EMAC();
OdinWiFiEMAC();
static WIFI_EMAC &get_instance();
static OdinWiFiEMAC &get_instance();
/**
* Return maximum transmission unit

View File

@ -45,11 +45,9 @@ struct wlan_scan_indication_s;
/** OdinWiFiInterface class
* Implementation of the WiFiInterface for the ODIN-W2 module
*/
#ifdef DEVICE_WIFI_AP
class OdinWiFiInterface : public WiFiInterface, public WiFiSoftAPInterface, public EMACInterface
#else
class OdinWiFiInterface : public WiFiInterface, public EMACInterface
#endif
{
public:
/** OdinWiFiInterface lifetime
@ -140,100 +138,6 @@ public:
*/
virtual nsapi_error_t set_timeout(int ms);
#ifdef DEVICE_WIFI_AP
/** Set IP config for access point
*
* This function has to be called before the access point is started.
*
* @param gateway Null-terminated representation of the local gateway
* @param netmask Null-terminated representation of the network mask
* @return 0 on success, negative error code on failure
*/
//TODO: In previous WiFiInterface.h but not in new WiFiSoftAPInterface
virtual nsapi_error_t set_ap_network(const char *ip_address, const char *netmask, const char *gateway);
/** Set the WiFi network credentials
*
* @param ssid Name of the network to connect to
* @param pass Security passphrase to connect to the network
* @param security Type of encryption for connection
* (defaults to NSAPI_SECURITY_NONE)
* @return 0 on success, or error code on failure
*/
virtual nsapi_error_t set_ap_credentials(const char *ssid, const char *pass = 0,
nsapi_security_t security = NSAPI_SECURITY_NONE);
/** Set the WiFi network channel
*
* @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
* @return 0 on success, or error code on failure
*/
virtual nsapi_error_t set_ap_channel(uint8_t channel);
/** Gets the current number of active connections
*
* @return number of active connections
*/
virtual int get_ap_connection_count();
/** Gets the max supported number of active connections
*
* @return maximum number of active connections
*/
virtual int get_ap_max_connection_count();
/** Enable or disable DHCP on the network access point
*
* Enables DHCP in SoftAP mode. Defaults to enabled unless
* a static IP address has been assigned. Requires that the network is
* service stopped.
*
* @param dhcp True to enable DHCP
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t set_ap_dhcp(bool dhcp);
/** Set the beacon interval.
*
* Note that the value needs to be set before ap_start in order to take effect.
*
* @param interval Beason interval in time units (Default: 100 time units = 102.4 ms)
* @return 0 on success, or error code on failure
*/
virtual nsapi_error_t set_ap_beacon_interval(uint16_t interval);
/** Start the interface
*
* Attempts to serve a WiFi network.
*
* @param ssid Name of the network to connect to
* @param pass Security passphrase to connect to the network
* @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
* @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
* @return 0 on success, or error code on failure
*/
virtual nsapi_error_t ap_start(const char *ssid, const char *pass = 0,
nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0);
/** Start the interface
*
* Attempts to serve a WiFi network. Requires ssid to be set.
* passphrase is optional.
* If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
*
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t ap_start();
/** Stop the interface
*
* @return 0 on success, or error code on failure
*/
virtual nsapi_error_t ap_stop();
#endif
private:
enum OdinWifiState {

View File

@ -186,6 +186,7 @@ typedef cb_int32 (*cbBCM_SetMaxLinksCmd)(cb_uint32 maxLinks);
* @return TRUE if handle is free, FALSE otherwise
*/
typedef cb_boolean (*cbBCM_IsHandleFree)(cbBCM_Handle handle);
/**
* Callback to indicate that remaining buffer size needs to be obtained from
* upper layer. The callback returns remaining buffer size and there is
@ -293,7 +294,6 @@ extern cb_int32 cbBCM_enableServerProfileUuid128(
cbBCM_ConnectionCallback *pConnectionCallback,
cbBCM_ServiceClassEnabled pServiceClassEnabled);
/**
* Registers the server role of the local device. If role is cbBCM_PAN_ROLE_NAP a service
* record will be registred in the local service data base. The local device can only act as a
@ -523,7 +523,7 @@ extern cbBCM_Handle cbBCM_reqConnectUuid(
*
* @param handle Connection handle
* @param accept TRUE to accept the incoming connection.
FALSE to reject.
* FALSE to reject.
* @return If the operation is successful cbBCM_OK is returned.
*/
extern cb_int32 cbBCM_rspConnectUuidCnf(
@ -876,9 +876,3 @@ extern cb_int32 cbBCM_changeConnectionPacketType(
#endif /* _CB_BT_CONN_MAN_H_ */

View File

@ -373,6 +373,7 @@ extern cb_int32 cbBSM_deleteAllBondedDevices(void);
* @return cbBSM_OK.
*/
cb_int32 cbBSM_setStaticLinkKeyNvdsId(cb_int32 nvdsId);
#ifdef __cplusplus
}
#endif

View File

@ -68,6 +68,7 @@ typedef struct
/*===========================================================================
* FUNCTIONS
*=========================================================================*/
/**
* Initialization of Bluetooth serial manager. Called during stack
* initialization. Shall not be called by application.

View File

@ -66,6 +66,7 @@ typedef struct
/*===========================================================================
* FUNCTIONS
*=========================================================================*/
/**
* Initialization of Bluetooth serial manager. Called during stack
* initialization. Shall not be called by application.

View File

@ -86,6 +86,7 @@ extern "C" {
/*===========================================================================
* TYPES
*=========================================================================*/
/**
* Start parameters passed to WLAN driver.
*
@ -140,8 +141,6 @@ typedef struct cbWLAN_WPAPSK {
*/
typedef struct cbWLAN_WPAPSKConnectParameters {
cbWLAN_WPAPSK psk; /**< WPA pre-shared key*/
#if defined(CB_FEATURE_802DOT11W)
#endif
} cbWLAN_WPAPSKConnectParameters;
#if defined(CB_FEATURE_802DOT11R)

View File

@ -235,7 +235,6 @@ struct cb_wlan_configuration* cbTARGET_configuration_create();
cbRTSL_Status cbTARGET_configure(cbTARGET_Handle* hTarget, cbTARGET_ConfigParams parameter, void* value);
/*--------------------------------------------------------------------------
* Constants
*-------------------------------------------------------------------------*/

View File

@ -423,6 +423,7 @@ cb_PACKED_STRUCT_BEGIN(cbWLAN_TimeOutInformation){
cb_uint8 timeOutType;
cb_uint32 value;
} cb_PACKED_STRUCT_END(cbWLAN_TimeOutInformation);
/**
* Description of the Mobility Domain Information Element
*