Changeset 549

Show
Ignore:
Timestamp:
04/27/08 16:57:35 (3 weeks ago)
Author:
agr
Message:

fixed sampl bugs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nano-RK/projects/SAMPL/app_pkt_handlers/neighbor_pkt.c

    r548 r549  
    22#include <../include/sampl.h> 
    33#include <neighbor_pkt.h> 
    4 #include <route_table.h> 
    54 
    65#ifdef NANORK  
     
    87#include <nrk_error.h> 
    98#include <debug.h> 
     9#include <neighbor_list.h> 
    1010#else 
    1111#define my_mac 0 
     
    2020NLIST_PKT_T p; 
    2121int8_t i,cnt; 
    22 uint16_t n; 
    2322 
    24   _route_table_ttl_update(); 
    25  
     23  neighbor_list_ttl_update(); 
    2624  cnt=0; 
    2725  i=0; 
    28   while(1) 
     26 
     27  do  
    2928  { 
    3029  p.mac_addr=my_mac; 
    31   i=route_table_get_next_valid_index(0); 
     30  i=neighbor_list_get_next_valid_index(i); 
    3231  if(i==NRK_ERROR) break; 
    33   n=route_table_get_dst_by_index(i); 
     32  p.neighbor_mac=neighbor_list_get_mac(i); 
     33  p.rssi=neighbor_list_get_rssi(i); 
    3434  i++; 
     35  pkt->payload_len = nlist_pkt_add( &p, pkt->payload,cnt); 
    3536  cnt++; 
    36   p.neighbor_mac=route_table_get(n); 
    37   p.rssi=route_table_value_get(n,0); 
    38   pkt->payload_len = nlist_pkt_add( &p, pkt->payload,0); 
    3937  pkt->num_msgs=cnt; 
    40   } 
     38  } while(i!=NRK_ERROR); 
    4139 
    4240  if(cnt==0)  
     
    5452NLIST_PKT_T p1, p2; 
    5553 
    56 if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 
     54//if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 
    5755for(i=0; i<in->num_msgs; i++ ) 
    5856{ 
  • nano-RK/projects/SAMPL/app_pkt_handlers/neighbor_pkt.h

    r548 r549  
    1 #ifndef _STATS_PKT_H 
    2 #define _STATS_PKT_H 
     1#ifndef _NLIST_PKT_H 
     2#define _NLIST_PKT_H 
    33 
    44#ifdef NANORK 
  • nano-RK/projects/SAMPL/app_pkt_handlers/stats_pkt.c

    r548 r549  
    3838STATS_PKT_T p1, p2; 
    3939 
    40 if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 
     40//if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 
    4141for(i=0; i<in->num_msgs; i++ ) 
    4242{ 
  • nano-RK/projects/SAMPL/app_pkt_handlers/trace.c

    r548 r549  
    2424TRACE_PKT_T p1, p2; 
    2525 
    26 if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 
     26// if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 
    2727for(i=0; i<in->num_msgs; i++ ) 
    2828{ 
  • nano-RK/projects/SAMPL/client/aggregate.c

    r548 r549  
    5555        break; 
    5656 
    57   case NEIGHBOR_LIST_PKT: 
     57  case SUBNET_NEIGHBOR_LIST_PKT: 
    5858        nlist_aggregate(us_pkt_in, us_pkt );     
    5959        break; 
  • nano-RK/projects/SAMPL/client/generate.c

    r548 r549  
    8585        break; 
    8686 
    87   case NEIGHBOR_LIST_PKT: 
     87  case SUBNET_NEIGHBOR_LIST_PKT: 
    8888        nlist_generate(us_pkt,ds_pkt); 
    8989        break; 
  • nano-RK/projects/SAMPL/client/main.c

    r548 r549  
    4242#include <nrk_eeprom.h> 
    4343#include <route_table.h> 
     44#include <neighbor_list.h> 
    4445#include <debug.h> 
    4546 
     
    183184  route_table_init(); 
    184185 
    185   // Default neighbor list TTL is 10 minutes 
     186  // initialize the neighbor list  
     187  neighbor_list_init(); 
     188 
     189// Default neighbor list TTL is 10 minutes 
    186190  neighborlist_ttl=600; 
    187191 
     
    353357    } 
    354358    // This is a NEW downstream flood packet 
    355     else if ((ff_state == IDLE_STATE) && (downstream == 1) 
    356         && (ds_pkt.seq_num != last_flood_seq_num) &&  check_subnet(p2p_pkt_in.subnet_mac, my_subnet_mac )==1 ) { 
     359    else if (downstream == 1 &&  check_subnet(p2p_pkt_in.subnet_mac, my_subnet_mac )==1 ) { 
     360        // Got downstream message from someone in subnet, so add to neighbor list  
     361        neighbor_list_add( ds_pkt.last_hop_mac, ds_pkt.rssi, neighborlist_ttl ); 
     362 
     363     // We actually need to service this downstream message 
     364     if(ff_state== IDLE_STATE && ds_pkt.seq_num != last_flood_seq_num) { 
    357365      last_flood_pkt = ds_pkt.pkt_type; 
    358366      last_flood_check_rate = ds_pkt.mac_check_rate; 
     
    363371      // Set the reply address for the gateway (mac=0) to last-hop with no ttl timeout 
    364372        route_table_set( GATEWAY_MAC, ds_pkt.last_hop_mac, 0 ); 
    365         // Add neighbor, with timeout 
    366         route_table_set( ds_pkt.last_hop_mac, ds_pkt.last_hop_mac, neighborlist_ttl ); 
    367         // Insert RSSI from neighbor  
    368         route_table_value_set(ds_pkt.last_hop_mac, 0, ds_pkt.rssi ); 
     373 
    369374 
    370375         if(ds_pkt.ctrl_flags & ENCRYPT != 0) 
     
    391396      } 
    392397    } 
     398  } 
    393399   // Upstream Packet to Aggregate 
    394400    else if (ff_state == FLOOD_ACTIVE_STATE && upstream == 1) { 
    395         // Add neighbor, with timeout 
    396         route_table_set( us_pkt.last_hop_src_mac, us_pkt.last_hop_src_mac, neighborlist_ttl ); 
    397         // Insert RSSI from neighbor  
    398         route_table_value_set(us_pkt.last_hop_src_mac, 0, us_pkt.rssi ); 
     401        // Add neighbor, with timeout 
     402        neighbor_list_add( us_pkt_in.last_hop_src_mac, us_pkt_in.rssi, neighborlist_ttl ); 
    399403 
    400404      if ( us_pkt_in.seq_num == last_flood_seq_num && check_subnet( us_pkt_in.subnet_mac, my_subnet_mac)==1 ) { 
  • nano-RK/projects/SAMPL/client/makefile

    r544 r549  
    4646# For example: 
    4747SRC += $(ROOT_DIR)/src/net/route_table/route_table.c 
     48SRC += $(ROOT_DIR)/src/net/neighbor_list/neighbor_list.c 
    4849SRC += $(ROOT_DIR)/src/net/bmac/bmac.c 
    4950SRC += $(ROOT_DIR)/src/drivers/platform/$(PLATFORM_TYPE)/source/ff_basic_sensor.c 
     
    5657EXTRAINCDIRS += $(ROOT_DIR)/src/net/bmac 
    5758EXTRAINCDIRS += $(ROOT_DIR)/src/net/route_table 
     59EXTRAINCDIRS += $(ROOT_DIR)/src/net/neighbor_list 
    5860 
    5961 
  • nano-RK/projects/SAMPL/client/nrk_cfg.h

    r544 r549  
    4646#define NRK_MAX_RESOURCE_CNT           2 
    4747 
    48 #define ROUTE_TABLE_SIZE        15 
     48#define NEIGHBOR_LIST_SIZE      15 
     49#define ROUTE_TABLE_SIZE        5 
    4950#define ROUTE_TABLE_VALUES      1 
    5051 
  • nano-RK/projects/SAMPL/include/sampl.h

    r548 r549  
    7878 
    7979// PKT Types 
    80 #define  EMPTY_PKT              0x00 
    81 #define  PING_PKT               0x01 
    82 #define  WIRELESS_UPDATE_PKT    0x02 
    83 #define  ACK_PKT                0x03 
    84 #define  ERROR_PKT              0x04 
    85 #define  ROUTE_PKT              0x05 
    86 #define  FF_SENSOR_LONG_PKT     0x06 
    87 #define  FF_SENSOR_SHORT_PKT    0x07 
    88 #define  TRACEROUTE_PKT         0x08 
    89 #define  CONTROL_PKT            0x09 
    90 #define  LED_CONTROL_PKT        0x0A 
    91 #define  DATA_STORAGE_PKT       0X0B 
    92 #define  XMPP_PKT               0X0C 
    93 #define  STATS_PKT              0X0D 
    94 #define  NEIGHBOR_LIST_PKT      0X0E 
    95 #define  UNKNOWN_PKT            0X0F 
     80#define  EMPTY_PKT                      0x00 
     81#define  PING_PKT                       0x01 
     82#define  WIRELESS_UPDATE_PKT            0x02 
     83#define  ACK_PKT                        0x03 
     84#define  ERROR_PKT                      0x04 
     85#define  ROUTE_PKT                      0x05 
     86#define  FF_SENSOR_LONG_PKT             0x06 
     87#define  FF_SENSOR_SHORT_PKT            0x07 
     88#define  TRACEROUTE_PKT                 0x08 
     89#define  CONTROL_PKT                    0x09 
     90#define  LED_CONTROL_PKT                0x0a 
     91#define  DATA_STORAGE_PKT               0X0b 
     92#define  XMPP_PKT                       0X0c 
     93#define  STATS_PKT                      0X0d 
     94#define  SUBNET_NEIGHBOR_LIST_PKT       0X0e 
     95#define  FULL_NEIGHBOR_LIST_PKT         0X0f 
     96#define  UNKNOWN_PKT                    0X10 
    9697// UNKNOWN_PKT used by phoenix etc, do not remove  
    9798 
     
    268269        uint8_t last_hop_mac;    
    269270        uint8_t next_hop_mac;    
     271//      uint8_t reply_checkrate;      
    270272 
    271273 
  • nano-RK/src/net/route_table/route_table.c

    r544 r549  
    2929nrk_time_get(&current_time); 
    3030v=nrk_time_sub(&elapsed_time, current_time, last_time); 
     31last_time.secs=current_time.secs; 
     32last_time.nano_secs=current_time.nano_secs; 
    3133if(v==NRK_OK) 
    3234        { 
     
    150152{ 
    151153uint8_t i; 
    152 if(start_index>=ROUTE_TABLE_VALUES ) return NRK_ERROR; 
     154if(start_index>=ROUTE_TABLE_SIZE) return NRK_ERROR; 
    153155for(i=start_index; i<ROUTE_TABLE_SIZE; i++ ) 
    154156        if((route_table[i].flags & VALID_MASK) !=0 ) 
     
    159161uint16_t route_table_get_dst_by_index(int8_t index) 
    160162{ 
    161 if(index>=ROUTE_TABLE_VALUES ) return 0; 
     163if(index>=ROUTE_TABLE_SIZE ) return 0; 
    162164return route_table[index].dst; 
    163165