Loading...
Searching...
No Matches
atwinc15x0_internal.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
20
21#include <stdbool.h>
22#include <string.h>
23
24#include "driver/include/m2m_types.h"
25#include "atwinc15x0.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
39
43#define ATWINC1510_SCAN_SLOTS_MIN 2
44
48#define ATWINC1510_SCAN_SLOTS_DEF M2M_SCAN_DEFAULT_NUM_SLOTS
49
53#define ATWINC1510_SCAN_SLOTS_MAX 255
54
58#define ATWINC1510_SCAN_SLOT_TIME_MS_MIN 10
59
63#define ATWINC1510_SCAN_SLOT_TIME_MS_DEF M2M_SCAN_DEFAULT_SLOT_TIME
64
68#define ATWINC1510_SCAN_SLOT_TIME_MS_MAX 250
69
73#define ATWINC1510_SCAN_PROBES_NUMOF_DEF M2M_SCAN_DEFAULT_NUM_PROBE
74
78#define ATWINC1510_SCAN_THRESHOLD_DBM_DEF (-99)
79
92
98static inline void _atwinc15x0_set_scanning(atwinc15x0_t *dev) {
101 }
102 else if (dev->state == ATWINC15X0_STATE_DISCONNECTED) {
104 }
105 else {
106 assert(false);
107 }
108}
109
122
129static inline void _atwinc15x0_set_connecting(atwinc15x0_t *dev) {
130 if (dev->state == ATWINC15X0_STATE_CONNECTED) {
132 }
133 else if (dev->state == ATWINC15X0_STATE_DISCONNECTED) {
135 }
136 else {
137 assert(false);
138 }
139}
140
149static inline bool _atwinc15x0_is_disconnecting(const atwinc15x0_t *dev) {
151}
152
160 if (dev->state == ATWINC15X0_STATE_CONNECTED) {
162 }
163}
164
178
191
200
215
224static inline bool _atwinc15x0_is_idle(const atwinc15x0_t *dev) {
225 return dev->state == ATWINC15X0_STATE_CONNECTED ||
227}
228
244
250static inline void _atwinc15x0_set_sleeping(atwinc15x0_t *dev) {
253}
254
262static inline bool _atwinc15x0_is_sleeping(const atwinc15x0_t *dev) {
263 return dev->state == ATWINC15X0_STATE_SLEEP;
264}
265
274static inline void _atwinc15x0_sta_set_current_ssid(atwinc15x0_t *dev, const char *ssid) {
275 (void)dev; (void)ssid;
276#if IS_USED(MODULE_ATWINC15X0_DYNAMIC_CONNECT)
277 strcpy(atwinc15x0->ssid, ssid);
278#endif
279}
280
290static inline const char *_atwinc15x0_sta_get_current_ssid(const atwinc15x0_t *dev) {
291 (void)dev;
292#if IS_USED(MODULE_ATWINC15X0_DYNAMIC_CONNECT)
293 return dev->ssid;
294#endif
295 return NULL;
296}
297
301void atwinc15x0_irq(void);
302
303#ifdef __cplusplus
304}
305#endif
306
#define assert(cond)
abort the program if assertion is false
Definition assert.h:146
Netdev Driver for the Microchip ATWINC15x0 WiFi Module.
@ ATWINC15X0_STATE_DISCONNECTED_SCANNING
Scanning state when disconnected.
Definition atwinc15x0.h:72
@ ATWINC15X0_STATE_CONNECTED_CONNECTING
Connecting state where disconnect event is not yet received.
Definition atwinc15x0.h:76
@ ATWINC15X0_STATE_DISCONNECTED
Disconnect state.
Definition atwinc15x0.h:71
@ ATWINC15X0_STATE_SLEEP
Sleep state.
Definition atwinc15x0.h:69
@ ATWINC15X0_STATE_CONNECTED
Connected state.
Definition atwinc15x0.h:74
@ ATWINC15X0_STATE_DISCONNECTING
Disconnect received when connected before.
Definition atwinc15x0.h:70
@ ATWINC15X0_STATE_DISCONNECTED_CONNECTING
Connecting state where disconnected before.
Definition atwinc15x0.h:73
@ ATWINC15X0_STATE_CONNECTED_SCANNING
Scanning state when connected.
Definition atwinc15x0.h:75
struct atwinc15x0 atwinc15x0_t
ATWINC15x0 device descriptor type.
static bool _atwinc15x0_is_idle(const atwinc15x0_t *dev)
Check is dev is currently not performing an asynchronous operation.
static void _atwinc15x0_sta_set_current_ssid(atwinc15x0_t *dev, const char *ssid)
Set member of currently connected AP SSID.
static bool _atwinc15x0_is_sleeping(const atwinc15x0_t *dev)
Check if dev is currently sleeping.
static bool _atwinc15x0_is_scanning(const atwinc15x0_t *dev)
Check if dev is scanning.
static const char * _atwinc15x0_sta_get_current_ssid(const atwinc15x0_t *dev)
Get member of currently connected AP.
void atwinc15x0_irq(void)
ATWINC15x0 device driver ISR.
static void _atwinc15x0_set_connecting(atwinc15x0_t *dev)
Set state to indicate that dev is connecting to an AP.
static void _atwinc15x0_set_sleeping(atwinc15x0_t *dev)
Set state to indicate that dev is sleeping.
static void _atwinc15x0_set_disconnected(atwinc15x0_t *dev)
Set state to indicate that dev is disconnected.
static bool _atwinc15x0_is_connecting(const atwinc15x0_t *dev)
Check if dev is connecting to an AP.
static void _atwinc15x0_set_scanning(atwinc15x0_t *dev)
Set state to indicate that dev is scanning.
static bool _atwinc15x0_is_connected(const atwinc15x0_t *dev)
Check if dev is connected to an AP.
static void _atwinc15x0_set_idle(atwinc15x0_t *dev)
Return from any busy state to corresponding idle state.
static void _atwinc15x0_set_disconnecting(atwinc15x0_t *dev)
Set state to indicate that dev is disconnecting from an AP.
static bool _atwinc15x0_is_disconnecting(const atwinc15x0_t *dev)
Check if dev is disconnecting from an AP.
static void _atwinc15x0_set_connected(atwinc15x0_t *dev)
Set state to indicate that dev is connected to an AP.
static bool _atwinc15x0_is_busy(const atwinc15x0_t *dev)
Check if dev is currently performing an asynchronous operation.
ATWINC15x0 device descriptor type.
Definition atwinc15x0.h:83
atwinc15x0_state_t state
Device state.
Definition atwinc15x0.h:86
char ssid[WIFI_SSID_LEN_MAX+1]
SSID of current AP.
Definition atwinc15x0.h:89