Fixed map module references to be uppercase
Fixed map module references to be uppercase

/** /**
* @author Michael Marques <dryerzinia@gmail.com> * @author Michael Marques <dryerzinia@gmail.com>
*/ */
   
/** /**
* Stats the WebPacketRadio main WebApp enabling the user to send and receive * Stats the WebPacketRadio main WebApp enabling the user to send and receive
* AFSK Modulated AX.25 packets through the sound card * AFSK Modulated AX.25 packets through the sound card
* @module Main * @module Main
* @main * @main
*/ */
   
requirejs.config({ requirejs.config({
   
baseUrl: 'js', baseUrl: 'js',
paths: paths:
{ {
config_json: '../config.json' config_json: '../config.json'
} }
   
}); });
   
require( require(
[ [
'map/Map', 'Map/Map',
'map/LatLong', 'Map/LatLong',
'main/UI' 'main/UI'
], ],
function( function(
Map, Map,
LatLong, LatLong,
UI UI
){ ){
   
var map_canvas, map; var map_canvas, map;
   
map_canvas = document.createElement('canvas'); map_canvas = document.createElement('canvas');
   
map_canvas.width = 640; map_canvas.width = 640;
map_canvas.height = 480; map_canvas.height = 480;
   
map = new Map('tile.openstreetmap.org/zoom/x/y.png', ['a', 'b', 'c'], map_canvas, 5, new LatLong(39, -104)); map = new Map('tile.openstreetmap.org/zoom/x/y.png', ['a', 'b', 'c'], map_canvas, 5, new LatLong(39, -104));
   
UI.init(map); UI.init(map);
   
} }
); );
   
