30#ifndef STATIC_LOCAL_IP
32#define STATIC_LOCAL_IP "192.168.1.1"
36#define STATIC_GATEWAY "192.168.1.1"
40#define STATIC_NETMASK "255.255.255.0"
51#define AP_SSID MorseMicroIoT
57#define SAE_PASSPHRASE 12345678
63#define SECURITY_TYPE MMWLAN_SAE
69#define PMF_MODE MMWLAN_PMF_REQUIRED
91#define S1G_CHANNEL (44)
103#define PRIMARY_BW_MHZ (0)
106#ifndef PRIMARY_1MHZ_CHANNEL_INDEX
108#define PRIMARY_1MHZ_CHANNEL_INDEX (0)
116#define MAX_STAS MMWLAN_DEFAULT_AP_MAX_STAS
120#define _STRINGIFY(x) #x
122#define STRINGIFY(x) _STRINGIFY(x)
141 printf(
"STA status updated\n");
200 if (strncmp(
"sae", strval,
sizeof(strval)) == 0)
204 else if (strncmp(
"owe", strval,
sizeof(strval)) == 0)
208 else if (strncmp(
"open", strval,
sizeof(strval)) == 0)
214 printf(
"Invalid value of %s read from config store: %s\n",
"wlan.security", strval);
222 if (strncmp(
"disabled", strval,
sizeof(strval)) == 0)
224 printf(
"PMF disabled\n");
227 else if (strncmp(
"required", strval,
sizeof(strval)) == 0)
233 printf(
"Invalid value of %s read from config store: %s\n",
"wlan.pmf_mode", strval);
243 int ret = sscanf(strval,
253 for (i = 0; i < 6; i++)
255 if (temp[i] > UINT8_MAX || temp[i] < 0)
258 memset(ap_args->
bssid, 0,
sizeof(ap_args->
bssid));
262 ap_args->
bssid[i] = (uint8_t)temp[i];
270 if (uint32val <= UINT8_MAX)
276 printf(
"%s out of range\n",
"wlan.op_class");
283 if (uint32val <= UINT8_MAX)
289 printf(
"%s out of range\n",
"wlan.s1g_chan_num");
296 if (uint32val <= UINT8_MAX)
302 printf(
"%s out of range\n",
"wlan.pri_bw_mhz");
309 if (uint32val <= UINT8_MAX)
315 printf(
"%s out of range\n",
"wlan.pri_1mhz_chan_idx");
363 uint32_t health_check_min = 0;
384 printf(
"Link is up. Time: %lu ms", time_ms);
385 printf(
", IP: %s", link_status->
ip_addr);
386 printf(
", Netmask: %s", link_status->
netmask);
387 printf(
", Gateway: %s\n", link_status->
gateway);
391 printf(
"Link is down. Time: %lu ms\n", time_ms);
401 printf(
"\n\nAP Mode Example (Built " __DATE__
" " __TIME__
")\n\n");
418 printf(
"Error initializing network interface.\n");
438 printf(
"AP started successfully\n");
442 printf(
"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 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 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.
#define MM_UNUSED(_x)
Casts the given expression to void to avoid "unused" warnings from the compiler.
#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.
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.