Functions | |
its_device_handle | its_add_local_device (uns16 device_id, uns16 pan_id, uns16 short_address) |
its_device_handle | its_add_net_device (uns16 device_id, uns16 previous_hop) |
its_device_handle | its_get_device_handle (uns16 device_id) |
uns16 | its_get_device_id () |
its_device_info * | its_get_device_info (uns8 handle) |
uns16 | its_get_network_id () |
Retrieve the current network ID. | |
uns8 | its_get_next_sequence () |
void | its_init () |
Initialise ITS and lower layers. | |
void | its_print_devices () |
Print devices currently known to this one. | |
void | its_set_device_id (uns16 device_id) |
Set the ITS device ID. | |
void | its_set_network_id (uns16 network_id) |
Set the ITS network ID. | |
void | its_transmit_to_ea (uns8 *dest_ea, uns16 dest_its_device_id, uns8 packet_type, uns8 *data, uns8 data_length) |
void | its_transmit_to_handle (its_device_handle handle, uns8 packet_type, uns8 *data, uns8 data_length) |
void | its_transmit_to_sa (uns16 dest_pan_id, uns16 dest_sa, uns16 dest_device_id, uns8 packet_type, uns8 *data, uns8 data_length) |
Variables | |
uns16 | its_device_id |
its_device_info | its_devices [ITS_MAX_KNOWN_DEVICES] |
uns16 | its_network_id |
uns8 | its_sequence = 0 |
its_device_handle its_add_local_device | ( | uns16 | device_id, | |
uns16 | pan_id, | |||
uns16 | short_address | |||
) |
00127 { 00128 00129 bit found_slot = 0; 00130 debug_str("Adding device_id ("); 00131 debug_int_hex_16bit(device_id); 00132 debug_str(" (pan_id "); 00133 debug_int_hex_16bit(pan_id); 00134 debug_str(" short_addr "); 00135 debug_int_hex_16bit(short_address); 00136 debug_str(")\n"); 00137 00138 for (uns8 count=0; count < ITS_MAX_KNOWN_DEVICES; count++) { 00139 if (its_devices[count].its_device_id == 0xffff) { 00140 found_slot = 1; 00141 break; 00142 } 00143 } 00144 if (found_slot) { 00145 its_devices[count].its_device_id = device_id; 00146 its_devices[count].addr.local.pan_id = pan_id; 00147 its_devices[count].addr.local.short_address = short_address; 00148 } else { 00149 count = ITS_DEVICE_NONE; 00150 } 00151 00152 its_print_devices(); 00153 00154 return count; 00155 00156 }
its_device_handle its_add_net_device | ( | uns16 | device_id, | |
uns16 | previous_hop | |||
) |
00158 { 00159 00160 bit found_slot = 0; 00161 debug_str(" Add "); 00162 debug_int_hex_16bit(device_id); 00163 debug_str(" (via "); 00164 debug_int_hex_16bit(previous_hop); 00165 debug_str(")\n"); 00166 00167 for (uns8 count=0; count < ITS_MAX_KNOWN_DEVICES; count++) { 00168 if (its_devices[count].its_device_id == 0xffff) { 00169 found_slot = 1; 00170 break; 00171 } 00172 } 00173 if (found_slot) { 00174 its_devices[count].its_device_id = device_id; 00175 its_devices[count].addr.remote.remote_indicator = 0xffff; 00176 its_devices[count].addr.remote.prior_device_id = previous_hop; 00177 } else { 00178 count = ITS_DEVICE_NONE; 00179 } 00180 its_print_devices(); 00181 return count; 00182 }
its_device_handle its_get_device_handle | ( | uns16 | device_id | ) |
00108 { 00109 00110 bit found = 0; 00111 if (device_id == 0xffff) { 00112 return ITS_DEVICE_NONE; 00113 } 00114 for (uns8 count=0; count < ITS_MAX_KNOWN_DEVICES; count++) { 00115 if (its_devices[count].its_device_id == device_id) { 00116 found = 1; 00117 break; 00118 } 00119 } 00120 if (found) { 00121 return count; 00122 } else { 00123 return ITS_DEVICE_NONE; 00124 } 00125 }
uns16 its_get_device_id | ( | ) |
its_device_info* its_get_device_info | ( | uns8 | handle | ) |
00100 { 00101 if (handle < ITS_MAX_KNOWN_DEVICES) { 00102 return &its_devices[handle]; 00103 } else { 00104 return NULL; 00105 } 00106 }
uns16 its_get_network_id | ( | ) |
uns8 its_get_next_sequence | ( | ) |
void its_init | ( | ) |
Call before using any ITS functionality
00093 { 00094 for (uns8 count=0; count < ITS_MAX_KNOWN_DEVICES; count++) { 00095 its_devices[count].its_device_id = 0xffff; // 0xffff = blank entry 00096 } 00097 wpan_init(); 00098 }
void its_print_devices | ( | ) |
00051 { 00052 debug_nl(); 00053 for (uns8 count=0; count < ITS_MAX_KNOWN_DEVICES; count++) { 00054 if (its_devices[count].its_device_id != 0xffff) { // 0xffff = blank entry 00055 debug_str(" dev= "); 00056 debug_int_hex_16bit(its_devices[count].its_device_id); 00057 if (its_devices[count].addr.remote.remote_indicator != 0xffff) { 00058 debug_str(" pan= "); 00059 debug_int_hex_16bit(its_devices[count].addr.local.pan_id); 00060 debug_str(" sa= "); 00061 debug_int_hex_16bit(its_devices[count].addr.local.short_address); 00062 } else { 00063 debug_str(" via= "); 00064 debug_int_hex_16bit(its_devices[count].addr.remote.prior_device_id); 00065 } 00066 debug_nl(); 00067 00068 } 00069 } 00070 }
void its_set_device_id | ( | uns16 | device_id | ) |
Set the ITS device ID before sending packets. See also: its_set_network_id(uns16 network_id);
00085 { 00086 its_device_id = device_id; 00087 }
void its_set_network_id | ( | uns16 | network_id | ) |
Set the ITS network ID before sending packets See also: its_set_device_id(uns16 device_id);
00076 { 00077 its_network_id = network_id; 00078 }
void its_transmit_to_ea | ( | uns8 * | dest_ea, | |
uns16 | dest_its_device_id, | |||
uns8 | packet_type, | |||
uns8 * | data, | |||
uns8 | data_length | |||
) |
00232 { 00233 00234 // must do this more efficiently when we have it working!!!! 00235 00236 uns8 buffer[20]; 00237 00238 uns8 count; 00239 00240 // should do some checks on handle to see if its valid, but hey... 00241 00242 buffer[0] = 'I'; 00243 buffer[1] = 'T'; 00244 buffer[2] = 11; // counted by hand from below 00245 buffer[3] = packet_type; 00246 buffer[4] = its_sequence++; 00247 // network 00248 buffer[5] = its_network_id & 0xff; // lsb 00249 buffer[6] = its_network_id >> 8; // msb 00250 // source 00251 buffer[7] = its_device_id & 0xff; // lsb 00252 buffer[8] = its_device_id >> 8; // msb 00253 // dest 00254 00255 buffer[9] = dest_its_device_id & 0xff; // lsb 00256 buffer[10] = dest_its_device_id >> 8; // msb 00257 // routing 00258 // in mode 2 we would go and look up our routing table here 00259 buffer[11] = 1; // max hop count 00260 buffer[12] = 0; // hop count 00261 buffer[13] = 0; // num routes is zero 00262 // so no routes list 00263 buffer[14] = data_length; // length of data 00264 for (count = 0; count < data_length; count++) { 00265 buffer[15+count] = data[count]; 00266 } // copy data in 00267 mrf24j40_transmit_to_extended_address(FRAME_TYPE_DATA, /* pan */ 0xffff, 00268 dest_ea, &buffer, 00269 data_length + 15, MRF_NO_ACK); 00270 }
void its_transmit_to_handle | ( | its_device_handle | handle, | |
uns8 | packet_type, | |||
uns8 * | data, | |||
uns8 | data_length | |||
) |
00185 { 00186 00187 // !! should do some checks on handle to see if its valid, but hey... 00188 00189 its_transmit_to_sa(its_devices[handle].addr.local.pan_id, 00190 its_devices[handle].addr.local.short_address, 00191 its_devices[handle].its_device_id, 00192 packet_type, data, data_length); 00193 }
void its_transmit_to_sa | ( | uns16 | dest_pan_id, | |
uns16 | dest_sa, | |||
uns16 | dest_device_id, | |||
uns8 | packet_type, | |||
uns8 * | data, | |||
uns8 | data_length | |||
) |
00195 { 00196 00197 uns8 buffer[20]; 00198 uns16 temp; 00199 uns8 count; 00200 00201 buffer[0] = 'I'; 00202 buffer[1] = 'T'; 00203 buffer[2] = 11; // counted by hand from below 00204 buffer[3] = packet_type; 00205 buffer[4] = its_sequence++; 00206 // network 00207 buffer[5] = its_network_id & 0xff; // lsb 00208 buffer[6] = its_network_id >> 8; // msb 00209 // source 00210 buffer[7] = its_device_id & 0xff; // lsb 00211 buffer[8] = its_device_id >> 8; // msb 00212 // dest 00213 temp = dest_device_id; 00214 buffer[9] = temp & 0xff; // lsb 00215 buffer[10] = temp >> 8; // msb 00216 // routing 00217 // in mode 2 we would go and look up our routing table here 00218 buffer[11] = 1; // max hop count 00219 buffer[12] = 0; // hop count 00220 buffer[13] = 0; // num routes is zero 00221 // so no routes list 00222 buffer[14] = data_length; // length of data 00223 for (count = 0; count < data_length; count++) { 00224 buffer[15+count] = data[count]; 00225 } // copy data in 00226 mrf24j40_transmit_to_short_address(FRAME_TYPE_DATA, dest_pan_id, 00227 dest_sa, &buffer, 00228 data_length + 15, MRF_ACK); 00229 }
uns16 its_device_id |
its_device_info its_devices[ITS_MAX_KNOWN_DEVICES] |
uns16 its_network_id |
uns8 its_sequence = 0 |