define( define(
[ [
'main/Station', 'main/Station',
'main/packet_interface', 'main/packet_interface',
   
'packet/APRSPacket', 'packet/APRSPacket',
   
'map/LatLong' 'Map/LatLong'
], ],
function( function(
Station, Station,
packet_interface, packet_interface,
   
APRSPacket, APRSPacket,
   
LatLong LatLong
){ ){
   
var Location_Manager = {}; var Location_Manager = {};
   
Location_Manager.beacon_status_message = ""; Location_Manager.beacon_status_message = "";
Location_Manager.self_station = undefined; Location_Manager.self_station = undefined;
   
Location_Manager.update_map_position = function(position){ Location_Manager.update_map_position = function(position){
   
var coords = new LatLong(position.coords.latitude, position.coords.longitude); var coords = new LatLong(position.coords.latitude, position.coords.longitude);
sym_name = APRSPacket.SYMBOL_TABLE[Location_Manager.self_station.status.symbol]; sym_name = APRSPacket.SYMBOL_TABLE[Location_Manager.self_station.status.symbol];
   
Location_Manager.self_station.coordinages = coords; Location_Manager.self_station.coordinages = coords;
   
// Set correct Icon for users position // Set correct Icon for users position
Location_Manager.self_station.update_map(sym_name, coords); Location_Manager.self_station.update_map(sym_name, coords);
Location_Manager.self_station.visible = true; Location_Manager.self_station.visible = true;
   
// Update the map to show users new Position // Update the map to show users new Position
packet_interface.map.render(); packet_interface.map.render();
   
}; };
   
Location_Manager.send_beacon = function(){ Location_Manager.send_beacon = function(){
   
console.log("Sending position Beacon: " + Location_Manager.beacon_status_message); console.log("Sending position Beacon: " + Location_Manager.beacon_status_message);
   
}; };
   
return Location_Manager; return Location_Manager;
   
} }
); );
define( define(
[ [
'main/Symbol_Sprite_Sheet', 'main/Symbol_Sprite_Sheet',
'main/Station_Status', 'main/Station_Status',
'map/Location_Conversions', 'Map/Location_Conversions',
'map/LatLong', 'Map/LatLong',
'map/Icon', 'Map/Icon',
'map/Map' 'Map/Map'
], ],
function( function(
Symbol_Sprite_Sheet, Symbol_Sprite_Sheet,
Station_Status, Station_Status,
Location_Conversions, Location_Conversions,
LatLong, LatLong,
Icon, Icon,
Map Map
){ ){
   
var Station = function(callsign, ssid, trail_color){ var Station = function(callsign, ssid, trail_color){
   
this.callsign = callsign; this.callsign = callsign;
this.ssid = ssid; this.ssid = ssid;
   
this.packets = []; this.packets = [];
this.coordinate_list = []; this.coordinate_list = [];
   
this.trail_color = trail_color; this.trail_color = trail_color;
   
this.visible = false; this.visible = false;
   
/** /**
* Information about this station received in packets * Information about this station received in packets
*/ */
this.status = new Station_Status(); this.status = new Station_Status();
   
}; };
   
Station.prototype = new Icon(); Station.prototype = new Icon();
Station.prototype.constructor = Station; Station.prototype.constructor = Station;
Station.superClass = Icon; Station.superClass = Icon;
   
Station.prototype.get_coordinates = function(){ Station.prototype.get_coordinates = function(){
   
if(this.coordinates) if(this.coordinates)
return this.coordinates; return this.coordinates;
else else
return LatLong.NULL; return LatLong.NULL;
   
}; };
   
Station.prototype.add_packet = function(packet, cb){ Station.prototype.add_packet = function(packet, cb){
   
this.packets.push(packet); this.packets.push(packet);
   
// If the packet is mapable put it on the map // If the packet is mapable put it on the map
if(packet.aprs_info){ if(packet.aprs_info){
   
// Update Station status object // Update Station status object
packet.aprs_info.update_status(this.status); packet.aprs_info.update_status(this.status);
   
var coord = packet.aprs_info.coordinates, var coord = packet.aprs_info.coordinates,
sym = packet.get_symbol(); sym = packet.get_symbol();
   
if(coord && sym){ if(coord && sym){
   
if(this.coordinates){ if(this.coordinates){
// Update the coordinates and symbol // Update the coordinates and symbol
if(!this.coordinates.equals(coord)){ if(!this.coordinates.equals(coord)){
this.coordinate_list.push(coord); this.coordinate_list.push(coord);
this.coordinates = coord; this.coordinates = coord;
cb(); cb();
   
} }
// TODO sym bupdate // TODO sym bupdate
} else { } else {
// put the waypoint on the map and refresh the view // put the waypoint on the map and refresh the view
this.update_map(sym, coord, cb); this.update_map(sym, coord, cb);
} }
   
} }
} }
   
}; };
   
Station.prototype.update_map = function(sym, coord, cb){ Station.prototype.update_map = function(sym, coord, cb){
   
this.coordinate_list.push(coord); this.coordinate_list.push(coord);
Icon.call(this, Symbol_Sprite_Sheet.get_sprite(sym + '.gif'), coord, cb); Icon.call(this, Symbol_Sprite_Sheet.get_sprite(sym + '.gif'), coord, cb);
   
}; };
   
Station.prototype.info_string = function(){ Station.prototype.info_string = function(){
   
return this.status.info_string(); return this.status.info_string();
   
}; };
   
Station.prototype.click = function(map){ Station.prototype.click = function(map){
   
if(this.visible && Station.UI_Build_Popup){ if(this.visible && Station.UI_Build_Popup){
   
Station.UI_Build_Popup(this); Station.UI_Build_Popup(this);
   
} }
   
}; };
   
Station.prototype.over = function(x, y, zoom){ Station.prototype.over = function(x, y, zoom){
   
if(this.coordinates == undefined) if(this.coordinates == undefined)
return false; return false;
   
var pos = Location_Conversions.latlong_to_tilexy(this.coordinates, zoom); var pos = Location_Conversions.latlong_to_tilexy(this.coordinates, zoom);
   
if(this.image){ if(this.image){
   
var offx = (this.image.get_width() / 2) / Map.TILE_SIDE_LENGTH, var offx = (this.image.get_width() / 2) / Map.TILE_SIDE_LENGTH,
offy = (this.image.get_height() / 2) / Map.TILE_SIDE_LENGTH; offy = (this.image.get_height() / 2) / Map.TILE_SIDE_LENGTH;
   
if( if(
x > pos.x - offx && x > pos.x - offx &&
x < pos.x + offx && x < pos.x + offx &&
y > pos.y - offy && y > pos.y - offy &&
y < pos.y + offy y < pos.y + offy
){ ){
   
return true; return true;
   
} }
   
} }
   
return false; return false;
   
}; };
   
Station.prototype.render = function(ctx, x, y, zoom){ Station.prototype.render = function(ctx, x, y, zoom){
   
if(this.visible && this.coordinates != undefined){ if(this.visible && this.coordinates != undefined){
   
var pos = Location_Conversions.latlong_to_tilexy(this.coordinates, zoom), var pos = Location_Conversions.latlong_to_tilexy(this.coordinates, zoom),
last = pos, last = pos,
lx = x, lx = x,
ly = y; ly = y;
   
// Draw Lines // Draw Lines
ctx.strokeStyle = this.trail_color; ctx.strokeStyle = this.trail_color;
ctx.lineWidth = 6; ctx.lineWidth = 6;
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(lx, ly); ctx.moveTo(lx, ly);
for(var i = this.coordinate_list.length - 2; i >= 0; i--){ for(var i = this.coordinate_list.length - 2; i >= 0; i--){
   
var c_pos = Location_Conversions.latlong_to_tilexy(this.coordinate_list[i], zoom), var c_pos = Location_Conversions.latlong_to_tilexy(this.coordinate_list[i], zoom),
x2 = x - ((pos.x - c_pos.x) * Map.TILE_SIDE_LENGTH), x2 = x - ((pos.x - c_pos.x) * Map.TILE_SIDE_LENGTH),
y2 = y - ((pos.y - c_pos.y) * Map.TILE_SIDE_LENGTH); y2 = y - ((pos.y - c_pos.y) * Map.TILE_SIDE_LENGTH);
   
ctx.lineTo(x2, y2); ctx.lineTo(x2, y2);
   
last = c_pos; last = c_pos;
lx = x2; lx = x2;
ly = y2; ly = y2;
   
} }
ctx.stroke(); ctx.stroke();
   
last = pos; last = pos;
lx = x; lx = x;
ly = y; ly = y;
   
// Draw Dots // Draw Dots
ctx.fillStyle = 'rgb(255, 0, 0)'; ctx.fillStyle = 'rgb(255, 0, 0)';
for(var i = this.coordinate_list.length - 2; i >= 0; i--){ for(var i = this.coordinate_list.length - 2; i >= 0; i--){
   
var c_pos = Location_Conversions.latlong_to_tilexy(this.coordinate_list[i], zoom), var c_pos = Location_Conversions.latlong_to_tilexy(this.coordinate_list[i], zoom),
x2 = x - ((pos.x - c_pos.x) * Map.TILE_SIDE_LENGTH), x2 = x - ((pos.x - c_pos.x) * Map.TILE_SIDE_LENGTH),
y2 = y - ((pos.y - c_pos.y) * Map.TILE_SIDE_LENGTH); y2 = y - ((pos.y - c_pos.y) * Map.TILE_SIDE_LENGTH);
   
ctx.beginPath(); ctx.beginPath();
ctx.arc(x2, y2, 3, 0, 2*Math.PI); ctx.arc(x2, y2, 3, 0, 2*Math.PI);
ctx.fill(); ctx.fill();
   
last = c_pos; last = c_pos;
lx = x2; lx = x2;
ly = y2; ly = y2;
   
} }
   
// Draw Icon // Draw Icon
var rot = Math.PI / 2; var rot = Math.PI / 2;
if(this.packets[this.packets.length - 1] && this.packets[this.packets.length - 1].aprs_info && this.packets[this.packets.length - 1].aprs_info.heading){ if(this.packets[this.packets.length - 1] && this.packets[this.packets.length - 1].aprs_info && this.packets[this.packets.length - 1].aprs_info.heading){
rot = this.packets[this.packets.length - 1].aprs_info.heading * Math.PI / 180; rot = this.packets[this.packets.length - 1].aprs_info.heading * Math.PI / 180;
} }
   
Station.superClass.prototype.render.call(this, ctx, x, y, zoom, rot); Station.superClass.prototype.render.call(this, ctx, x, y, zoom, rot);
   
} }
   
}; };
   
return Station; return Station;
   
} }
); );
define( define(
[ [
'main/Station', 'main/Station',
'main/Packet_Manager', 'main/Packet_Manager',
'map/Icon', 'Map/Icon',
'packet/APRSPacket', 'packet/APRSPacket',
'util/misc/math', 'util/misc/math',
'util/config', 'util/config',
'util/ui' 'util/ui'
], ],
function( function(
Station, Station,
Packet_Manager, Packet_Manager,
Icon, Icon,
APRSPacket, APRSPacket,
math, math,
config, config,
ui ui
){ ){
   
var packet_interface = {}; var packet_interface = {};
   
packet_interface.manager = new Packet_Manager(); packet_interface.manager = new Packet_Manager();
   
packet_interface.init = function(map, table){ packet_interface.init = function(map, table){
   
packet_interface.map = map; packet_interface.map = map;
packet_interface.table = table; packet_interface.table = table;
   
}; };
   
packet_interface.update_map = function(){ packet_interface.update_map = function(){
packet_interface.map.render(); packet_interface.map.render();
}; };
   
packet_interface.process_packet = function(packet_data){ packet_interface.process_packet = function(packet_data){
   
// Create packet from data // Create packet from data
var packet = APRSPacket.from_data(packet_data); var packet = APRSPacket.from_data(packet_data);
   
// Check if packet is valid // Check if packet is valid
var valid = packet.crc_check(); var valid = packet.crc_check();
   
// If packet is valid proccess it // If packet is valid proccess it
if(valid){ if(valid){
   
//ui.toast('Got Packet: '+packet.to_string(), {ttl: 2000}); //ui.toast('Got Packet: '+packet.to_string(), {ttl: 2000});
   
var now = new Date(); var now = new Date();
// Add info to the log // Add info to the log
packet_interface.table.append_data( packet_interface.table.append_data(
[ [
math.zero(2, now.getHours()) + ':' + math.zero(2, now.getMinutes()) + ':' + math.zero(2, now.getSeconds()), math.zero(2, now.getHours()) + ':' + math.zero(2, now.getMinutes()) + ':' + math.zero(2, now.getSeconds()),
packet.source_address + "-" + packet.source_ssid, packet.source_address + "-" + packet.source_ssid,
packet.destination_address + "-" + packet.destination_ssid, packet.destination_address + "-" + packet.destination_ssid,
packet.to_string() packet.to_string()
] ]
); );
   
var new_station = packet_interface.manager.add_packet(packet, packet_interface.update_map); var new_station = packet_interface.manager.add_packet(packet, packet_interface.update_map);
if(new_station){ if(new_station){
   
new_station.visible = packet_interface.table.filter.flt.call(packet_interface.table.filter, ['', new_station.callsign + '-' + new_station.ssid]); new_station.visible = packet_interface.table.filter.flt.call(packet_interface.table.filter, ['', new_station.callsign + '-' + new_station.ssid]);
packet_interface.map.add_object(new_station); packet_interface.map.add_object(new_station);
} }
   
// Log detailed packet info to console // Log detailed packet info to console
if(config.log_packets) if(config.log_packets)
console.log(packet.info_string()); console.log(packet.info_string());
   
} }
   
}; };
   
packet_interface.clear_filters = function(){ packet_interface.clear_filters = function(){
   
packet_interface.table.filter.list.length = 0; packet_interface.table.filter.list.length = 0;
packet_interface.table.update_filter(); packet_interface.table.update_filter();
   
var stations = packet_interface.manager.stations; var stations = packet_interface.manager.stations;
   
for(var key in stations){ for(var key in stations){
if(stations.hasOwnProperty(key)){ if(stations.hasOwnProperty(key)){
stations[key].visible = true; stations[key].visible = true;
} }
} }
   
packet_interface.map.render(); packet_interface.map.render();
   
}; };
   
Station.UI_Build_Popup = function(station){ Station.UI_Build_Popup = function(station){
   
var d = document.createElement('div'), var d = document.createElement('div'),
head = document.createElement('div'), head = document.createElement('div'),
title = document.createElement('div'), title = document.createElement('div'),
info = document.createElement('div'), info = document.createElement('div'),
filter = document.createElement('div'), filter = document.createElement('div'),
hide = document.createElement('div'), hide = document.createElement('div'),
more = document.createElement('div'), more = document.createElement('div'),
img = station.image.get_image_element(); img = station.image.get_image_element();
   
img.style.cssFloat = 'left'; img.style.cssFloat = 'left';
title.innerHTML = station.callsign + '-' + station.ssid; title.innerHTML = station.callsign + '-' + station.ssid;
info.innerHTML = station.info_string().replace(/\n/g, '<br />'); info.innerHTML = station.info_string().replace(/\n/g, '<br />');
   
head.appendChild(img); head.appendChild(img);
head.appendChild(title); head.appendChild(title);
hide.innerHTML = 'Hide'; hide.innerHTML = 'Hide';
hide.classList.add('message-button'); hide.classList.add('message-button');
filter.innerHTML = 'Filter'; filter.innerHTML = 'Filter';
filter.classList.add('message-button'); filter.classList.add('message-button');
more.innerHTML = 'More'; more.innerHTML = 'More';
more.classList.add('message-button'); more.classList.add('message-button');
d.appendChild(head); d.appendChild(head);
d.appendChild(info); d.appendChild(info);
d.appendChild(hide); d.appendChild(hide);
d.appendChild(filter); d.appendChild(filter);
d.appendChild(more); d.appendChild(more);
d.classList.add('station-info'); d.classList.add('station-info');
packet_interface.map.clear_messages(); packet_interface.map.clear_messages();
var mb = packet_interface.map.add_message_box(d, station.coordinates); var mb = packet_interface.map.add_message_box(d, station.coordinates);
// Hide the selected station // Hide the selected station
hide.onclick = function(e){ hide.onclick = function(e){
station.visible = false; station.visible = false;
packet_interface.map.remove_message_box(mb); packet_interface.map.remove_message_box(mb);
   
// TODO: Hide in Table // TODO: Hide in Table
   
packet_interface.map.render(); packet_interface.map.render();
packet_interface.table.filter.list.push({type: '-', column: 1, value: station.callsign + '-' + station.ssid}); packet_interface.table.filter.list.push({type: '-', column: 1, value: station.callsign + '-' + station.ssid});
packet_interface.table.update_filter(); packet_interface.table.update_filter();
}; };
// Filter all stations but the selected station // Filter all stations but the selected station
filter.onclick = function(e){ filter.onclick = function(e){
   
var stations = packet_interface.manager.stations; var stations = packet_interface.manager.stations;
   
for(var key in stations){ for(var key in stations){
if(stations.hasOwnProperty(key)){ if(stations.hasOwnProperty(key)){
if(stations[key] != station){ if(stations[key] != station){
   
// TODO: Filter in Table // TODO: Filter in Table
   
stations[key].visible = false; stations[key].visible = false;
   
} }
} }
} }
   
packet_interface.map.render(); packet_interface.map.render();
   
packet_interface.map.render(); packet_interface.map.render();
packet_interface.table.filter.list.push({type: 'w', column: 1, value: station.callsign + '-' + station.ssid}); packet_interface.table.filter.list.push({type: 'w', column: 1, value: station.callsign + '-' + station.ssid});
packet_interface.table.update_filter(); packet_interface.table.update_filter();
   
}; };
   
// TODO // TODO
// Cover the map with a menu with more options // Cover the map with a menu with more options
// View raw packets option // View raw packets option
more.onclick = function(e){ more.onclick = function(e){
   
// //
   
}; };
   
} }
   
return packet_interface; return packet_interface;
   
} }
); );
/** /**
* @author Michael Marques <dryerzinia@gmail.com> * @author Michael Marques <dryerzinia@gmail.com>
*/ */
   
