<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>smartPOC-tx</title>
    <link rel="icon" href="data:,">
    <meta name="apple-mobile-web-app-title" content="smartPOC-tx">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <div class="wrapper">
        <div class="header">
            <div class="topnav" id="topnav">
                <a href="#home" onclick="selTab(event,'Home');fetchCfgVals()" class="tablinks" id="defaultTab">Transmitter</a>

                <a href="#contacts" onclick="selTab(event,'Contacts')" class="tablinks">Contacts</a>

                <a href="#config" onclick="selTab(event,'Config')" class="tablinks">Config</a>
                <a href="#wifi" onclick="selTab(event,'WiFi')" class="tablinks">WiFi</a>

                <a href="#dwdmowas" onclick="selTab(event,'DWD+MoWaS')" class="tablinks">DWD / MOWAS</a>
                <a href="#idle" onclick="selTab(event,'Time / Idle Beacon')" class="tablinks">Time / Idle Beacon</a>

                <a href="#sysop" onclick="selTab(event,'SysOp / Update')" class="tablinks">SysOp / Update</a>
                
                <a href="#about" onclick="selTab(event,'About')" class="tablinks">About</a>

                <a href="javascript:void(0);" class="icon" onclick="toggleResponsive()">
                    <span class="hamburger"></span>
                </a>
            </div>
        </div>
        <div id="Home" class="tabcontent system-info">
            <h1>pocsag-tx</h1>
            <form action="/page" class="styled-form">
                <label for="ric">RIC</label>
                <input type="number" id="ric" name="ric" min="1" max="2097152" step="1" value="1234" />
            
                <label for="fun">Function</label>
                <input type="number" id="fun" name="fun" min="0" max="3" step="1" value="3" />
            
                <label for="text">Text</label>
                <input type="text" id="text" name="text" placeholder="Enter text..." />

                <label for="numeric">Numeric 4-bit BCD</label>
                <input type="checkbox" name="numeric"/>
            
                <div class="button-group">
                    <button type="submit" name="add">Queue</button>
                    <button type="submit" name="addtx">Direct Transmit</button>
                </div>
            </form>
            <div class="styled-form">
                <div class="button-group">
                    <button style="width: 10rem;" onClick="calculateTimeToTxTxt('swissphone')">Calc. Swissphone Time</button>
                    <button style="width: 10rem;" onClick="calculateTimeToTxTxt('tpl')">Calc. TPL Time</button>
                </div>
            </div>
            <form action="/transmit" class="styled-form no-top-margin">
                <div class="button-group">
                    <input class="btn" type="submit" value="transmit queue" />
                </div>
            </form>
            <p>Clear Queue manually (if config>clear queue after tx is not enabled)</p>
            <form action="/clear" class="styled-form no-top-margin">
                <div class="button-group">
                    <input class="btn" type="submit" value="clear queue" />
                </div>
            </form>
        </div>
        <div id="Contacts" class="tabcontent">
            <ol id="contactlist">
            </ol>
            <section class="styled-form">
                <h2>Add Contact</h3>
                <h3>RIC + Function + Text Length</h4>
                <input type="number" placeholder="RIC" id="newcon_r" min="1" max="2097152" step="1" value="1234" />
                <input type="number" placeholder="Function" id="newcon_f" min="0" max="3" step="1" value="3" />
                <input type="number" placeholder="Text Length" id="newcon_tl" min="0" max="260" step="1" value="80" />
                <h3>Contact Name + Default Message</h4>
                <input type="text" placeholder="Contact Name" id="newcon_n" />
                <input type="text" placeholder="Default Message" id="newcon_t" />
                
                <div class="button-group">
                    <button class="btn" onclick="addContact(true)">Add Contact, Save & Reload</button>
                    <button class="btn" onclick="addContact()">Add Contact & Just Save</button>
                    <button class="btn" onclick="resetContacts()">Initialize Empty Contacts</button>
                </div>
            </section>
        </div>
        <div id="Config" class="tabcontent">
            <h2>Semtech Modem Configuration</h3>
            <form action="/settransmitter" class="styled-form no-top-margin">
                <label for="tx_freq">TX Frequency in MHz / 137.0MHz - 525.0MHz</label>
                <input type="number" name="tx_freq" step="0.001" value="400.000" />
                
                <label for="tx_tune">TX Tuning</label>
                <input type="number" name="tx_tune" step="1"/>
                
                <label for="tx_baud">TX Baudrate 512/1200/2400</label>
                <input type="number" name="tx_baud" step="1" value="1200" />
                
                <label for="tx_dev">TX Deviation (usually 4.5kHz)</label>
                <input type="number" name="tx_dev" step="0.1" value="4.5" />
                
                <label for="tx_power">TX Power (3 to 15 dBm (RFO pin) or +2 to +17 dBm (PA_BOOST pin))</label>
                <input type="number" name="tx_power" step="1" value="3" />
                
                <label for="tx_empty_queue">Clear Transmit-Queue after TX</label>
                <input type="checkbox" name="tx_empty_queue"/>
                
                <label for="webserver_protect">Protect Web-Interface with AP-SSID/Pass</label>
                <input type="checkbox" name="webserver_protect"/>

                <label for="pocsag_german">German POCSAG</label>
                <input type="checkbox" name="pocsag_german"/>

                <div class="button-group">
                    <input class="btn" type="submit" value="set transmitter settings" />
                </div>
            </form>
            <h2>Device Configuration</h3>
            <form action="/setdev" class="styled-form no-top-margin">
                <label for="device_name">Device Name</label>
                <input id="device_name" type="text" name="device_name" />

                <label for="oled_timeout">OLED Timeout in minutes (0=disable), should be lower than idle/time beacon-interval</label>
                <input type="number" name="oled_timeout" step="1" min="0" max="720" value="3" />

                <div class="button-group">
                    <input class="btn" type="submit" value="set device settings" />
                </div>
            </form>
            <h2>MosQuiTTo Broker Configuration</h3>
            <form action="/setmqtt" class="styled-form no-top-margin">
                <label for="mqtt_host">MQTT Host (empty = disabled)</label>
                <input type="text" name="mqtt_host" value="" />
                <label for="mqtt_port">MQTT Port</label>
                <input type="number" name="mqtt_port" step="1" value="1883" />

                <label for="mqtt_user">MQTT Username</label>
                <input type="text" name="mqtt_user" value="" />
                <label for="mqtt_pass">MQTT Password</label>
                <input type="password" name="mqtt_pass" value="" />
                
                <label for="mqtt_toic">MQTT BaseTopic</label>
                <input type="text" name="mqtt_topic" value="" />
                <pre>transmit_topic = topic + "/transmit"</pre>
                <pre>clear_topic = topic + "/clear"</pre>
                <pre>state_topic = topic + "/state"</pre>
                <div class="button-group">
                    <input class="btn" type="submit" value="set mqtt settings" />
                </div>
            </form>
            <h2>Reboot to Apply Settings</h3>
            <form action="/reboot" class="styled-form no-top-margin">
                <div class="button-group">
                    <input class="btn" type="submit" value="reboot esp" />
                </div>
            </form>
        </div>
        <div id="WiFi" class="tabcontent">
            <h2>Access-Point Credentials</h2>
            <form action="/setap" class="styled-form no-top-margin">
                <label for="ssid">SSID</label>
                <input id="ap_ssid" type="text" name="ssid" />
                <label for="pass">Password</label>
                <input id="ap_pass" type="password" name="pass" />
                <div class="button-group">
                    <input class="btn" type="submit" value="set ap" />
                </div>
            </form>
            <h2>Home-WiFi Credentials</h2>
            <form action="/setwifi1" class="styled-form no-top-margin">
                <label for="ssid">SSID</label>
                <input id="wifi1_ssid" type="text" name="ssid" />
                <label for="pass">Password</label>
                <input id="wifi1_pass" type="password" name="pass" />
                <div class="button-group">
                    <input class="btn" type="submit" value="set wifi1" />
                </div>
            </form>
            <h2>Alt. WiFi Credentials</h2>
            <form action="/setwifi2" class="styled-form no-top-margin">
                <label for="ssid">SSID</label>
                <input id="wifi2_ssid" type="text" name="ssid" />
                <label for="pass">Password</label>
                <input id="wifi2_pass" type="password" name="pass" />
                <div class="button-group">
                    <input class="btn" type="submit" value="set wifi2" />
                </div>
            </form>
            <h2>Reboot to Apply Settings</h3>
            <form action="/reboot" class="styled-form no-top-margin">
                <div class="button-group">
                    <input class="btn" type="submit" value="reboot esp" />
                </div>
            </form>
        </div>
        <div id="DWD+MoWaS" class="tabcontent">
            <h2>DWD Settings</h2>
            <form action="/setdwdmowas" class="styled-form no-top-margin">
                <label for="dwd_enable">Enable DWD</label>
                <input type="checkbox" name="dwd_enable"/>
                <label for="dwd_region">DWD Region (lowercase wettwarn.de indicator)</label>
                <input id="dwd_region" type="text" name="dwd_region" />
                <label for="dwd_interval">DWD Interval (minutes)</label>
                <input type="number" placeholder="5m" id="dwd_interval" name="dwd_interval" min="1" max="1440" step="1" value="5" />
                <label for="dwd_fun">DWD Function</label>
                <input type="number" placeholder="Function" id="dwd_fun" name="dwd_fun" min="0" max="3" step="1" value="3" />

                <label for="mowas_enable">Enable MoWaS</label>
                <input type="checkbox" name="mowas_enable"/>
                <label for="mowas_region">MoWaS Region (<a href="https://www.dcat-ap.de/def/politicalGeocoding/regionalKey/">dcat-ap.de</a>)</label>
                <input id="mowas_region" type="text" name="mowas_region" />
                <label for="mowas_interval">MoWaS Interval (minutes)</label>
                <input type="number" placeholder="5m" id="mowas_interval" name="mowas_interval" min="1" max="1440" step="1" value="5" />
                <label for="mowas_fun">MoWaS Function</label>
                <input type="number" placeholder="Function" id="mowas_fun" name="mowas_fun" min="0" max="3" step="1" value="3" />


                <label for="broadcast_ric">Broadcast RIC</label>
                <input type="number" placeholder="RIC" id="broadcast_ric" name="broadcast_ric" min="1" max="2097152" step="1" value="1234" />
                <!-- <label for="broadcast_fun">Broadcast Function</label>
                <input type="number" placeholder="Function" id="broadcast_fun" name="broadcast_fun" min="0" max="3" step="1" value="3" /> -->

                <div class="button-group">
                    <input class="btn" type="submit" value="Set Settings" />
                </div>
            </form>
            <h2>DWD-WX Settings</h2>
            <form action="/setdwdwx" class="styled-form no-top-margin">
                <label for="dwdwx_enable">Enable DWD-WX</label>
                <input type="checkbox" name="dwdwx_enable"/>
                <label for="dwdwx_fun">DWD-WX Function</label>
                <input type="number" placeholder="Function" id="dwdwx_fun" name="dwdwx_fun" min="0" max="3" step="1" value="3" />

                <label for="dwdwx_lng">Longitude</label>
                <input type="number" placeholder="Longitude" step="0.00001"  id="dwdwx_lng" name="dwdwx_lng" />
                <label for="dwdwx_lat">Latitude</label>
                <input type="number" placeholder="Latitude" step="0.00001" id="dwdwx_lat" name="dwdwx_lat" />

                <label for="dwdwx_schedule">Schedule</label>
                <select name="dwdwx_schedule">
                    <option value="0">300,600,900,1200,1500,1800,2100,2400</option>
                    <option value="1">600,900,1200,1500,1800,2100,2400</option>
                    <option value="2">600,1200,1800,2400</option>
                </select>

                <div class="button-group">
                    <input class="btn" type="submit" value="Set WX-Settings" />
                </div>
            </form>
        </div>
        <div id="Time / Idle Beacon" class="tabcontent">
            <h2>Time Beacon</h2>
            <form action="/settimebeacon" class="styled-form no-top-margin">
                <label for="time_enable">Enable</label>
                <input type="checkbox" name="time_enable"/>
                
                <label for="time_interval">Interval (minutes)</label>
                <input type="number" placeholder="5m" id="time_interval" name="time_interval" min="1" max="1440" step="1" value="5" />

                <label for="time_zone">Timezone</label>
                <select placeholder="Timezone" id="time_zone" name="time_zone">
                </select>

                <label for="time_ric">RIC</label>
                <input type="number" placeholder="RIC" id="time_ric" name="time_ric" min="1" max="2097152" step="1" value="1234" />

                <label for="time_fun">Function</label>
                <input type="number" placeholder="Function" id="time_fun" name="time_fun" min="0" max="3" step="1" value="3" />

                <label for="time_mode">Mode</label>
                <select name="time_mode">
                    <option value="0">TPL-Time (Service OTA, Func 1/B)</option>
                    <option value="1">German TPL-Time(ZEIT)</option>
                    <option value="2">Swissphone Time</option>
                </select>
                
                <div class="button-group">
                    <input class="btn" type="submit" value="Set Time Beacon Settings" />
                </div>
            </form>
            <h2>Trigger Time Beacon</h3>
            <form action="/trigger-time" class="styled-form no-top-margin">
                <div class="button-group">
                    <input class="btn" type="submit" value="trigger time beacon" />
                </div>
            </form>
            <h2>Idle Beacon</h2>
            <form action="/setidlebeacon" class="styled-form no-top-margin">
                <label for="idle_enable">Enable</label>
                <input type="checkbox" name="idle_enable"/>

                <label for="idle_interval">Interval (minutes)</label>
                <input type="number" placeholder="5m" id="idle_interval" name="idle_interval" min="1" max="1440" step="1" value="5" />

                <label for="idle_mode">Mode</label>
                <select name="idle_mode">
                    <option value="0">Numeric NET-ID > RIC 8</option>
                </select>

                <label for="idle_netid">Net-ID</label>
                <input type="number" placeholder="1234" id="idle_netid" name="idle_netid" step="1"/>

                <div class="button-group">
                    <input class="btn" type="submit" value="Set Idle Beacon Settings" />
                </div>
            </form>
        </div>
        <div id="SysOp / Update" class="tabcontent">
            <h2>SysOp / Update Notifications</h2>
            <form action="/setsysop" class="styled-form no-top-margin">
                <label for="sysop_enable">Enable</label>
                <input type="checkbox" name="sysop_enable"/>

                <label for="sysop_ric">RIC</label>
                <input type="number" placeholder="RIC" id="sysop_ric" name="sysop_ric" min="1" max="2097152" step="1" value="1234" />

                <label for="sysop_fun">Function</label>
                <input type="number" placeholder="Function" id="sysop_fun" name="sysop_fun" min="0" max="3" step="1" value="3" />

                <div class="button-group">
                    <input class="btn" type="submit" value="Set SysOp" />
                </div>
            </form>
            <h4 id="versionText">Current Version: ? | Available Version: ?</h4>
            <form action="/update/do" id="doUpdateBtn" style="display: none;" class="styled-form no-top-margin">
                <div class="button-group">
                    <input class="btn" type="submit" value="Update Firmare" />
                </div>
            </form>
        </div>
        <div id="About" class="tabcontent">
            <h4>Code: Cheetah van Oranje (<a href="https://t.me/spottychee">@spottychee</a> / cheetah.cat)</p>
            <h4>Idea: <a href="https://t.me/MUC80937">@MUC80937</a>.</p>
            <h4>Legal & License</h4>
            <p>© 2025 Cheetah van Oranje – All rights reserved unless otherwise noted.</p>
            <p>Unauthorized copying, redistribution, or commercial use is strictly prohibited.</p>
            <h4>Disclaimer:</h4>
            <p>This tool is for educational and experimental use only. Always comply with your local RF regulations when transmitting signals.</p>
        </div>
    </div>
    <script src="script.js"></script>
</body>
</html>