remove short addr from packet
This commit is contained in:
parent
716f166dd3
commit
c6012611ba
|
@ -6,10 +6,7 @@
|
||||||
#define MAX_PAYLOAD_SIZE 125
|
#define MAX_PAYLOAD_SIZE 125
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef uint16_t short_addr_t;
|
|
||||||
|
|
||||||
struct packet {
|
struct packet {
|
||||||
short_addr_t addr;
|
|
||||||
uint8_t length; /* does not include FCS checksum */
|
uint8_t length; /* does not include FCS checksum */
|
||||||
volatile struct packet * left;
|
volatile struct packet * left;
|
||||||
volatile struct packet * right;
|
volatile struct packet * right;
|
||||||
|
|
14
tests/per.c
14
tests/per.c
|
@ -44,7 +44,7 @@ uint32_t get_time(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define random_short_addr() (*MACA_RANDOM & ones(sizeof(short_addr_t)*8))
|
#define random_short_addr() (*MACA_RANDOM & ones(sizeof(uint16_t)*8))
|
||||||
|
|
||||||
void build_session_req(volatile packet_t *p) {
|
void build_session_req(volatile packet_t *p) {
|
||||||
static uint8_t count = 0;
|
static uint8_t count = 0;
|
||||||
|
@ -56,7 +56,7 @@ void build_session_req(volatile packet_t *p) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_req(short_addr_t addr __attribute__((unused))) {
|
void session_req(uint16_t addr __attribute__((unused))) {
|
||||||
static volatile int time = 0;
|
static volatile int time = 0;
|
||||||
volatile packet_t *p;
|
volatile packet_t *p;
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ void session_req(short_addr_t addr __attribute__((unused))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session_id_t open_session(short_addr_t addr __attribute((unused))) { return 0; }
|
session_id_t open_session(uint16_t addr __attribute((unused))) { return 0; }
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
uint32_t state;
|
uint32_t state;
|
||||||
volatile packet_t *p;
|
volatile packet_t *p;
|
||||||
session_id_t sesid;
|
session_id_t sesid;
|
||||||
ptype_t type;
|
ptype_t type;
|
||||||
short_addr_t addr, my_addr;
|
uint16_t addr, my_addr;
|
||||||
|
|
||||||
/* trim the reference osc. to 24MHz */
|
/* trim the reference osc. to 24MHz */
|
||||||
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
||||||
|
@ -96,7 +96,7 @@ void main(void) {
|
||||||
|
|
||||||
/* sets up tx_on, should be a board specific item */
|
/* sets up tx_on, should be a board specific item */
|
||||||
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
||||||
*GPIO_PAD_DIR0 = *GPIO_PAD_DIR0 | (1<<(44-32));
|
gpio_pad_dir_set( 1ULL << 44 );
|
||||||
|
|
||||||
print_welcome("Packet error test");
|
print_welcome("Packet error test");
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ void main(void) {
|
||||||
printf("Recv: ");
|
printf("Recv: ");
|
||||||
print_packet(p);
|
print_packet(p);
|
||||||
type = get_packet_type((packet_t *) p);
|
type = get_packet_type((packet_t *) p);
|
||||||
addr = p->addr;
|
addr = 0; /* FIXME */
|
||||||
free_packet(p);
|
free_packet(p);
|
||||||
/* pick a new address if someone else is using ours */
|
/* pick a new address if someone else is using ours */
|
||||||
if(addr == my_addr) {
|
if(addr == my_addr) {
|
||||||
|
@ -121,7 +121,7 @@ void main(void) {
|
||||||
/* check if it's a session request beacon */
|
/* check if it's a session request beacon */
|
||||||
if(type == PACKET_SESS_REQ) {
|
if(type == PACKET_SESS_REQ) {
|
||||||
/* try to start a session */
|
/* try to start a session */
|
||||||
sesid = open_session(p->addr);
|
sesid = open_session(addr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
session_req(my_addr);
|
session_req(my_addr);
|
||||||
|
|
Loading…
Reference in a new issue