/** /**
* @module Packet * @module Packet
*/ */
   
/** /**
* @class APRS_MIC_E * @class APRS_MIC_E
*/ */
   
define( define(
[ [
'main/Station_Status', 'main/Station_Status',
'map/LatLong' 'Map/LatLong'
], ],
function( function(
Station_Status, Station_Status,
LatLong LatLong
){ ){
   
var APRS_MIC_E = function(packet){ var APRS_MIC_E = function(packet){
   
// Debuging info // Debuging info
console.log('Parsing APRS_MIC_E Packet'); console.log('Parsing APRS_MIC_E Packet');
   
// Parse denstination Address for info // Parse denstination Address for info
var long_offset = 0; var long_offset = 0;
var long_multiplier = 1; var long_multiplier = 1;
if((packet.data[4] >> 1) >= 0x50) if((packet.data[4] >> 1) >= 0x50)
long_offset = 100; long_offset = 100;
if((packet.data[5] >> 1) >= 0x50) if((packet.data[5] >> 1) >= 0x50)
long_multiplier = -1; long_multiplier = -1;
   
var long_degrees = packet.message_data[1]; var long_degrees = packet.message_data[1];
var long_minutes = packet.message_data[2]; var long_minutes = packet.message_data[2];
var long_hundreths_of_minutes = packet.message_data[3]; var long_hundreths_of_minutes = packet.message_data[3];
   
var long = long_degrees - 28; var long = long_degrees - 28;
long += long_offset; long += long_offset;
if(long >= 180 && long <= 189) long -= 80; if(long >= 180 && long <= 189) long -= 80;
else if(long >= 190 && long <= 199) long -= 190; else if(long >= 190 && long <= 199) long -= 190;
long_minutes -= 28; long_minutes -= 28;
if(long_minutes >= 60) long_minutes -= 60; if(long_minutes >= 60) long_minutes -= 60;
long_hundreths_of_minutes -= 28; long_hundreths_of_minutes -= 28;
long += (long_minutes/60) + (long_hundreths_of_minutes/6000); long += (long_minutes/60) + (long_hundreths_of_minutes/6000);
long *= long_multiplier; long *= long_multiplier;
   
var lats = ""; var lats = "";
for(var j = 0; j < 6; j++){ for(var j = 0; j < 6; j++){
var val = (packet.data[j] >> 1) & 0x7F; var val = (packet.data[j] >> 1) & 0x7F;
if(val >= 0x41 && val <= 0x4A) if(val >= 0x41 && val <= 0x4A)
val -= 17; val -= 17;
else if(val >= 0x50 && val <= 0x59) else if(val >= 0x50 && val <= 0x59)
val -= 32; val -= 32;
lats += String.fromCharCode(val); lats += String.fromCharCode(val);
} }
   
var lat = parseFloat(lats.substring(0, 2)) + parseFloat(lats.substring(2, 4))/60 + parseFloat(lats.substring(4, 6))/6000; var lat = parseFloat(lats.substring(0, 2)) + parseFloat(lats.substring(2, 4))/60 + parseFloat(lats.substring(4, 6))/6000;
if((packet.data[3]>>1) < 0x50) if((packet.data[3]>>1) < 0x50)
lat *= -1; lat *= -1;
   
var dest_0 = (packet.data[0] >> 1) & 0x7F; var dest_0 = (packet.data[0] >> 1) & 0x7F;
var dest_1 = (packet.data[1] >> 1) & 0x7F; var dest_1 = (packet.data[1] >> 1) & 0x7F;
var dest_2 = (packet.data[2] >> 1) & 0x7F; var dest_2 = (packet.data[2] >> 1) & 0x7F;
   
var message_a = 0; var message_a = 0;
var message_b = 0; var message_b = 0;
var message_c = 0; var message_c = 0;
   
if(dest_0 >= 0x41 && dest_0 <= 0x4B) if(dest_0 >= 0x41 && dest_0 <= 0x4B)
message_a = 1; message_a = 1;
else if(dest_0 >= 0x50) else if(dest_0 >= 0x50)
message_a = 2; message_a = 2;
   
if(dest_1 >= 0x41 && dest_1 <= 0x4B) if(dest_1 >= 0x41 && dest_1 <= 0x4B)
message_b = 1; message_b = 1;
else if(dest_1 >= 0x50) else if(dest_1 >= 0x50)
message_b = 2; message_b = 2;
   
if(dest_2 >= 0x41 && dest_2 <= 0x4B) if(dest_2 >= 0x41 && dest_2 <= 0x4B)
message_c = 1; message_c = 1;
else if(dest_2 >= 0x50) else if(dest_2 >= 0x50)
message_c = 2; message_c = 2;
   
var message_type = 0; var message_type = 0;
   
var message_cust = (message_a == 1 || message_b == 1 || message_c == 1); var message_cust = (message_a == 1 || message_b == 1 || message_c == 1);
var message_stan = (message_a == 2 || message_b == 2 || message_c == 2); var message_stan = (message_a == 2 || message_b == 2 || message_c == 2);
   
if(message_cust && message_stan) if(message_cust && message_stan)
message_type = 0; message_type = 0;
   
else { else {
   
if(message_a != 0){ if(message_a != 0){
   
if(message_b != 0){ if(message_b != 0){
   
if(message_c != 0) message_type = 1; if(message_c != 0) message_type = 1;
else message_type = 2; else message_type = 2;
   
} else { } else {
   
if(message_c != 0) message_type = 3; if(message_c != 0) message_type = 3;
else message_type = 4; else message_type = 4;
   
} }
   
} else { } else {
   
if(message_b != 0){ if(message_b != 0){
   
if(message_c != 0) message_type = 5; if(message_c != 0) message_type = 5;
else message_type = 6; else message_type = 6;
   
} else { } else {
   
if(message_c != 0) message_type = 7; if(message_c != 0) message_type = 7;
else message_type = 8; else message_type = 8;
   
} }
   
} }
   
} }
switch(message_type){ switch(message_type){
case 0: case 0:
this.MIC_E_message_type = "Unknown"; this.MIC_E_message_type = "Unknown";
break; break;
case 1: case 1:
if(message_stan) this.MIC_E_message_type = "Off Duty"; if(message_stan) this.MIC_E_message_type = "Off Duty";
else this.MIC_E_message_type = "C0"; else this.MIC_E_message_type = "C0";
break; break;
case 2: case 2:
if(message_stan) this.MIC_E_message_type = "En Route"; if(message_stan) this.MIC_E_message_type = "En Route";
else this.MIC_E_message_type = "C1"; else this.MIC_E_message_type = "C1";
break; break;
case 3: case 3:
if(message_stan) this.MIC_E_message_type = "In Service"; if(message_stan) this.MIC_E_message_type = "In Service";
else this.MIC_E_message_type = "C2"; else this.MIC_E_message_type = "C2";
break; break;
case 4: case 4:
if(message_stan) this.MIC_E_message_type = "Returning"; if(message_stan) this.MIC_E_message_type = "Returning";
else this.MIC_E_message_type = "C3"; else this.MIC_E_message_type = "C3";
break; break;
case 5: case 5:
if(message_stan) this.MIC_E_message_type = "Committed"; if(message_stan) this.MIC_E_message_type = "Committed";
else this.MIC_E_message_type = "C4"; else this.MIC_E_message_type = "C4";
break; break;
case 6: case 6:
if(message_stan) this.MIC_E_message_type = "Special"; if(message_stan) this.MIC_E_message_type = "Special";
else this.MIC_E_message_type = "C5"; else this.MIC_E_message_type = "C5";
break; break;
case 7: case 7:
if(message_stan) this.MIC_E_message_type = "Priority"; if(message_stan) this.MIC_E_message_type = "Priority";
else this.MIC_E_message_type = "C6"; else this.MIC_E_message_type = "C6";
break; break;
case 8: case 8:
// Consider some kind of messaging callback to notify user // Consider some kind of messaging callback to notify user
this.MIC_E_message_type = "Emergency"; this.MIC_E_message_type = "Emergency";
break; break;
} }
   
this.coordinates = new LatLong(lat, long); this.coordinates = new LatLong(lat, long);
   
var speed = packet.message_data[4]; var speed = packet.message_data[4];
var spdhed = packet.message_data[5]; var spdhed = packet.message_data[5];
var heading = packet.message_data[6]; var heading = packet.message_data[6];
   
var aspeed = (speed - 28) * 10; var aspeed = (speed - 28) * 10;
aspeed += Math.round((spdhed - 28) / 10); aspeed += Math.round((spdhed - 28) / 10);
var aheading = (((spdhed - 28) % 10) * 100) + (heading - 28); var aheading = (((spdhed - 28) % 10) * 100) + (heading - 28);
if(aspeed >= 800) aspeed -= 800; if(aspeed >= 800) aspeed -= 800;
if(aheading >= 400) aheading -= 400; if(aheading >= 400) aheading -= 400;
   
this.speed = aspeed; this.speed = aspeed;
this.heading = aheading; this.heading = aheading;
   
this.symbol_table = String.fromCharCode(packet.message_data[8]); this.symbol_table = String.fromCharCode(packet.message_data[8]);
this.symbol_code = String.fromCharCode(packet.message_data[7]); this.symbol_code = String.fromCharCode(packet.message_data[7]);
   
// Find Telemetry // Find Telemetry
   
// Find Grid Locator /G // Find Grid Locator /G
var j = -1; var j = -1;
if(packet.message_data[16] == 47 && packet.message_data[16] == 71){ if(packet.message_data[16] == 47 && packet.message_data[16] == 71){
j = 18; j = 18;
} else if(packet.message_data[17] == 47 && packet.message_data[17] == 71){ } else if(packet.message_data[17] == 47 && packet.message_data[17] == 71){
j = 19; j = 19;
} }
   
if(j != -1){ if(j != -1){
// Check for space for message and if its missing print warning // Check for space for message and if its missing print warning
if(packet.message_data.length > j - 1 && packet.message_data[j - 1] == 32) if(packet.message_data.length > j - 1 && packet.message_data[j - 1] == 32)
console.log('Warning: Status Text should begin with Space after grid locator!'); console.log('Warning: Status Text should begin with Space after grid locator!');
   
// Parse Grid Locator // Parse Grid Locator
console.log('parse loc'); console.log('parse loc');
} }
   
// Find Altitude Indicator } if we dident find Grid Locator // Find Altitude Indicator } if we dident find Grid Locator
else { else {
   
if(packet.message_data[12] == 125){ if(packet.message_data[12] == 125){
j = 13; j = 13;
} else if(packet.message_data[13] == 125){ } else if(packet.message_data[13] == 125){
j = 14; j = 14;
} }
   
// Parse Altitude // Parse Altitude
if(j != -1){ if(j != -1){
this.altitude = this.altitude =
( (
(packet.message_data[j - 4] - 33) * 8281 + // 8281 is 91^2, Base 91 encoding shifed by 33 (packet.message_data[j - 4] - 33) * 8281 + // 8281 is 91^2, Base 91 encoding shifed by 33
(packet.message_data[j - 3] - 33) * 91 + // to be printable characters (packet.message_data[j - 3] - 33) * 91 + // to be printable characters
(packet.message_data[j - 2] - 33) (packet.message_data[j - 2] - 33)
- 10000); // Altitude is based 10000 feet below sealevel - 10000); // Altitude is based 10000 feet below sealevel
} }
   
} }
   
this.status = ""; this.status = "";
var i = 10; var i = 10;
if(j != -1) if(j != -1)
i = j; i = j;
   
for(; i < packet.message_data.length; i++){ for(; i < packet.message_data.length; i++){
this.status += String.fromCharCode(packet.message_data[i]); this.status += String.fromCharCode(packet.message_data[i]);
} }
   
}; };
   
APRS_MIC_E.prototype.update_status = function(status){ APRS_MIC_E.prototype.update_status = function(status){
   
status.altitude = this.altitude; status.altitude = this.altitude;
status.altitude_unit = 'meters'; status.altitude_unit = 'meters';
   
status.speed = this.speed; status.speed = this.speed;
status.speed_unit = 'knots'; status.speed_unit = 'knots';
   
status.heading = this.heading; status.heading = this.heading;
   
status.status = this.status; status.status = this.status;
   
status.mic_e = this.MIC_E_message_type; status.mic_e = this.MIC_E_message_type;
   
}; };
   
return APRS_MIC_E; return APRS_MIC_E;
   
} }
); );
/** /**
* @author Michael Marques <dryerzinia@gmail.com> * @author Michael Marques <dryerzinia@gmail.com>
*/ */
   
/** /**
* @module Packet * @module Packet
*/ */
   
/** /**
* @class APRS_Parser * @class APRS_Parser
* @static * @static
*/ */
   
define( define(
[ [
'map/LatLong', 'Map/LatLong',
'util/misc/math', 'util/misc/math',
'util/misc/string' 'util/misc/string'
], ],
function( function(
LatLong, LatLong,
math, math,
string string
){ ){
var APRS_Parser = {}; var APRS_Parser = {};
   
APRS_Parser.update_extensions = function(info, status){ APRS_Parser.update_extensions = function(info, status){
   
if(info.status_official){ if(info.status_official){
status.status = info.status; status.status = info.status;
status.status_official = info.status_official; status.status_official = info.status_official;
} }
   
if(!status.status_official && info.status) if(!status.status_official && info.status)
status.status = info.status; status.status = info.status;
   
if(info.altitude !== undefined){ if(info.altitude !== undefined){
status.altitude = info.altitude; status.altitude = info.altitude;
status.altitude_unit = 'feet'; status.altitude_unit = 'feet';
} }
   
if(info.power !== undefined) if(info.power !== undefined)
status.power = info.power; status.power = info.power;
   
if(info.haat !== undefined) if(info.haat !== undefined)
status.haat = info.haat; status.haat = info.haat;
   
if(info.gain !== undefined) if(info.gain !== undefined)
status.gain = info.gain; status.gain = info.gain;
   
if(info.directivity !== undefined) if(info.directivity !== undefined)
status.directivity = info.directivity; status.directivity = info.directivity;
   
if(info.heading !== undefined) if(info.heading !== undefined)
status.heading = info.heading; status.heading = info.heading;
   
if(info.speed !== undefined){ if(info.speed !== undefined){
status.speed = info.speed; status.speed = info.speed;
status.speed_unit = info.speed_unit; status.speed_unit = info.speed_unit;
} }
   
}; };
   
APRS_Parser.update_WX = function(info, status){ APRS_Parser.update_WX = function(info, status){
   
if(info.wind_direction !== undefined){ if(info.wind_direction !== undefined){
status.wind_direction = info.wind_direction; status.wind_direction = info.wind_direction;
} }
if(info.wind_speed !== undefined){ if(info.wind_speed !== undefined){
status.wind_speed = info.wind_speed; status.wind_speed = info.wind_speed;
status.wind_speed_unit = 'MPH'; status.wind_speed_unit = 'MPH';
} }
if(info.gust_speed !== undefined){ if(info.gust_speed !== undefined){
status.gust_speed = info.gust_speed; status.gust_speed = info.gust_speed;
status.gust_speed_unit = 'MPH'; status.gust_speed_unit = 'MPH';
} }
if(info.temperature !== undefined){ if(info.temperature !== undefined){
status.temperature = info.temperature; status.temperature = info.temperature;
status.temperature_unit = 'fahrenheit'; status.temperature_unit = 'fahrenheit';
} }
if(info.rain_hour !== undefined){ if(info.rain_hour !== undefined){
status.rain_hour = info.rain_hour / 100; status.rain_hour = info.rain_hour / 100;
status.rain_hour_unit = 'inch'; status.rain_hour_unit = 'inch';
} }
if(info.rain_24hour !== undefined){ if(info.rain_24hour !== undefined){
status.rain_24hour = info.rain_24hour / 100; status.rain_24hour = info.rain_24hour / 100;
status.rain_24hour_unit = 'inch'; status.rain_24hour_unit = 'inch';
} }
if(info.rain_midnight !== undefined){ if(info.rain_midnight !== undefined){
status.rain_midnight = info.rain_midnight / 100; status.rain_midnight = info.rain_midnight / 100;
status.rain_midnight_unit = 'inch'; status.rain_midnight_unit = 'inch';
} }
if(info.humidity !== undefined){ if(info.humidity !== undefined){
status.humidity = info.humidity; status.humidity = info.humidity;
} }
if(info.barometric_pressure !== undefined){ if(info.barometric_pressure !== undefined){
status.barometric_pressure = info.barometric_pressure; status.barometric_pressure = info.barometric_pressure;
status.barometric_pressure_unit = 'mBars/tenths_hPascal'; status.barometric_pressure_unit = 'mBars/tenths_hPascal';
} }
   
}; };
   
APRS_Parser.parse_extensions = function(info, packet, i){ APRS_Parser.parse_extensions = function(info, packet, i){
   
info.status = ''; info.status = '';
for(; i < packet.message_data.length; i++){ for(; i < packet.message_data.length; i++){
info.status += String.fromCharCode(packet.message_data[i]); info.status += String.fromCharCode(packet.message_data[i]);
} }
   
APRS_Parser.parse_course_speed(info, info.status); APRS_Parser.parse_course_speed(info, info.status);
APRS_Parser.parse_PHG(info, info.status); APRS_Parser.parse_PHG(info, info.status);
APRS_Parser.parse_alt_in_stat(info, info.status); APRS_Parser.parse_alt_in_stat(info, info.status);
   
}; };
   
APRS_Parser.parse_course_speed = function(info, status_in){ APRS_Parser.parse_course_speed = function(info, status_in){
   
var m = status_in.match(/[0-9][0-9][0-9]\/[0-9][0-9][0-9]/); var m = status_in.match(/[0-9][0-9][0-9]\/[0-9][0-9][0-9]/);
   
if(m !== null){ if(m !== null){
   
var idx = status_in.indexOf(m[0]); var idx = status_in.indexOf(m[0]);
   
info.heading = parseFloat(status_in.substring(idx, idx + 3)); info.heading = parseFloat(status_in.substring(idx, idx + 3));
info.speed = parseFloat(status_in.substring(idx + 4, idx + 7)); info.speed = parseFloat(status_in.substring(idx + 4, idx + 7));
info.speed_unit = 'MPH'; // TODO this needs confirmation info.speed_unit = 'MPH'; // TODO this needs confirmation
   
info.status = status_in.substring(0, idx) + status_in.substring(idx + 7, status_in.length); info.status = status_in.substring(0, idx) + status_in.substring(idx + 7, status_in.length);
   
} }
   
}; };
   
APRS_Parser.parse_PHG = function(info, status_in){ APRS_Parser.parse_PHG = function(info, status_in){
   
var phg = status_in.indexOf('PHG'); var phg = status_in.indexOf('PHG');
if(phg != -1){ if(phg != -1){
   
info.power = Math.pow(status_in.charCodeAt(phg + 3) - 0x30, 2); info.power = Math.pow(status_in.charCodeAt(phg + 3) - 0x30, 2);
info.haat = Math.pow(2, status_in.charCodeAt(phg + 4) - 0x30) * 10; info.haat = Math.pow(2, status_in.charCodeAt(phg + 4) - 0x30) * 10;
info.gain = status_in.charCodeAt(phg + 5) - 0x30; info.gain = status_in.charCodeAt(phg + 5) - 0x30;
info.directivity = (status_in.charCodeAt(phg + 6) - 0x30) * 45; info.directivity = (status_in.charCodeAt(phg + 6) - 0x30) * 45;
   
info.status = info.status.substring(phg + 7, info.status.length); info.status = info.status.substring(phg + 7, info.status.length);
   
}; };
   
}; };
   
APRS_Parser.parse_alt_in_stat = function(info, status_in){ APRS_Parser.parse_alt_in_stat = function(info, status_in){
   
var altitude = undefined, var altitude = undefined,
status = status_in; status = status_in;
   
var alt = status_in.indexOf('/A='); var alt = status_in.indexOf('/A=');
if(alt != -1){ if(alt != -1){
   
altitude = parseFloat(status.substring(alt + 3, alt + 9)); altitude = parseFloat(status.substring(alt + 3, alt + 9));
   
status = status_in.substring(0, alt); status = status_in.substring(0, alt);
if(status_in.length > alt + 9) if(status_in.length > alt + 9)
status += status_in.substring(alt + 9, status_in.length); status += status_in.substring(alt + 9, status_in.length);
   
} }
   
info.status = status; info.status = status;
info.altitude = altitude; info.altitude = altitude;
   
}; };
   
APRS_Parser.parse_wind = function(info, packet, i){ APRS_Parser.parse_wind = function(info, packet, i){
   
info.wind_direction = math.parse_int(packet.message_data, i, 3); info.wind_direction = math.parse_int(packet.message_data, i, 3);
i += 4; i += 4;
info.wind_speed = math.parse_int(packet.message_data, i, 3); info.wind_speed = math.parse_int(packet.message_data, i, 3);
i += 3; i += 3;
   
return i; return i;
   
}; };
   
APRS_Parser.parse_WX = function(info, packet, i){ APRS_Parser.parse_WX = function(info, packet, i){
   
var finished = false; var finished = false;
   
while(!finished && i < packet.message_data.length){ while(!finished && i < packet.message_data.length){
   
var type = String.fromCharCode(packet.message_data[i]); var type = String.fromCharCode(packet.message_data[i]);
   
i++; i++;
   
switch(type){ switch(type){
case 'c': case 'c':
if(packet.message_data[i] != 0x2E) if(packet.message_data[i] != 0x2E)
info.wind_direction = math.parse_int(packet.message_data, i, 3); info.wind_direction = math.parse_int(packet.message_data, i, 3);
i += 3; i += 3;
break; break;
case 's': case 's':
if(packet.message_data[i] != 0x2E) if(packet.message_data[i] != 0x2E)
info.wind_speed = math.parse_int(packet.message_data, i, 3); info.wind_speed = math.parse_int(packet.message_data, i, 3);
i += 3; i += 3;
break; break;
case 'g': case 'g':
if(packet.message_data[i] != 0x2E) if(packet.message_data[i] != 0x2E)
info.gust_speed = math.parse_int(packet.message_data, i, 3); info.gust_speed = math.parse_int(packet.message_data, i, 3);
i += 3; i += 3;
break; break;
case 't': case 't':
if(packet.message_data[i] != 0x2E){ if(packet.message_data[i] != 0x2E){
if(packet.message_data[i] == 0x2D){ if(packet.message_data[i] == 0x2D){
info.temperature = -math.parse_int(packet.message_data, i + 1, 2); info.temperature = -math.parse_int(packet.message_data, i + 1, 2);
} }
else else
info.temperature = math.parse_int(packet.message_data, i, 3); info.temperature = math.parse_int(packet.message_data, i, 3);
} }
i += 3; i += 3;
break; break;
case 'r': case 'r':
if(packet.message_data[i] != 0x2E) if(packet.message_data[i] != 0x2E)
info.rain_hour = math.parse_int(packet.message_data, i, 3); info.rain_hour = math.parse_int(packet.message_data, i, 3);
i += 3; i += 3;
break; break;
case 'p': case 'p':
if(packet.message_data[i] != 0x2E) if(packet.message_data[i] != 0x2E)
info.rain_24hour = math.parse_int(packet.message_data, i, 3); info.rain_24hour = math.parse_int(packet.message_data, i, 3);
i += 3; i += 3;
break; break;
case 'P': case 'P':
if(packet.message_data[i] != 0x2E) if(packet.message_data[i] != 0x2E)
info.rain_midnight = math.parse_int(packet.message_data, i, 3); info.rain_midnight = math.parse_int(packet.message_data, i, 3);
i += 3; i += 3;
break; break;
case 'h': case 'h':
if(packet.message_data[i] != 0x2E){ if(packet.message_data[i] != 0x2E){
info.humidity = math.parse_int(packet.message_data, i, 2); info.humidity = math.parse_int(packet.message_data, i, 2);
if(info.humidity == 0) if(info.humidity == 0)
info.humidity = 100; info.humidity = 100;
} }
i += 2; i += 2;
break; break;
case 'b': case 'b':
if(packet.message_data[i+1] != 0x2E) if(packet.message_data[i+1] != 0x2E)
info.barometric_pressure = math.parse_int(packet.message_data, i, 5); info.barometric_pressure = math.parse_int(packet.message_data, i, 5);
i += 5; i += 5;
break; break;
default: default:
   
info.software_type = String.fromCharCode(packet.message_data[i++]); info.software_type = String.fromCharCode(packet.message_data[i++]);
   
info.WX_unit = ''; info.WX_unit = '';
var start = i; var start = i;
while(i < packet.message_data.length && i < start + 4 && string.is_printable(packet.message_data[i])){ while(i < packet.message_data.length && i < start + 4 && string.is_printable(packet.message_data[i])){
   
info.WX_unit += String.fromCharCode(packet.message_data[i]); info.WX_unit += String.fromCharCode(packet.message_data[i]);
i++; i++;
   
} }
   
break; break;
} }
} }
   
return i; return i;
   
}; };
   
APRS_Parser.parse_lat_lon = function(info, packet, i){ APRS_Parser.parse_lat_lon = function(info, packet, i){
   
var latDeg = ""; var latDeg = "";
var latMin = ""; var latMin = "";
   
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
latDeg += String.fromCharCode(packet.message_data[i]); latDeg += String.fromCharCode(packet.message_data[i]);
   
for(var j = i+4; i < j; i++) for(var j = i+4; i < j; i++)
latMin += String.fromCharCode(packet.message_data[i]); latMin += String.fromCharCode(packet.message_data[i]);
   
i++; i++;
var latCardinal = String.fromCharCode(packet.message_data[i]); var latCardinal = String.fromCharCode(packet.message_data[i]);
   
i++; i++;
info.symbol_table = String.fromCharCode(packet.message_data[i]); info.symbol_table = String.fromCharCode(packet.message_data[i]);
   
i++; i++;
var longDeg = ""; var longDeg = "";
var longMin = ""; var longMin = "";
   
for(var j = i+3; i < j; i++) for(var j = i+3; i < j; i++)
longDeg += String.fromCharCode(packet.message_data[i]); longDeg += String.fromCharCode(packet.message_data[i]);
   
for(var j = i+4; i < j; i++) for(var j = i+4; i < j; i++)
longMin += String.fromCharCode(packet.message_data[i]); longMin += String.fromCharCode(packet.message_data[i]);
   
i++; i++;
var longCardinal = String.fromCharCode(packet.message_data[i]); var longCardinal = String.fromCharCode(packet.message_data[i]);
   
i++; i++;
info.symbol_code = String.fromCharCode(packet.message_data[i]); info.symbol_code = String.fromCharCode(packet.message_data[i]);
   
var lat = parseFloat(latDeg) + parseFloat(latMin)/60; var lat = parseFloat(latDeg) + parseFloat(latMin)/60;
var long = parseFloat(longDeg) + parseFloat(longMin)/60; var long = parseFloat(longDeg) + parseFloat(longMin)/60;
   
if(latCardinal == 'S') if(latCardinal == 'S')
lat *= -1; lat *= -1;
   
if(longCardinal == 'W') if(longCardinal == 'W')
long *= -1; long *= -1;
   
info.coordinates = new LatLong(lat, long); info.coordinates = new LatLong(lat, long);
   
return i; return i;
   
}; };
   
APRS_Parser.parse_time_stamp = function(info, packet, i){ APRS_Parser.parse_time_stamp = function(info, packet, i){
   
info.time_stamp = new Date(); info.time_stamp = new Date();
   
var timeStampType = String.fromCharCode(packet.message_data[i+6]); var timeStampType = String.fromCharCode(packet.message_data[i+6]);
   
var month = ""; var month = "";
var day = ""; var day = "";
var hour = ""; var hour = "";
var minute = ""; var minute = "";
var second = ""; var second = "";
   
switch(timeStampType){ switch(timeStampType){
case 'z': // Day/Hours/Minutes Zulu (UTC) case 'z': // Day/Hours/Minutes Zulu (UTC)
{ {
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
day += String.fromCharCode(packet.message_data[i]); day += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
hour += String.fromCharCode(packet.message_data[i]); hour += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
minute += String.fromCharCode(packet.message_data[i]); minute += String.fromCharCode(packet.message_data[i]);
   
info.time_stamp.setUTCDate(parseFloat(day)); info.time_stamp.setUTCDate(parseFloat(day));
info.time_stamp.setUTCHours(parseFloat(hour)); info.time_stamp.setUTCHours(parseFloat(hour));
info.time_stamp.setUTCMinutes(parseFloat(minute)); info.time_stamp.setUTCMinutes(parseFloat(minute));
   
} }
break; break;
case '/': // Day/Hours/Minutes Local case '/': // Day/Hours/Minutes Local
{ {
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
day += String.fromCharCode(packet.message_data[i]); day += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
hour += String.fromCharCode(packet.message_data[i]); hour += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
minute += String.fromCharCode(packet.message_data[i]); minute += String.fromCharCode(packet.message_data[i]);
   
info.time_stamp.setDate(parseFloat(day)); info.time_stamp.setDate(parseFloat(day));
info.time_stamp.setHours(parseFloat(hour)); info.time_stamp.setHours(parseFloat(hour));
info.time_stamp.setMinutes(parseFloat(minute)); info.time_stamp.setMinutes(parseFloat(minute));
   
} }
break; break;
case 'h': // Hours/Minutes/Seconds case 'h': // Hours/Minutes/Seconds
{ {
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
hour += String.fromCharCode(packet.message_data[i]); hour += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
minute += String.fromCharCode(packet.message_data[i]); minute += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
second += String.fromCharCode(packet.message_data[i]); second += String.fromCharCode(packet.message_data[i]);
   
info.time_stamp.setUTCHours(parseFloat(hour)); info.time_stamp.setUTCHours(parseFloat(hour));
info.time_stamp.setUTCMinutes(parseFloat(minute)); info.time_stamp.setUTCMinutes(parseFloat(minute));
info.time_stamp.setUTCSeconds(parseFloat(second)); info.time_stamp.setUTCSeconds(parseFloat(second));
   
} }
break; break;
default: // Month/Day/Hours/Minutes default: // Month/Day/Hours/Minutes
{ {
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
month += String.fromCharCode(packet.message_data[i]); month += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
day += String.fromCharCode(packet.message_data[i]); day += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
hour += String.fromCharCode(packet.message_data[i]); hour += String.fromCharCode(packet.message_data[i]);
for(var j = i+2; i < j; i++) for(var j = i+2; i < j; i++)
minute += String.fromCharCode(packet.message_data[i]); minute += String.fromCharCode(packet.message_data[i]);
   
info.time_stamp.setUTCMonth(parseFloat(month)); info.time_stamp.setUTCMonth(parseFloat(month));
info.time_stamp.setUTCDate(parseFloat(day)); info.time_stamp.setUTCDate(parseFloat(day));
info.time_stamp.setUTCHours(parseFloat(hour)); info.time_stamp.setUTCHours(parseFloat(hour));
info.time_stamp.setUTCMinutes(parseFloat(minute)); info.time_stamp.setUTCMinutes(parseFloat(minute));
   
} }
break; break;
}; };
   
return i; return i;
   
}; };
   
return APRS_Parser; return APRS_Parser;
   
} }
); );