@@ -614,6 +614,7 @@ async function postToMeshMapperAPI(lat, lon) {
614614
615615// ---- Ping ----
616616async function sendPing ( manual = false ) {
617+ console . log ( `\n=== SEND PING (${ manual ? 'MANUAL' : 'AUTO' } ) ===` ) ;
617618 try {
618619 // Check cooldown only for manual pings
619620 if ( manual && isInCooldown ( ) ) {
@@ -672,13 +673,14 @@ async function sendPing(manual = false) {
672673 // Validate GPS coordinates (note: 0 is a valid coordinate)
673674 if ( lat == null || lon == null || typeof lat !== 'number' || typeof lon !== 'number' || isNaN ( lat ) || isNaN ( lon ) ) {
674675 const msg = "Invalid GPS coordinates - cannot send ping" ;
675- console . error ( `GPS validation failed: lat=${ lat } , lon=${ lon } ` ) ;
676+ console . error ( `❌ GPS validation failed: lat=${ lat } , lon=${ lon } ` ) ;
676677 setStatus ( msg , "text-red-300" ) ;
677678 if ( ! manual && state . running ) {
678679 scheduleNextAutoPing ( ) ;
679680 }
680681 return ;
681682 }
683+ console . log ( `✓ GPS coordinates valid: ${ lat . toFixed ( 5 ) } , ${ lon . toFixed ( 5 ) } , accuracy: ±${ accuracy ? Math . round ( accuracy ) : '?' } m` ) ;
682684
683685 // Check geofence: ensure we're within the Ottawa service area
684686 console . log ( `Checking geofence for location: ${ lat . toFixed ( 5 ) } , ${ lon . toFixed ( 5 ) } ` ) ;
@@ -723,6 +725,7 @@ async function sendPing(manual = false) {
723725 }
724726
725727 const payload = buildPayload ( lat , lon ) ;
728+ console . log ( `✓ All checks passed! Sending ping: "${ payload } "` ) ;
726729
727730 const ch = await ensureChannel ( ) ;
728731 await state . connection . sendChannelTextMessage ( ch . channelIdx , payload ) ;
@@ -886,7 +889,9 @@ function startAutoPing() {
886889
887890// ---- BLE connect / disconnect ----
888891async function connect ( ) {
892+ console . log ( "\n=== Attempting to connect via Bluetooth ===" ) ;
889893 if ( ! ( "bluetooth" in navigator ) ) {
894+ console . error ( "❌ Web Bluetooth not supported in this browser" ) ;
890895 alert ( "Web Bluetooth not supported in this browser." ) ;
891896 return ;
892897 }
@@ -898,10 +903,12 @@ async function connect() {
898903 state . connection = conn ;
899904
900905 conn . on ( "connected" , async ( ) => {
906+ console . log ( "✓ Bluetooth connected successfully" ) ;
901907 setStatus ( "Connected" , "text-emerald-300" ) ;
902908 setConnectButton ( true ) ;
903909 connectBtn . disabled = false ;
904910 const selfInfo = await conn . getSelfInfo ( ) ;
911+ console . log ( `Device info: ${ selfInfo ?. name || "[No device]" } ` ) ;
905912 deviceInfoEl . textContent = selfInfo ?. name || "[No device]" ;
906913 updateAutoButton ( ) ;
907914 try { await conn . syncDeviceTime ?. ( ) ; } catch { /* optional */ }
@@ -993,6 +1000,10 @@ document.addEventListener("visibilitychange", async () => {
9931000
9941001// ---- Bind UI & init ----
9951002export async function onLoad ( ) {
1003+ console . log ( "=== MeshCore WarDriver Initialized ===" ) ;
1004+ console . log ( `Geofence: ${ OTTAWA_GEOFENCE_RADIUS_KM } km radius around Ottawa (${ OTTAWA_CENTER_LAT } , ${ OTTAWA_CENTER_LON } )` ) ;
1005+ console . log ( `Min ping distance: ${ MIN_PING_DISTANCE_M } m` ) ;
1006+ console . log ( `Channel: ${ CHANNEL_NAME } ` ) ;
9961007 setStatus ( "Disconnected" , "text-red-300" ) ;
9971008 enableControls ( false ) ;
9981009 updateAutoButton ( ) ;
0 commit comments