ITS Mesh networking mode 2. More...
Go to the source code of this file.
#define ITS2_FLAG_ACK 0x01 |
#define ITS2_FLAG_DELETED 0xff |
#define ITS2_FLAG_NO_ACK 0x02 |
#define ITS2_NO_AVAILABLE_SLOTS 0xff |
#define ITS2_STATUS_QUEUED 0x00 |
#define ITS2_STATUS_TX_QUEUE_FULL 0x01 |
#define ITS2_TX_STATUS_NEXT_HOP_UNKNOWN 0x04 |
#define ITS2_TX_STATUS_NO_ACK 0x02 |
#define ITS2_TX_STATUS_NO_ROUTE 0x01 |
#define ITS2_TX_STATUS_REMOTE_NO_ACK 0x03 |
#define ITS2_TX_STATUS_SUCCESS 0x00 |
#define ITS2_UPDATE_ROUTE_FAIL 0x01 |
#define ITS2_UPDATE_ROUTE_SUCCESS 0x00 |
#define POS_DEST_H 0x0a |
#define POS_DEST_L 0x09 |
#define POS_HOP_COUNT 0x0d |
#define POS_KEY1 0x00 |
#define POS_KEY2 0x01 |
#define POS_LENGTH_HEADER 0x02 |
#define POS_MAX_HOP_COUNT 0x0b |
#define POS_NETWORK_H 0x06 |
#define POS_NETWORK_L 0x05 |
#define POS_NUM_ROUTES 0x0c |
#define POS_PKT_TYPE 0x03 |
#define POS_ROUTE_START 0x0e |
#define POS_SEQUENCE 0x04 |
#define POS_SOURCE_H 0x08 |
#define POS_SOURCE_L 0x07 |
#define QS_ACK_RECEIVED 0x04 |
#define QS_READY_TO_SEND 0x02 |
#define QS_ROUTING_FAILED 0x06 |
#define QS_SENT 0x05 |
#define QS_WAITING_ON_ACK 0x03 |
#define QS_WAITING_ON_LOCAL_ADDR 0x00 |
#define QS_WAITING_ON_NETWORK_ADDR 0x01 |
#define REMOTE_DEVICE 0xffff |
typedef enum _its2_result its2_result |
typedef enum _its2_state its2_state |
enum _its2_result |
RESULT_SUCCESSFUL | |
RESULT_FAILED | |
ITEM_QUEUED | |
QUEUE_FULL | |
ROUTING_TOO_MANY_HOPS | |
NEXT_HOP_NOT_LOCAL |
00150 { RESULT_SUCCESSFUL, RESULT_FAILED, ITEM_QUEUED, QUEUE_FULL, 00151 ROUTING_TOO_MANY_HOPS, NEXT_HOP_NOT_LOCAL };
enum _its2_state |
00154 { 00155 STATE_STARTUP, 00156 STATE_RUNNING, 00157 STATE_SEARCHING, 00158 STATE_ASSOCIATED, 00159 STATE_UNASSOCIATED, 00160 };
void its2_delete_item_from_queue | ( | queued_item * | item | ) |
01025 { 01026 if (item->data_length > 0) { 01027 free((void *)item->data); 01028 } 01029 item->flag = ITS2_FLAG_DELETED; 01030 }
its2_result its2_device_init | ( | uns16 | my_device_id, | |
uns16 | network_id | |||
) |
01136 { 01137 01138 // ITS_EA is set in config.h 01139 01140 // uns8 my_ea[8] = ITS_EA; 01141 01142 debug_str("Device startup\n"); 01143 01144 its_init(); 01145 wpan_init(); 01146 01147 its_set_device_id(my_device_id); 01148 its_set_network_id(network_id); // network id = controller id = pan id in mode 1 01149 01150 mrf24j40_set_pan_id(network_id); 01151 mrf24j40_set_short_address(my_device_id); // same as device id 01152 //mrf24j40_set_extended_address(&my_ea); 01153 01154 state = STATE_UNASSOCIATED; 01155 }
void its2_device_process | ( | ) |
01163 { 01164 01165 uns16 test_tick; 01166 01167 // are we searching? 01168 // has time limit expired? 01169 // go on to next channel 01170 // send its association request to everyone 01171 if (state == STATE_SEARCHING) { 01172 test_tick = tick_get_count(); 01173 if (tick_calc_diff(tick_marker, test_tick) >= 250) { // 250 = 1/4 second 01174 tick_marker = test_tick; 01175 if (channel == 0) { 01176 channel = MRF_FIRST_CHANNEL; 01177 } else { 01178 if (channel == MRF_LAST_CHANNEL) { 01179 // Didn't find the controller 01180 state = STATE_UNASSOCIATED; 01181 debug_str("Didn't find controller\n"); 01182 } else { 01183 channel++; 01184 } 01185 } 01186 // change channel 01187 debug_var("Trying channel ", channel); 01188 debug_nl(); 01189 mrf24j40_set_channel(channel); 01190 // send broadcast association request 01191 its_transmit_to_sa(/* pan id*/ 0xffff, /* sa */ 0xffff, /* dest device */ 0xffff, 01192 ITS_ASSOC_REQ, /* nil data */ 0, /* zero length */ 0); 01193 } // timer for another channel 01194 } // we're searching 01195 01196 }
void its2_device_receive_callback | ( | uns8 * | data, | |
uns8 | data_length | |||
) |
its2_result its2_device_transmit | ( | uns16 | device_id, | |
uns8 * | data, | |||
uns8 | data_length | |||
) |
its2_result its2_find_coordinator | ( | ) |
its2_result its2_forward_routed_packet | ( | its2_packet * | pkt, | |
uns8 * | data, | |||
uns8 | data_length | |||
) |
00653 { 00654 00655 uns8 queue_slot; 00656 queued_item *item; 00657 void *p; 00658 00659 queue_slot = its2_find_free_queue_slot(); 00660 00661 if (queue_slot != ITS2_NO_AVAILABLE_SLOTS) { 00662 00663 debug_var("<Qed>", queue_slot); 00664 debug_str(" data lengh="); 00665 debug_int(data_length); 00666 debug_spc(); 00667 00668 item = &its2_tx_queue[queue_slot]; 00669 item->flag = ITS2_FLAG_NO_ACK; // it's ours! 00670 memcpy(/*dst*/ (void *)&item->packet, // copy it in 00671 /*src*/ (void *)pkt, 00672 /*len*/ 11 + (pkt->num_routes * 2)); 00673 00674 its2_print_packet(&item->packet); 00675 00676 item->packet.hop_count++; 00677 00678 // If hop_count now == num_routes then we are done routing 00679 // and have to go final (local) destination. 00680 // Otherwise, forward to next hop. 00681 00682 if (item->packet.hop_count == item->packet.num_routes) { 00683 // Final desintation 00684 debug_str(" going to final="); 00685 item->dest_its_device_id = item->packet.its_dest_id; 00686 } else { 00687 // Forward to next hop 00688 debug_str(" going to next hop="); 00689 item->dest_its_device_id = item->packet.routers[item->packet.hop_count]; 00690 } 00691 00692 debug_int_hex_16bit(item->dest_its_device_id); 00693 00694 item->sent_count = 0; 00695 item->dest_device_handle = its_get_device_handle(item->dest_its_device_id); 00696 00697 // Do we know about it already? 00698 if (item->dest_device_handle == ITS_DEVICE_NONE) { 00699 // Not in our routing table. Let's see if it's local 00700 debug_str(" unknown. Looking for local. "); 00701 item->status = QS_WAITING_ON_LOCAL_ADDR; 00702 } else { 00703 // Check that it is really local 00704 its_device_info *device_info = its_get_device_info(item->dest_device_handle); 00705 00706 if (device_info->addr.remote.remote_indicator == 0xffff) { 00707 debug_str(" Not local! Abandon ship "); 00708 item->flag = ITS2_FLAG_DELETED; // delete it 00709 return NEXT_HOP_NOT_LOCAL; // let our caller know 00710 // !! we should send something back to originator 00711 // to say that we couldn't route it 00712 } else { 00713 debug_str(" found locally. "); 00714 item->status = QS_READY_TO_SEND; 00715 } 00716 } 00717 item->data_length = 0; 00718 item->data = NULL; 00719 00720 // copy data... 00721 00722 if (data_length > 0) { 00723 p = alloc(data_length); 00724 00725 memcpy(/*dst*/ p, // copy it in 00726 /*src*/ (void *)data, 00727 /*len*/ data_length); 00728 item->data = (uns8*)p; 00729 } 00730 00731 item->data_length = data_length; 00732 00733 return ITEM_QUEUED; 00734 } else { 00735 return QUEUE_FULL; 00736 } 00737 00738 }
void its2_print_packet | ( | its2_packet * | pkt | ) |
00580 { 00581 00582 debug_str("(pkt type="); 00583 debug_int(pkt->packet_type); 00584 debug_str(" seq="); 00585 debug_int(pkt->sequence); 00586 debug_str(" net="); 00587 debug_int_hex_16bit(pkt->its_network_id); 00588 debug_str(" src="); 00589 debug_int_hex_16bit(pkt->its_source_id); 00590 debug_str(" dst="); 00591 debug_int_hex_16bit(pkt->its_dest_id); 00592 debug_str(" max_hop="); 00593 debug_int(pkt->max_hop_count); 00594 debug_str(" num_rts="); 00595 debug_int(pkt->num_routes); 00596 debug_str(" hop_cnt="); 00597 debug_int(pkt->hop_count); 00598 00599 uns8 count; 00600 debug_str(" Rts="); 00601 for (count = 0; count < pkt->num_routes; count++) { 00602 if (count > ITS2_MAX_HOP_COUNT) { 00603 debug_str(" Too many routes! "); 00604 break; 00605 } else { 00606 debug_putc(' '); 00607 debug_int_hex_16bit(pkt->routers[count]); 00608 } 00609 } 00610 debug_str(") "); 00611 }
void its2_print_queue | ( | ) |
01106 { 01107 01108 uns8 count; 01109 queued_item *item; 01110 01111 debug_nl(); 01112 for (count = 0; count < ITS2_TX_QUEUE_SIZE; count++) { 01113 item = &its2_tx_queue[count]; 01114 if (item->flag != ITS2_FLAG_DELETED) { 01115 debug_var("Q:",count); 01116 debug_var(" FL:", item->flag); 01117 debug_var(" SRC:", item->packet.its_source_id); 01118 debug_var(" DST:", item->packet.its_dest_id); 01119 debug_var(" STAT:", item->status); 01120 debug_var(" SENT:", item->sent_count); 01121 debug_var(" TICK:", item->tick_sent); 01122 debug_nl(); 01123 } 01124 } 01125 debug_var("Current tick", tick_get_count()); 01126 debug_nl(); 01127 }
void its2_process_tx_queue | ( | ) |
00904 { 00905 00906 uns16 current_tick; 00907 uns8 count; 00908 queued_item *item; 00909 uns8 flag; 00910 uns8 status; 00911 uns16 my_id; 00912 //debug_str("\n[PQ]\n"); 00913 00914 current_tick = tick_get_count(); 00915 my_id = its_get_device_id(); 00916 00917 //clear_bit(intcon3, INT1IE); // disable int1 00918 00919 00920 for (count = 0; count < ITS2_TX_QUEUE_SIZE; count++) { // search for a packet 00921 item = &its2_tx_queue[count]; // grab item to save code 00922 flag = item->flag; 00923 status = item->status; 00924 if (flag == ITS2_FLAG_DELETED) { 00925 continue; 00926 } 00927 //debug_var("\nQ-", count); 00928 if (status == QS_WAITING_ON_LOCAL_ADDR) { 00929 if (item->sent_count == ITS2_SEND_MAX_TRIES) { // Sent too many times 00930 if (item->packet.its_source_id == my_id) { // from me? 00931 debug_str(" Tried local, now time for net search"); 00932 item->sent_count = 0; 00933 item->status = QS_WAITING_ON_NETWORK_ADDR; 00934 } else { // Must have been a network route 00935 // but we failed to find the next hop locally 00936 // !! Should return something here to sender 00937 debug_str("Next hop not available locally. Giving up."); 00938 its2_transmit_status_callback(&item->packet, ITS2_TX_STATUS_NEXT_HOP_UNKNOWN); 00939 its2_delete_item_from_queue(item); 00940 } 00941 } else if ((item->sent_count == 0) || (tick_calc_diff(item->tick_sent, current_tick) 00942 > ITS2_RESEND_TICK_DELAY)) { 00943 00944 debug_str(" REQ local address for q "); 00945 debug_int(count); 00946 debug_str(" dev "); 00947 debug_int_hex_16bit(item->dest_its_device_id); 00948 00949 item->tick_sent = current_tick; 00950 item->sent_count++; 00951 its2_request_local_addr(item->dest_its_device_id); 00952 item->tick_sent = current_tick; // set tick count to current 00953 } else { 00954 debug_str(" Local waiting for "); 00955 debug_int(item->tick_sent); 00956 } 00957 } else 00958 if (status == QS_WAITING_ON_NETWORK_ADDR) { 00959 if (item->sent_count == ITS2_SEND_MAX_TRIES) { // Sent too many times 00960 // !! Need to issue callback here 00961 debug_str("No addr. killing"); 00962 its2_transmit_status_callback(&item->packet, ITS2_TX_STATUS_NO_ROUTE); 00963 its2_delete_item_from_queue(item); 00964 } else { 00965 //debug_str("Wait for "); 00966 //debug_int(item->tick_sent); 00967 //debug_str("+ 5000 current="); 00968 //debug_int(current_tick); 00969 if (tick_calc_diff(item->tick_sent, current_tick) 00970 > ITS2_RESEND_TICK_DELAY) { 00971 item->tick_sent = current_tick; 00972 item->sent_count++; 00973 its2_request_net_addr(item->dest_its_device_id); 00974 } 00975 } 00976 } else 00977 if (status == QS_READY_TO_SEND) { 00978 if (!its2_transmitting) { 00979 debug_str("<TX!>"); 00980 its2_transmit(item); 00981 debug_str("<Done>"); 00982 00983 } 00984 } else 00985 if (status == QS_WAITING_ON_ACK) { 00986 if (item->sent_count > ITS2_SEND_MAX_TRIES) { // Sent too many times 00987 // !! give up, go home... FAIL! No address 00988 // issue call back 00989 // kill from queue 00990 debug_str("Too many. killing."); 00991 its2_transmit_status_callback(&item->packet, ITS2_TX_STATUS_NO_ACK); 00992 its2_delete_item_from_queue(item); 00993 } 00994 if (tick_calc_diff(item->tick_sent, current_tick) 00995 > ITS2_RESEND_TICK_DELAY) { 00996 if (!its2_transmitting) { 00997 debug_str("<RETRYTX!>"); 00998 its2_transmit(item); 00999 debug_str("<Done>"); 01000 } 01001 } 01002 } 01003 if (status == QS_ACK_RECEIVED) { 01004 // !! call back here 01005 its2_transmit_status_callback(&item->packet, ITS2_TX_STATUS_SUCCESS); 01006 01007 its2_delete_item_from_queue(item); 01008 } else 01009 if (status == QS_SENT) { 01010 debug_str(" <SENT del> "); 01011 its2_transmit_status_callback(&item->packet, ITS2_TX_STATUS_SUCCESS); 01012 its2_delete_item_from_queue(item); 01013 } else 01014 if (status == QS_ROUTING_FAILED) { 01015 debug_str(" <RFAIL del> "); 01016 its2_transmit_status_callback(&item->packet, ITS2_TX_STATUS_NO_ROUTE); 01017 its2_delete_item_from_queue(item); 01018 } 01019 } 01020 01021 //set_bit(intcon3, INT1IE); // enable int1 01022 01023 }
its2_result its2_rebroadcast_net_discover_req | ( | its2_packet * | pkt | ) |
00613 { 00614 00615 uns8 queue_slot; 00616 queued_item *item; 00617 00618 if (pkt->hop_count == pkt->max_hop_count) { 00619 debug_str("<Can't re-b: max hop count exceeded!>"); 00620 return ROUTING_TOO_MANY_HOPS; 00621 } 00622 queue_slot = its2_find_free_queue_slot(); 00623 if (queue_slot != ITS2_NO_AVAILABLE_SLOTS) { 00624 00625 debug_var("<Qed>", queue_slot); 00626 item = &its2_tx_queue[queue_slot]; 00627 00628 item->flag = ITS2_FLAG_NO_ACK; // it's ours! 00629 memcpy(/*dst*/ (void *)&item->packet, // copy it in 00630 /*src*/ (void *)pkt, 00631 /*len*/ 11 + (pkt->num_routes * 2)); 00632 item->dest_its_device_id = 0xffff; 00633 item->packet.routers[item->packet.hop_count] = its_get_device_id(); 00634 item->packet.hop_count++; 00635 item->packet.num_routes++; 00636 item->sent_count = 0; 00637 item->dest_device_handle = ITS_DEVICE_NONE; // it's a broadcast 00638 item->data_length = 0; 00639 item->data = NULL; 00640 00641 00642 item->status = QS_READY_TO_SEND; 00643 00644 its2_add_to_seen_list(item->packet.its_source_id, item->packet.sequence); 00645 00646 return ITEM_QUEUED; 00647 } else { 00648 return QUEUE_FULL; 00649 } 00650 00651 }
void its2_request_local_addr | ( | uns16 | device_id | ) |
00779 { 00780 its2_router_queue_packet(device_id, ITS_LOCAL_DISCOVER_REQ, NULL, 0, ITS2_FLAG_NO_ACK); 00781 }
void its2_request_net_addr | ( | uns16 | device_id | ) |
00792 { 00793 its2_router_queue_packet(device_id, ITS_NET_DISCOVER_REQ, NULL, 0, ITS2_FLAG_NO_ACK); 00794 }
void its2_respond_local_addr | ( | uns16 | device_id | ) |
00783 { 00784 00785 if ((device_id != 0x0001) || !debug_module) { 00786 its2_router_queue_packet(device_id, ITS_LOCAL_DISCOVER_RES, NULL, 0, ITS2_FLAG_NO_ACK); 00787 } else { 00788 debug_str("IGNORE"); 00789 } 00790 }
void its2_respond_net_addr | ( | uns16 | device_id | ) |
00796 { 00797 its2_router_queue_packet(device_id, ITS_NET_DISCOVER_RES, NULL, 0, ITS2_FLAG_NO_ACK); 00798 }
its2_result its2_router_handle_association | ( | uns16 | pan_id, | |
uns16 | its_device_id | |||
) |
00118 { 00119 // see if this device is in our list, if not, add it 00120 its_device_handle device_handle; 00121 00122 device_handle = its_get_device_handle(its_device_id); 00123 00124 if (device_handle == ITS_DEVICE_NONE) { 00125 // in mode 1 we assume that 00126 device_handle = its_add_local_device(/* device */ its_device_id, pan_id, /* short addr */ its_device_id); 00127 if (device_handle == ITS_DEVICE_NONE) { 00128 // panic! 00129 debug_str("Too many devices! association failed"); 00130 return RESULT_FAILED; 00131 } else { 00132 // send association response 00133 its_transmit_to_handle(device_handle, ITS_ASSOC_RES, /* nil data */ 0, /* zero length */ 0); 00134 return RESULT_SUCCESSFUL; 00135 // although strictly speaking we should wait for the ack... 00136 } 00137 00138 } 00139 }
uns8 its2_router_init | ( | uns16 | my_device_id, | |
uns16 | network_id | |||
) |
00743 { 00744 00745 uns8 lowest_channel_ed; 00746 uns8 count; 00747 00748 //uns8 my_ed[8] = ITS_EA; 00749 00750 its2_seen_index = 0; 00751 00752 for (count=0; count < ITS2_SEEN_LIST_SIZE; count++) { 00753 its2_seen_list[count].its_source_id = 0xffff; 00754 } 00755 00756 for (count = 0; count < ITS2_TX_QUEUE_SIZE; count++) { 00757 its2_tx_queue[count].flag = ITS2_FLAG_DELETED; 00758 } 00759 00760 its_init(); 00761 00762 its_set_device_id(my_device_id); 00763 its_set_network_id(network_id); // network id = controller id = pan id in mode 1 00764 00765 mrf24j40_set_pan_id(network_id); 00766 mrf24j40_set_short_address(my_device_id); // same as device id 00767 //mrf24j40_set_extended_address(&my_ed); 00768 00769 debug_str("Router startup\n"); 00770 00771 debug_var("Chosing channel", 15); 00772 debug_nl(); 00773 00774 // Now set ourselves up on this channel 00775 mrf24j40_set_channel(15); 00776 00777 }
void its2_router_process | ( | ) |
00808 { 00809 00810 turn_off_mrf_interrupts(); 00811 00812 its2_process_tx_queue(); 00813 00814 uns16 test_tick; 00815 test_tick = tick_get_count(); 00816 if (tick_calc_diff(tick_marker, test_tick) >= state_timeout) { 00817 // timeout 00818 } 00819 turn_on_mrf_interrupts(); 00820 00821 }
its2_result its2_router_queue_packet | ( | uns16 | device_id, | |
uns8 | packet_type, | |||
uns8 * | data, | |||
uns8 | data_length, | |||
uns8 | ack | |||
) |
00823 { 00824 00825 // return result - queue handle? 00826 00827 uns8 found; 00828 void *p; 00829 queued_item *item; 00830 uns8 count; 00831 00832 turn_off_mrf_interrupts(); 00833 00834 debug_str("\n[its2_router_queue_packet]\n"); 00835 00836 // find slot 00837 found = 0; 00838 for (count = 0; count < ITS2_TX_QUEUE_SIZE; count++) { 00839 if (its2_tx_queue[count].flag == ITS2_FLAG_DELETED) { 00840 found = 1; 00841 break; 00842 } 00843 } 00844 if (found) { 00845 debug_var("Qed: ", count); 00846 item = &its2_tx_queue[count]; 00847 item->flag = ack; // it's ours! 00848 item->sent_count = 0; 00849 00850 //item->packet.key_1 = 'I'; 00851 //item->packet.key_2 = 'T'; 00852 // item->length_header; // unknown as yet 00853 item->packet.packet_type = packet_type; 00854 item->packet.sequence = its_get_next_sequence(); 00855 item->packet.its_network_id = its_get_network_id(); 00856 item->packet.its_source_id = its_get_device_id(); 00857 item->packet.its_dest_id = device_id; 00858 if ((packet_type == ITS_LOCAL_DISCOVER_REQ) || 00859 (packet_type == ITS_NET_DISCOVER_REQ)) { 00860 item->dest_its_device_id = 0xffff; 00861 } else { 00862 item->dest_its_device_id = device_id; 00863 } 00864 item->packet.max_hop_count = ITS2_MAX_HOP_COUNT; 00865 item->packet.hop_count = 0; 00866 // item->packet.num_routes; 00867 00868 // uns16 routers[5]; 00869 // create some memory to whack the data in 00870 if (data_length > 0) { 00871 p = alloc(data_length); 00872 00873 memcpy(/*dst*/ p, // copy it in 00874 /*src*/ (void *)data, 00875 /*len*/ data_length); 00876 item->data = (uns8*)p; 00877 } 00878 00879 item->data_length = data_length; 00880 00881 // Here we will update the route and also set 00882 // dest_device_handle (which may not be the same as the 00883 // eventual destination, since we may be going through 00884 // other hops or doing a broadcast) 00885 uns8 routing_result = its2_update_route(item); 00886 00887 turn_on_mrf_interrupts(); 00888 00889 if (routing_result == ITS2_UPDATE_ROUTE_FAIL) { 00890 debug_str("RoUtE fail"); 00891 return ROUTING_TOO_MANY_HOPS; 00892 } else { 00893 debug_str("qdone "); 00894 return ITEM_QUEUED; 00895 } 00896 } else { 00897 turn_on_mrf_interrupts(); 00898 debug_str(" Full! "); 00899 return QUEUE_FULL; 00900 } 00901 }
void its2_router_receive_callback | ( | uns16 | device_id, | |
uns8 * | data, | |||
uns8 | data_length | |||
) |
void its2_setup_io | ( | ) |
void its2_transmit | ( | queued_item * | item | ) |
01035 { 01036 01037 uns8 buffer[50]; 01038 uns8 count; 01039 uns8 index; 01040 its_device_info *device_info; 01041 01042 its2_transmitting = 1; 01043 01044 debug_str(" X: "); 01045 its2_print_packet(&item->packet); 01046 //p = (void *)alloc(item->data_size + ??); 01047 buffer[0] = 'I'; 01048 buffer[1] = 'T'; 01049 memcpy(/* dst */ (void *)&buffer[3], /* src */ (void *)&item->packet, 11 ); 01050 // now need to copy routes 01051 index = 11 + 3; 01052 for (count = 0; count < item->packet.num_routes; count++) { 01053 buffer[index++] = item->packet.routers[count] & 0xff; 01054 buffer[index++] = item->packet.routers[count] >> 8; 01055 } 01056 01057 buffer[2] = index - 3; // update header with length 01058 01059 // now copy data 01060 for (count = 0; count < item->data_length; count++) { 01061 buffer[index++] = item->data[count]; 01062 } 01063 debug_str(" To="); 01064 debug_int_hex_16bit(item->dest_its_device_id); 01065 debug_str(" bytes="); 01066 debug_int(index); 01067 01068 item->sent_count++; 01069 item->tick_sent = tick_get_count(); 01070 if (item->flag == ITS2_FLAG_ACK) { // ack 01071 item->status = QS_WAITING_ON_ACK; 01072 } else { 01073 item->status = QS_SENT; 01074 } 01075 if (item->dest_device_handle != ITS_DEVICE_NONE) { // we have handle 01076 debug_var(" Handle ", item->dest_device_handle); 01077 device_info = its_get_device_info(item->dest_device_handle); 01078 if (device_info != NULL) { 01079 debug_str(" Pan "); 01080 debug_int_hex_16bit(device_info->addr.local.pan_id); 01081 debug_str(" SA "); 01082 debug_int_hex_16bit(device_info->addr.local.short_address); 01083 } else { 01084 debug_str("!!Strange!! - NO DEVICE INFO!!\n"); 01085 } 01086 mrf24j40_transmit_to_short_address(FRAME_TYPE_DATA, device_info->addr.local.pan_id, 01087 device_info->addr.local.short_address, 01088 &buffer, index, MRF_ACK); 01089 debug_str(" Sent bytes "); 01090 debug_int(index); 01091 debug_putc(' '); 01092 } 01093 else { // it's a broadcast 01094 debug_str(" It's a broadcast"); 01095 mrf24j40_transmit_to_short_address(FRAME_TYPE_DATA, 0xffff, 01096 0xffff, &buffer, index, MRF_NO_ACK); 01097 } 01098 01099 }
void its2_transmit_status_callback | ( | its2_packet * | pkt, | |
uns8 | status | |||
) |
bit debug_module |