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
19#ifndef ATWINC15X0_INTERNAL_H
20#define ATWINC15X0_INTERNAL_H
21
22#include <stdbool.h>
23#include <string.h>
24
25#include "driver/include/m2m_types.h"
26#include "atwinc15x0.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
40
44#define ATWINC1510_SCAN_SLOTS_MIN 2
45
49#define ATWINC1510_SCAN_SLOTS_DEF M2M_SCAN_DEFAULT_NUM_SLOTS
50
54#define ATWINC1510_SCAN_SLOTS_MAX 255
55
59#define ATWINC1510_SCAN_SLOT_TIME_MS_MIN 10
60
64#define ATWINC1510_SCAN_SLOT_TIME_MS_DEF M2M_SCAN_DEFAULT_SLOT_TIME
65
69#define ATWINC1510_SCAN_SLOT_TIME_MS_MAX 250
70
74#define ATWINC1510_SCAN_PROBES_NUMOF_DEF M2M_SCAN_DEFAULT_NUM_PROBE
75
79#define ATWINC1510_SCAN_THRESHOLD_DBM_DEF (-99)
80
93
99static inline void _atwinc15x0_set_scanning(atwinc15x0_t *dev) {
100 if (dev->state == ATWINC15X0_STATE_CONNECTED) {
102 }
103 else if (dev->state == ATWINC15X0_STATE_DISCONNECTED) {
105 }
106 else {
107 assert(false);
108 }
109}
110
123
130static inline void _atwinc15x0_set_connecting(atwinc15x0_t *dev) {
131 if (dev->state == ATWINC15X0_STATE_CONNECTED) {
133 }
134 else if (dev->state == ATWINC15X0_STATE_DISCONNECTED) {
136 }
137 else {
138 assert(false);
139 }
140}
141
150static inline bool _atwinc15x0_is_disconnecting(const atwinc15x0_t *dev) {
152}
153
161 if (dev->state == ATWINC15X0_STATE_CONNECTED) {
163 }
164}
165
179
192
201
216
225static inline bool _atwinc15x0_is_idle(const atwinc15x0_t *dev) {
226 return dev->state == ATWINC15X0_STATE_CONNECTED ||
228}
229
245
251static inline void _atwinc15x0_set_sleeping(atwinc15x0_t *dev) {
254}
255
263static inline bool _atwinc15x0_is_sleeping(const atwinc15x0_t *dev) {
264 return dev->state == ATWINC15X0_STATE_SLEEP;
265}
266
275static inline void _atwinc15x0_sta_set_current_ssid(atwinc15x0_t *dev, const char *ssid) {
276 (void)dev; (void)ssid;
277#if IS_USED(MODULE_ATWINC15X0_DYNAMIC_CONNECT)
278 strcpy(atwinc15x0->ssid, ssid);
279#endif
280}
281
291static inline const char *_atwinc15x0_sta_get_current_ssid(const atwinc15x0_t *dev) {
292 (void)dev;
293#if IS_USED(MODULE_ATWINC15X0_DYNAMIC_CONNECT)
294 return dev->ssid;
295#endif
296 return NULL;
297}
298
302void atwinc15x0_irq(void);
303
304#ifdef __cplusplus
305}
306#endif
307
308#endif /* ATWINC15X0_INTERNAL_H */
#define assert(cond)
abort the program if assertion is false
Definition assert.h:136
Netdev Driver for the Microchip ATWINC15x0 WiFi Module.
@ ATWINC15X0_STATE_DISCONNECTED_SCANNING
Scanning state when disconnected.
Definition atwinc15x0.h:73
@ ATWINC15X0_STATE_CONNECTED_CONNECTING
Connecting state where disconnect event is not yet received.
Definition atwinc15x0.h:77
@ ATWINC15X0_STATE_DISCONNECTED
Disconnect state.
Definition atwinc15x0.h:72
@ ATWINC15X0_STATE_SLEEP
Sleep state.
Definition atwinc15x0.h:70
@ ATWINC15X0_STATE_CONNECTED
Connected state.
Definition atwinc15x0.h:75
@ ATWINC15X0_STATE_DISCONNECTING
Disconnect received when connected before.
Definition atwinc15x0.h:71
@ ATWINC15X0_STATE_DISCONNECTED_CONNECTING
Connecting state where disconnected before.
Definition atwinc15x0.h:74
@ ATWINC15X0_STATE_CONNECTED_SCANNING
Scanning state when connected.
Definition atwinc15x0.h:76
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.
atwinc15x0_t * atwinc15x0
Reference to the single ATWINC15x0 device instance.
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:84
atwinc15x0_state_t state
Device state.
Definition atwinc15x0.h:87
char ssid[WIFI_SSID_LEN_MAX+1]
SSID of current AP.
Definition atwinc15x0.h:90