PicoWAN SDK Documentation
mac_interface.h
1 /*
2  * mac_interface - The interface that any MAC needs to implement
3  *
4  * Copyright (c) 2018, Archos S.A.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of Archos nor the names of its contributors may be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
20  * AND EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL ARCHOS S.A. BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef _MAC_INTERFACE_H_
32 #define _MAC_INTERFACE_H_
33 
34 #include <stdint.h>
35 #include "mac.h"
36 
37 typedef struct {
42 
46  void (*mac_deinit)(void);
47 
53  void (*mac_set_device_class)(device_class_t device_class);
54 
58  void (*mac_init_activation_personalization)(uint32_t netid, uint32_t devaddr, uint8_t *nwkskey, uint8_t *appskey);
59 
66  mac_status_t (*mac_init_activation_on_air)(uint8_t *dev_eui, uint8_t *app_eui, uint8_t *app_key);
67 
73  mac_status_t (*mac_send_when_possible)(uint8_t port, uint8_t *payload, uint8_t payload_len, downlink_mode_t dl_mode);
74 
80  mac_status_t (*mac_send_when_possible_confirmed)(uint8_t port, uint8_t *payload, uint8_t payload_len, uint8_t nb_retries,
81  downlink_mode_t dl_mode);
82 
89 
97  uint32_t (*mac_get_device_address)(void);
99 
100 #endif /* _MAC_INTERFACE_H_ */
mac_status_t mac_init_activation_personalization(uint32_t netid, uint32_t devaddr, uint8_t *nwkskey, uint8_t *appskey)
Initiates the Activation By Personalization (ABP). The session keys must be provided.
Definition: mac.c:93
mac_status_t
Definition: mac.h:92
MAC events structure. Used to notify upper layers after each MAC events done.
Definition: mac.h:136
mac_status_t mac_get_device_address(uint32_t *device_address)
Gets device address.
Definition: mac.c:173
downlink_mode_t
Definition: mac.h:46
Definition: mac.h:179
mac_status_t mac_deinit(void)
Deinitializes the MAC.
Definition: mac.c:77
mac_status_t mac_send_when_possible_confirmed(uint8_t port, uint8_t *payload, uint8_t payload_len, uint8_t nb_retries, downlink_mode_t dl_mode)
Sends data with acknowledge.
Definition: mac.c:133
Definition: mac_interface.h:37
Definition: mac.h:167
mac_status_t mac_init(mac_type_t mac, mac_message_callbacks_t *cb, mac_battery_callback_t *battery_cb, mac_flash_callback_t *flash_cbs)
Initializes the MAC.
Definition: mac.c:45
mac_status_t mac_set_device_class(device_class_t device_class)
Sets end-device class. (class A, B or C for LoRaWAN, A or C for PicoWAN)
Definition: mac.c:159
mac_status_t mac_send_when_possible(uint8_t port, uint8_t *payload, uint8_t payload_len, downlink_mode_t dl_mode)
Sends data without acknowledge.
Definition: mac.c:120
mac_status_t mac_init_activation_on_air(uint8_t *dev_eui, uint8_t *app_eui, uint8_t *app_key)
Initiates the Over The Air Activation (OTAA). Sends a request with the device and application EUI...
Definition: mac.c:107
mac_status_t mac_network_available(void)
Reports network availability using callback. It corresponds to the LoRaWAN MAC command Link Check Req...
Definition: mac.c:146
MAC unified API for PicoWAN and LoRaWAN network access.