#include <avr/eeprom.h>
#include <inttypes.h>
#include <stddef.h>
#include <string.h>
#include "net/network.h"
#include "net/transport.h"
#include "utils.h"
#include "net.h"
Go to the source code of this file.
Data Structures | |
struct | cache_entry_t |
struct | reply_entry_t |
struct | tsp_int_buf |
Defines | |
#define | TPDU_MASK 0x30 |
#define | SEQU_MASK 0x0f |
#define | TPDU_ACKED_MSG 0x00 |
#define | TPDU_UACKED_MSG 0x01 |
#define | TPDU_ACK 0x02 |
#define | TPDU_REMINDER 0x03 |
Functions | |
net_buf_t * | tsp_ind (uint8_t *buf, uint8_t len, uint8_t session) |
Called from transport layer if a packet arrived. | |
void | tsp_con (uint8_t *buf, uint8_t len) |
Called from transport layer if a reply to a request arrived. | |
void | tsp_con_fin (uint8_t status) |
Called from transport layer if a request was finished. | |
void | net_ind (uint8_t *buf, uint8_t len, const net_ind_t *ind) |
Called from network layer if a packet arrived for us... | |
void | net_con (void) |
Called from network layer if a queued packet was sent. | |
void | tsp_process (void) |
Process waiting packets and schedule them for transmission. | |
void | tsp_check_timeout (void) |
Check transport layer timeouts. | |
int8_t | tsp_requ (net_buf_t *buf, net_addr_t *dest, enum tsp_service_e service) |
Send a packet using a transport layer sevice. | |
uint8_t | tsp_clear_to_send (void) |
Returns a nonzero value if a new packet could be passed to the transport layer. | |
void | tsp_set_segment_size (uint8_t size) |
Set size of segment. | |
uint8_t | tsp_get_segment_size (void) |
Get segment size. | |
void | tsp_set_group_size (uint8_t group, uint8_t size) |
Set size of a group. | |
uint8_t | tsp_get_group_size (uint8_t group) |
Get size of a group. | |
Variables | |
uint8_t ee_group_size[TSP_MAX_GROUPS] | EEPROM |
The transport layer is responsible for reliable packet delivery and to provide a request/response (session) service. For correct function of this layer you have to call some special functions.
Firstly tsp_process(), preferably directly from the main loop. Secondly tsp_check_timeout() at a fixed rate but NOT from a timer interrupt routine. This is because the implementation is not thread-save. Instead call it from the main loop. See the following code to get a idea how to do it:
uint8_t timer_flag; SIGNAL(SIG_OVERFLOW1) { timer_flag++; } void main(void) { ... for (;;) { while (timer_flag > 0) { timer_flag--; tsp_check_timeout(); } tsp_process(); } ... }
Standalone usage
If you use the protocol stack only for communication and not for a home automation system then this is the layer to be called from your application. The usage is straigt forward.
To receive packets provide a non-static function defined as follows:
net_buf_t *tsp_ind(uint8_t *buf, uint8_t len, uint8_t session) { }
You also have to define the following two function:
void tsp_con(uint8_t *buf, uint8_t len) { } void tsp_con_fin(uint8_t status) { }
Definition in file transport.c.
|
Called from network layer if a queued packet was sent. Checks if tsp_con_fin() should be called. Definition at line 380 of file transport.c. References tsp_con_fin(). Referenced by lnk_con(), and net_requ(). |
|
Called from network layer if a packet arrived for us...
Definition at line 296 of file transport.c. References net_addr_t::addr, net_addr_t::format, NAF_GROUP, net_get_local_member_id(), NPDU_SESSION, NPDU_SINGLE, net_ind_t::pdu, net_ind_t::rat, net_ind_t::src, tsp_con(), tsp_con_fin(), and tsp_ind(). Referenced by lnk_ind(). |
|
Check transport layer timeouts. This function must be called at a fixed rate from the main loop.
Definition at line 451 of file transport.c. References NAF_GROUP, and tsp_con_fin(). |
|
Called from transport layer if a reply to a request arrived.
Definition at line 396 of file application.c. Referenced by net_ind(). |
|
Called from transport layer if a request was finished.
Definition at line 417 of file application.c. Referenced by net_con(), net_ind(), and tsp_check_timeout(). |
|
Get size of a group.
Definition at line 597 of file transport.c. |
|
Get segment size.
Definition at line 575 of file transport.c. |
|
Called from transport layer if a packet arrived.
Definition at line 359 of file application.c. Referenced by net_ind(). |
|
Process waiting packets and schedule them for transmission. This function should be called from your main loop.
Definition at line 398 of file transport.c. References net_clear_to_send(), net_requ(), and NPDU_SINGLE. |
|
Send a packet using a transport layer sevice. This function does return without waiting for the packet to be transmitted. Check the return value if the packet was scheduled for transmission.
Definition at line 492 of file transport.c. References AT_LOGIC, NPDU_SESSION, NPDU_SINGLE, NPDU_TRANSACTION, S_ACKED, S_DGRAM, S_REPEATED, and S_REQUEST. Referenced by app_process(). |
|
Set size of a group.
Definition at line 586 of file transport.c. |
|
Set size of segment.
Definition at line 565 of file transport.c. |