Virgil IoT KIT
|
SNAP network interface calls. More...
#include <stdint.h>
#include <virgil/iot/protocols/snap/snap-structs.h>
#include <virgil/iot/status_code/status_code.h>
Go to the source code of this file.
Functions | |
vs_status_e | vs_snap_init (vs_netif_t *default_netif, const vs_device_manufacture_id_t manufacturer_id, const vs_device_type_t device_type, const vs_device_serial_t device_serial, uint32_t device_roles) |
Init SNAP. More... | |
vs_status_e | vs_snap_deinit () |
Destroy SNAP. More... | |
const vs_device_manufacture_id_t * | vs_snap_device_manufacture (void) |
Return current manufacture ID. More... | |
const vs_device_type_t * | vs_snap_device_type (void) |
Return current device type. More... | |
const vs_device_serial_t * | vs_snap_device_serial (void) |
Return current device serial number. More... | |
uint32_t | vs_snap_device_roles (void) |
Return device role. More... | |
const vs_netif_t * | vs_snap_default_netif (void) |
Return device network interface. More... | |
vs_status_e | vs_snap_send (const vs_netif_t *netif, const uint8_t *data, uint16_t data_sz) |
Send SNAP message. More... | |
vs_status_e | vs_snap_register_service (const vs_snap_service_t *service) |
Register SNAP service. More... | |
vs_status_e | vs_snap_mac_addr (const vs_netif_t *netif, vs_mac_addr_t *mac_addr) |
MAC address. More... | |
const vs_mac_addr_t * | vs_snap_broadcast_mac (void) |
Return MAC address. More... | |
vs_status_e | vs_snap_send_request (const vs_netif_t *netif, const vs_mac_addr_t *mac, vs_snap_service_id_t service_id, vs_snap_element_t element_id, const uint8_t *data, uint16_t data_sz) |
Prepare and send SNAP message. More... | |
vs_snap_stat_t | vs_snap_get_statistics (void) |
Return SNAP statistics. More... | |
SNAP network interface calls.
Secure Network Adjustable Protocol is used as transport layer for network communication. There are several layers provided by Virgil IoT SDK that use this interface :
User can add his own protocols base on SNAP. It is necessary to provide service callbacks by filling vs_snap_service_t structure and register service by vs_snap_register_service call.
const vs_mac_addr_t* vs_snap_broadcast_mac | ( | void | ) |
Return MAC address.
const vs_netif_t* vs_snap_default_netif | ( | void | ) |
Return device network interface.
vs_status_e vs_snap_deinit | ( | ) |
Destroy SNAP.
Uses deinit call from vs_snap_service_t structure for each SNAP registered service and deinit call from vs_netif_t structure for network interface.
const vs_device_manufacture_id_t* vs_snap_device_manufacture | ( | void | ) |
Return current manufacture ID.
uint32_t vs_snap_device_roles | ( | void | ) |
Return device role.
const vs_device_serial_t* vs_snap_device_serial | ( | void | ) |
Return current device serial number.
const vs_device_type_t* vs_snap_device_type | ( | void | ) |
Return current device type.
vs_snap_stat_t vs_snap_get_statistics | ( | void | ) |
Return SNAP statistics.
vs_status_e vs_snap_init | ( | vs_netif_t * | default_netif, |
const vs_device_manufacture_id_t | manufacturer_id, | ||
const vs_device_type_t | device_type, | ||
const vs_device_serial_t | device_serial, | ||
uint32_t | device_roles | ||
) |
Init SNAP.
Initializes SNAP. Uses init call from vs_netif_t network interface. Must be called prior to any SNAP call.
[in] | default_netif | Default network interface. Must not be NULL. |
[in] | manufacturer_id | Manufacturer ID. |
[in] | device_type | Device type. |
[in] | device_serial | Device serial number. |
[in] | device_roles | Device roles. Mask formed from vs_snap_device_role_e element. |
vs_status_e vs_snap_mac_addr | ( | const vs_netif_t * | netif, |
vs_mac_addr_t * | mac_addr | ||
) |
MAC address.
Returns mac_addr MAC address. Uses mac_addr call from vs_netif_t network interface.
[in] | netif | SNAP service descriptor. Must not be NULL. |
[out] | mac_addr | Buffer to store MAC address. Must not be NULL. |
vs_status_e vs_snap_register_service | ( | const vs_snap_service_t * | service | ) |
Register SNAP service.
Initializes SNAP service.
[in] | service | SNAP service descriptor. Must not be NULL. |
vs_status_e vs_snap_send | ( | const vs_netif_t * | netif, |
const uint8_t * | data, | ||
uint16_t | data_sz | ||
) |
Send SNAP message.
Sends data message data_sz bytes length by using SNAP protocol specified by netif network interface. tx callback from vs_netif_t network interface is used.
[in] | netif | Network interface. If NULL, default network interface specified by default_netif parameter for vs_snap_init call is used. |
[in] | data | Data buffer to be send. Must not be NULL. |
[in] | data_sz | Data size in bytes to be send. Must not be zero. |
vs_status_e vs_snap_send_request | ( | const vs_netif_t * | netif, |
const vs_mac_addr_t * | mac, | ||
vs_snap_service_id_t | service_id, | ||
vs_snap_element_t | element_id, | ||
const uint8_t * | data, | ||
uint16_t | data_sz | ||
) |
Prepare and send SNAP message.
Sends data message data_sz bytes length by using element_ID element of service_id SNAP service to mac device by netif network interface.
[in] | netif | Network interface. If NULL, default network interface specified by default_netif parameter for vs_snap_init call is used. |
[in] | mac | MAC address. If NULL, broadcast MAC address is used. |
[in] | service_id | Service ID registered by vs_snap_register_service call. |
[in] | element_id | Element ID of service_id. |
[in] | data | Data buffer to be send. Must not be NULL. |
[in] | data_sz | Data size in bytes to be send. Must not be zero. |