31#ifndef STATIC_LOCAL_IP
33#define STATIC_LOCAL_IP "192.168.1.1"
37#define STATIC_GATEWAY "192.168.1.1"
41#define STATIC_NETMASK "255.255.255.0"
52#define AP_SSID MorseMicroIoT
58#define SAE_PASSPHRASE 12345678
64#define SECURITY_TYPE MMWLAN_SAE
70#define PMF_MODE MMWLAN_PMF_REQUIRED
92#define S1G_CHANNEL (44)
104#define PRIMARY_BW_MHZ (0)
107#ifndef PRIMARY_1MHZ_CHANNEL_INDEX
109#define PRIMARY_1MHZ_CHANNEL_INDEX (3)
117#define MAX_STAS MMWLAN_DEFAULT_AP_MAX_STAS
121#define _STRINGIFY(x) #x
123#define STRINGIFY(x) _STRINGIFY(x)
140 return "Unknown (disconnected)";
143 return "Authenticated";
152 return "Unrecognized";
231 if (strncmp(
"sae", strval,
sizeof(strval)) == 0)
235 else if (strncmp(
"owe", strval,
sizeof(strval)) == 0)
239 else if (strncmp(
"open", strval,
sizeof(strval)) == 0)
245 MMLOG_APP(
"Invalid value of %s read from config store: %s\n",
255 if (strncmp(
"disabled", strval,
sizeof(strval)) == 0)
260 else if (strncmp(
"required", strval,
sizeof(strval)) == 0)
266 MMLOG_APP(
"Invalid value of %s read from config store: %s\n",
278 int ret = sscanf(strval,
288 for (i = 0; i < 6; i++)
290 if (temp[i] > UINT8_MAX || temp[i] < 0)
293 memset(ap_args->
bssid, 0,
sizeof(ap_args->
bssid));
297 ap_args->
bssid[i] = (uint8_t)temp[i];
305 if (uint32val <= UINT8_MAX)
311 MMLOG_APP(
"%s out of range\n",
"wlan.ap_op_class");
318 if (uint32val <= UINT8_MAX)
324 MMLOG_APP(
"%s out of range\n",
"wlan.ap_s1g_chan_num");
331 if (uint32val <= UINT8_MAX)
337 MMLOG_APP(
"%s out of range\n",
"wlan.ap_pri_bw_mhz");
344 if (uint32val <= UINT8_MAX)
350 MMLOG_APP(
"%s out of range\n",
"wlan.ap_pri_1mhz_chan_idx");
398 uint32_t health_check_min = 0;
436 MMLOG_PRINTF(
"\n\nAP Mode Example (Built " __DATE__
" " __TIME__
")\n\n");
453 MMLOG_APP(
"Error initializing network interface.\n");
478 MMLOG_APP(
"Failed to start AP (status %d)\n", status);
#define PRIMARY_BW_MHZ
Primary Bandwidth to use for AP.
#define SECURITY_TYPE
Security type (.
#define MAX_STAS
The maximum number of stations that can connect to the AP.
void load_mmwlan_ap_args(struct mmwlan_ap_args *ap_args)
Loads the provided structure with initialization parameters read from config store.
static void load_ap_mmipal_init_args(struct mmipal_init_args *args)
Loads the provided structure with initialization parameters read from config store.
#define S1G_CHANNEL
S1G Channel to use for AP.
#define STATIC_NETMASK
Statically configured netmask.
static void load_mmwlan_settings_ap(void)
Loads various WLAN AP specific settings from config store and applies them.
#define AP_SSID
SSID of the AP.
#define PMF_MODE
Protected Management Frames (PMF) mode (.
#define STRINGIFY(x)
Convert the content of the given macro to a string.
#define SAE_PASSPHRASE
Passphrase of the AP (ignored if security type is not SAE).
static void link_status_callback(const struct mmipal_link_status *link_status)
Link status callback.
static char * mmwlan_ap_sta_state_to_str(enum mmwlan_ap_sta_state state)
Function to convert mmwlan_ap_sta_state enumeration to a human readable string.
static void handle_ap_sta_status(const struct mmwlan_ap_sta_status *sta_status, void *arg)
Handler for AP STA Status callback.
#define OP_CLASS
Operating Class to use for AP.
#define PRIMARY_1MHZ_CHANNEL_INDEX
Primary 1 MHz Channel Index to use for AP.
#define STATIC_GATEWAY
Statically configured gateway address.
void app_init(void)
Main entry point to the application.
uint32_t opaque_argument_value
A throw away variable for checking that the opaque argument is correct.
#define STATIC_LOCAL_IP
Statically configured IP address.
int mmconfig_read_string(const char *key, char *buffer, int bufsize)
Returns the persistent store string value identified by the key.
int mmconfig_read_int(const char *key, int *value)
Returns the integer stored in persistent store identified by the key.
int mmconfig_read_bool(const char *key, bool *value)
Returns the boolean value stored in persistent store identified by the key.
int mmconfig_read_uint32(const char *key, uint32_t *value)
Returns the unsigned integer stored in persistent store identified by the key.
@ MMCONFIG_OK
Operation completed successfully.
enum mmipal_status mmipal_init(const struct mmipal_init_args *args)
Initialize the IP stack and enable the MMWLAN interface.
#define MMIPAL_INIT_ARGS_DEFAULT
Default values for mmipal_init_args.
void mmipal_set_link_status_callback(mmipal_link_status_cb_fn_t fn)
Sets the callback function to be invoked on link status changes.
@ MMIPAL_LINK_UP
Link is up.
@ MMIPAL_IP6_DISABLED
Disabled.
@ MMIPAL_SUCCESS
Completed successfully.
@ MMIPAL_STATIC
Static IP address.
#define MMLOG_APP(fmt,...)
Display an APP level log message.
#define MMLOG_PRINTF(...)
Logging printf definition.
#define MM_MAC_ADDR_FMT
Macro for format specifier to print MM_MAC_ADDR_VAL.
#define MM_MAC_ADDR_VAL(value)
Macro for printing a MAC address.
#define MMOSAL_ASSERT(expr)
Assert that the given expression evaluates to true and abort execution if not.
static bool mmosal_safer_strcpy(char *dst, const char *src, size_t size)
A safer version of strncpy.
uint32_t mmosal_get_time_ms(void)
Get the system time in milliseconds.
mmwlan_ap_sta_state
Enumeration of STA states.
#define MMWLAN_AP_ARGS_INIT
Initializer for mmwlan_ap_args.
enum mmwlan_status mmwlan_ap_enable(const struct mmwlan_ap_args *args)
Enable AP mode.
@ MMWLAN_AP_STA_AUTHORIZED
The STA is fully connected and authorized for data transmission.
@ MMWLAN_AP_STA_ASSOCIATED
The STA is associated but not yet authorized for data transmission.
@ MMWLAN_AP_STA_UNKNOWN
The STA is not known.
@ MMWLAN_AP_STA_AUTHENTICATED
The STA is authenticated but not associated.
enum mmwlan_status mmwlan_boot(const struct mmwlan_boot_args *args)
Boot the Morse Micro transceiver and leave it in an idle state.
enum mmwlan_status mmwlan_set_ampdu_enabled(bool ampdu_enabled)
Sets whether or not Aggregated MAC Protocol Data Unit (A-MPDU) support is enabled.
enum mmwlan_status mmwlan_set_sgi_enabled(bool sgi_enabled)
Sets whether or not Short Guard Interval (SGI) support is enabled.
enum mmwlan_status mmwlan_set_health_check_interval(uint32_t min_interval_ms, uint32_t max_interval_ms)
Specify the upper and lower bound for the periodic health check interval.
enum mmwlan_status mmwlan_set_subbands_enabled(bool subbands_enabled)
Sets whether or not sub-band support is enabled for transmit.
enum mmwlan_status mmwlan_set_fragment_threshold(unsigned fragment_threshold)
Set the Fragmentation threshold.
enum mmwlan_status mmwlan_set_rts_threshold(unsigned rts_threshold)
Set the RTS threshold.
void mmwlan_init(void)
Initialize the MMWLAN subsystem.
enum mmwlan_status mmwlan_set_channel_list(const struct mmwlan_s1g_channel_list *channel_list)
Set the list of channels that are supported by the regulatory domain in which the device resides.
enum mmwlan_status mmwlan_set_power_save_mode(enum mmwlan_ps_mode mode)
Sets whether or not the 802.11 power save is enabled.
@ MMWLAN_PS_DISABLED
Power save disabled.
mmwlan_status
Enumeration of status return codes.
@ MMWLAN_SUCCESS
The operation was successful.
@ MMWLAN_PMF_DISABLED
No protected management frames.
@ MMWLAN_PMF_REQUIRED
Protected management frames must be used.
@ MMWLAN_OPEN
Open (no security)
@ MMWLAN_SAE
Simultaneous Authentication of Equals (SAE)
@ MMWLAN_OWE
Opportunistic Wireless Encryption (OWE)
Morse Micro application helper routines for initializing/de-initializing the Wireless LAN interface a...
void app_print_version_info(void)
Prints various version information.
const struct mmwlan_s1g_channel_list * load_channel_list(void)
Looks up country code and returns appropriate channel list.
Initialize arguments structure.
enum mmipal_ip6_addr_mode ip6_mode
IPv6 address allocation mode to use.
mmipal_ip_addr_t gateway_addr
Gateway IP address to use (if mode is MMIPAL_STATIC).
enum mmipal_addr_mode mode
IP address allocation mode to use.
mmipal_ip_addr_t netmask
Netmask to use (if mode is MMIPAL_STATIC).
mmipal_ip_addr_t ip_addr
IP address to use (if mode is MMIPAL_STATIC).
Structure representing the current status of the link.
mmipal_ip_addr_t netmask
Current netmask.
mmipal_ip_addr_t ip_addr
Current IP address.
mmipal_ip_addr_t gateway
Current gateway IP address.
enum mmipal_link_state link_state
State of the link (up/down).
Arguments data structure for mmwlan_ap_enable().
void * sta_status_cb_arg
Optional opaque argument to be passed to sta_status_cb.
uint16_t s1g_chan_num
S1G channel number of the channel to use.
uint8_t pri_1mhz_chan_idx
Index of the primary 1 Mhz channel within the operating channel.
enum mmwlan_pmf_mode pmf_mode
Protected Management Frame mode to use (802.11w)
uint16_t op_class
Operating Class to use (S1G or Global).
uint8_t pri_bw_mhz
Bandwidth to use for the primary channel.
uint8_t max_stas
Maximum number of stations that can connect to the AP simultaneously.
uint16_t ssid_len
Length of the SSID.
uint8_t bssid[MMWLAN_MAC_ADDR_LEN]
Optional BSSID of the AP.
uint8_t ssid[MMWLAN_SSID_MAXLEN]
SSID of the AP.
mmwlan_ap_sta_status_cb_t sta_status_cb
Optional callback to be invoked when the status of a connected STA changes.
char passphrase[MMWLAN_PASSPHRASE_MAXLEN+1]
Passphrase (only used if security_type is MMWLAN_SAE, otherwise ignored.
enum mmwlan_security_type security_type
Type of security to use.
uint16_t passphrase_len
Length of passphrase.
Data structure for communicating STA status information for stations connected to an AP.
uint16_t aid
The AID of the STA.
enum mmwlan_ap_sta_state state
The current state of the STA.
uint8_t mac_addr[MMWLAN_MAC_ADDR_LEN]
The MAC address of the STA.