FMP24 with Linux and Wine

Status
Not open for further replies.

ianb

Member
Joined
May 12, 2020
Messages
22
Press F12 in Chrome web browser to inspect console output for any errors and ensure that under Network with WS filter on that you have an open connection to the socket. If not, try right clicking on the connection and opening in new tab and change the prefix wss:// to https:// so that Chrome will ask you to verify your self-signed certificate then reload the page.

Also ensure that you are running the PHP Ratchet WebSocket via Terminal Window with a command like below
php /var/www/html/bin/server.php


1602282203400.png
 

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
Yep, I have the PHP Ratchet WebSocket going in the terminal, and this is what I get.
wss.png

Not quite sure what I'm doing wrong, but I suspect I may have something screwed up with my Apache2 config for SSL sites, since I can't even look at a simple index.html over https. Could also be an issue with my self signed certificate and key, not sure. I made it twice just to make sure, and made sure it was placed in the same folder your script called for. I can get to the CEM over http, but not https. Could also just be some other config file somewhere, or some place I was supposed to specify a directory and put something wrong.
 

ianb

Member
Joined
May 12, 2020
Messages
22
Yep, I have the PHP Ratchet WebSocket going in the terminal, and this is what I get.
View attachment 92493

Not quite sure what I'm doing wrong, but I suspect I may have something screwed up with my Apache2 config for SSL sites, since I can't even look at a simple index.html over https. Could also be an issue with my self signed certificate and key, not sure. I made it twice just to make sure, and made sure it was placed in the same folder your script called for. I can get to the CEM over http, but not https. Could also just be some other config file somewhere, or some place I was supposed to specify a directory and put something wrong.


Checkout this page for configuring Apache SSL - once you can load CEM via https you can move on to configuring server.php with the SSL certificate and key file you've created or that is being used by apache2 configs.


Highly un-recommended, but you could downgrade to http without SSL by changing wss:// to ws:// in script.js and modifying server.php to something along the lines of below - then you will need to adapt to the non secure server class of Ratchet and read up on that.

$secure_websockets = new \React\Socket\SecureServer($secure_websockets, $loop, [
to
$secure_websockets = new \React\Socket\Server($secure_websockets, $loop, [
 
Last edited:

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
Okay, I've got my SSL straightened out and can get over there over HTTPS, but I still ain't having much luck connecting to wss://localhost/events

Question I have is, where is const socket = new WebSocket('wss://localhost:443/events/'); pointing at locally on my machine? Is that an instance created by PHP Ratchet WebSocket or is that supposed to be a local folder on my computer.
 

ianb

Member
Joined
May 12, 2020
Messages
22
Okay, I've got my SSL straightened out and can get over there over HTTPS, but I still ain't having much luck connecting to wss://localhost/events

Question I have is, where is const socket = new WebSocket('wss://localhost:443/events/'); pointing at locally on my machine? Is that an instance created by PHP Ratchet WebSocket or is that supposed to be a local folder on my computer.

- Ratchet WebSocket is running on port 8080 as configured in bin/server.php
- Check script.js line 1 and point to wss://localhost:8080/events
 

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
Okay, went back at it for a little while, finally figured out that CEM didn't like the certificate and key I made, or probably where they were stored wasn't accessible by CEM, so I had to put them in a folder that had full read-write access. Probably not the best security, but it'll do for now. Now that I've got some things working, I'll have to comb through it and tweak it a little along here and there, find out what all kinds of things I can do with it.

CEM-working.png

I'd also like to take this opportunity to say how much of a pain in the @$$ it is to get Chrome to accept self signed certificates. I still haven't gotten it to do it, at least Firefox let's me acknowledge the fact and continue anyways.

So, thanks again @ianb for sharing your project, and for putting up with some of the dumb things I was doing trying to figure out what the hell I was trying to do. I didn't even realize until later on that the Rachet Socket server.php was its own web instance, I was trying to configure apache2 to use port 8080 and those certs as well, which is isn't configured to do by default and I found out that Ratchet only wants to use ports in user land. You were probably wondering what in the heck I was trying to do.

So, thanks again.
 

ianb

Member
Joined
May 12, 2020
Messages
22
Okay, went back at it for a little while, finally figured out that CEM didn't like the certificate and key I made, or probably where they were stored wasn't accessible by CEM, so I had to put them in a folder that had full read-write access. Probably not the best security, but it'll do for now. Now that I've got some things working, I'll have to comb through it and tweak it a little along here and there, find out what all kinds of things I can do with it.

View attachment 92497

I'd also like to take this opportunity to say how much of a pain in the @$$ it is to get Chrome to accept self signed certificates. I still haven't gotten it to do it, at least Firefox let's me acknowledge the fact and continue anyways.

So, thanks again @ianb for sharing your project, and for putting up with some of the dumb things I was doing trying to figure out what the hell I was trying to do. I didn't even realize until later on that the Rachet Socket server.php was its own web instance, I was trying to configure apache2 to use port 8080 and those certs as well, which is isn't configured to do by default and I found out that Ratchet only wants to use ports in user land. You were probably wondering what in the heck I was trying to do.

So, thanks again.


Great to hear! I'll take our troubleshooting steps and update the documentation to be a bit more straightforward without as much assumption required.

Yes, Ratchet WebSocket, is a server within itself, apart from apache and works to push down new content. Initially, when I tried using jQuery on a timer to repeatedly make GET requests even with one or two tabs open the I/O was horrendous where as this solutions tracks each particular client (user) and sends last recent 200 events on load and anything new after that, thus reducing a lot of I/Of to clients that have certain data etc. A quiet 20 minutes can go by without any outbound requests and then a lightweight JSON response arrives via WS and is processed by event driven JavaScript which allows 5 users to connect to a small PI without overloading Apache on GET requests from timers and also by not needing to open several ports via streaming, trying to listen to multiple streams at once without easy playback or downloadabily.

Anyways, your questions are valid and the certificate issue is likely permission related as you suggested and can be resolved by creating groups for apache / www-data - you'll need to read up more on that to effectively secure your certificate files from being downloaded. A .htacess file may also prevent downlading.

Checkout sever.php getRtl433Events function to see how rtl_433 messages for door sensors are parsed so that you can populate more useful data such as the temperature, humidity or whatever is available to the environment/frequency you're monitoring.


One thing I noted which I'll look to fix is the WebSocket can be accessed from any instance without logging in via htacess authorisation prompt, file names and LRRP are sent out - with files only acessible after authorisation, but LRRP coordinates sent.. so I'll try to patch this soon.


I'm mumbling now - but in the future I'll look to add a direct way of writing to DSD .radios/groups files so that you can click a message from CEM and type a name for the unit or group and have it updated. Then, I've been testing free Python Transcriber to try and dictate audio to text so that you could read messages in text format, but it seems that it will take some noise filtering techniques to get intelligible responses. If achievable one could have 'trigger' words to prioritise etc.



Have a good evening and let me know if you have any other questions.
 
Last edited:

ianb

Member
Joined
May 12, 2020
Messages
22
If you prefer Firefox then power to you - if you want to try Chrome - the 'trick' I use is to take the WebSocket Server address and replace wss:// with https:// and visit it in Chrome browser like - https://localhost:8080 then click 'Advanced' and 'Proceed to localhost (unsafe). If a week later you have random issues you may have to re-do this trick so registering the unsigned certificate may payoff or just getting a 'cheap' signed one if you want to scale up a bit.

1602305567092.png
 

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
Yeah, I was able to get Chrome to accept a certificate from port 8080/events, but not from the apache2 server. Not sure why, I can browse to it over http://localhost and connect to the secure elements to view things. I'm just going to go with Firefox though, its my main browser for anything that isn't Google/YouTube.

Also, I found in api.php you have some hard coded directories for where the wav files are stored. I had to change those before I could get audio playback to work. That also seems to be something that only works in Firefox for me, can't get any audio playback in Chrome. May be related to above mentioned issue.
 

ianb

Member
Joined
May 12, 2020
Messages
22
Yeah, I was able to get Chrome to accept a certificate from port 8080/events, but not from the apache2 server. Not sure why, I can browse to it over http://localhost and connect to the secure elements to view things. I'm just going to go with Firefox though, its my main browser for anything that isn't Google/YouTube.

Also, I found in api.php you have some hard coded directories for where the wav files are stored. I had to change those before I could get audio playback to work. That also seems to be something that only works in Firefox for me, can't get any audio playback in Chrome. May be related to above mentioned issue.

I'll look to make a settings file soon to reduce most of the hard-coding.

I'm not sure why it wont work with Chrome if you visit ( https://localhost or https://localhost:443 ) and if promoted with "Your connection is not private" press the Advanced button and click "Proceed to localhost (unsafe)". If you still have issues though perhaps it's something different and Firefox is still a pretty good option. I may look for a 'cheap' (sub $10 CAD) for a signed SSL and then have no hassle even sharing online to friends etc. Since the socket is on the same domain and uses a different port, I know from a past bingo game we shared the certificate and any browser would trust it without approval, though we paid around $50-100 CAD for that.

Audio playback issue is probably SSL related as well since api.php returns mime type audio/wav with and the selected file - this allows recordings to be stored in different directories and amalgamate different sources that don't need to be hosted by Apache.
 

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
Yeah, I'm not sure, I got the option for Advanced button and click "Proceed to localhost (unsafe)" when going to https://localhost:8080/events and was able to accept it, but no such option when trying to browse to https://localhost, so again, I think its something with how certificates are set up on my end. As far as getting a cheap signed certificate from an authority, don't worry about doing something like that just because of me. I only plan on using this kind of set up on my local area network, and I'll figure out that certificate thing eventually.

I think the reason I'm not getting playback in Chrome though, is that that script.js calls for api.php over https, and with Chrome not allowing that currently, I'll just use Firefox which I usually do anyways.
Code:
function readWaveFile(file) {

    var strUrl = 'https://localhost/api.php?' + $.param({ cmd: 'ReadWaveFile', file: file });
    console.log('Read Wave File', [file]);
    audioPlayer.src = strUrl;
    audioPlayer.play();
}
 

ianb

Member
Joined
May 12, 2020
Messages
22
Hello,

I've made some updates to the project including the following.


1. A new config file has been created in src/config.php which has all directories, certificates and login info clearly defined in one file.

2. Login page is now optional which ensures that API and WebSocket connections are authorised, which is a bit more secure than before since .htaccess did not prevent Ratchet WebSocket connections on port 8080

3. Some minor tweaks throughout for file and directory checks as well for empty arrays.



I'll look at another I/O improvement that would prevent DSD+ logs from being parsed unless the file changed and has additional lines.



Optional Login Page

1602357712788.png


App Config File
1602357595569.png


Ratchet WebSocket - Login Messages

1602358494151.png
 

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
I decided to nuke my last install and try out the new revision of it, along with lessons learned last time, I was able to get everything up and working in about an hour or less. I do have to give you props for taking some things I was having issues with and taking that info and quickly turning around and implementing a config file out of it.

Some takeaways I had about the current version. Not so much anything I'm nitpicking about, but just observations and questions.

1) You still have some entries in script.js where you have to specify the web address.
Code:
var WebSocketAdress = "wss://josieinthedark.ddns.net:8080/events";
if (isDebug) {
    WebSocketAdress = "wss://192.168.0.150:8080/events";
--skip to line 486---
function readDSDWaveFile(instance, date, time) {

    var strUrl = 'https://josieinthedark.ddns.net/api.php?' + $.param({ cmd: 'ReadDSDWaveFile', instance: instance, date: date, time: time });
    // console.log('Read DSD Wave File', [instance, date, time]);
    audioPlayer.src = strUrl;
    audioPlayer.play();
}

function downloadDSDWaveFile(instance, date, time) {

    var strUrl = 'https://josieinthedark.ddns.net/api.php?' + $.param({ cmd: 'ReadDSDWaveFile', instance: instance, date: date, time: time });
    window.open(strUrl, '_blank');
}



function readWaveFile(file) {

    var strUrl = 'https://josieinthedark.ddns.net/api.php?' + $.param({ cmd: 'ReadWaveFile', file: file });
    console.log('Read Wave File', [file]);
    audioPlayer.src = strUrl;
    audioPlayer.play();
}

Anyway to just consolidate all of these to the entry in the config.php file? Also, is there any user end difference between using 'debug' address if you have both set to localhost?

2.) In the server.php, there was some hard coded refernces to the CN and CYET file events, which would be fine assuming everybody had a CN and CYET to listen to or used the same folders at least. In my case, I just commented ended up doing this instead.

Code:
            // File Events
            //$this->FileEvents[0] = $this->getFileEvents(3, "CN");
            //$this->FileEvents[1] = $this->getFileEvents(4, "CYET");
            
            $this->FileEvents[0] = $this->getFileEvents(3, "");

3.) Since I am listening to NXDN48 instead of TIII, some of the event log info is a bit different, so I'll have to dig into the getDSDPlusEvents and tweak some of the info I get and what to do with it. Just one of those things I'll have to work on when I really feel like digging in and going at it.
Same with the info off of rtl_433. Since I'm looking at a weather station, I'll find a way to parse the info in the JSON to show me the humidity and temperature if nothing else. Simple enough, just one of those things to do when I actually feel like digging into code.

Again, I'll probably dig around and find things to tweak to my liking in the days and weeks to come. I'll report back and ask stuff if it occurs to me, and follow here and the github for any new things.

Thanks again, as always, for posting the project.
 

ianb

Member
Joined
May 12, 2020
Messages
22
Hello,

Thanks for the input and trying out the project as you've had useful responses and motivated me to fix the hard coding. I'm having a lot of fun bridging the gap between a bunch of useful radio data and something portable and ease of use. I've been making some improvements towards UI/UX - some are half implemented and I'll fix up several bugs as time goes by :rolleyes:


Mainly. I fixed the hard coded references in script.js (renamed to index.js) so that you should only need to edit config.php when updating to the latest version.

- Each instance now has audio controls (top left) with volume icon highlighted when playing. Mute and Volume are separate in that a muted source will not play new files, but will scroll to maintain position on new messages, if a message is clicked audio is played at the volume defined by the slider
- Chat Icon (top right) controls whether or not to scroll down to new messages which is useful when scrolling far back and not having the position scroll down automatically
- Improved playback with Howler.js
- rtl_433 will use temperature_F or temperature_C if when no state is returned
- An annoying yet fun changing colours to keep it fresh

 
Last edited:

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
Alright, now that I've had a chance to try out the latest greatest version, I can't really think of anything to add at this point, so I'll just share a screenshot of it all set up and customized, along with a note about the differences in logging between NXDN48 and DMR.

CEM-screenshot.png

About NXDN48 v DMR logging, I found that DMR logging is very nice and consistent, behold the following example as evidence.

Code:
2020/09/09  20:25:22  DSD+ 2.246 / Fast Lane Release
2020/09/09  20:25:22  [REDACTED]
2020/09/09  20:25:22  P25 data loaded; 2 networks, 8 sites, 17 channels
2020/09/09  20:25:22  Fusion decoding enabled
2020/09/09  20:25:22  D-STAR decoding enabled
2020/09/09  20:25:22  NXDN4800 decoding enabled
2020/09/09  20:25:22  NXDN9600 decoding enabled
2020/09/09  20:25:22  DMR/MotoTRBO decoding enabled
2020/09/09  20:25:22  P25 Phase 1 and Phase 2 decoding enabled
2020/09/09  20:25:22  X2-TDMA decoding enabled
2020/09/09  20:25:22  ProVoice decoding enabled
-----------------------DMR-------------------------
2020/06/18  06:22:42  Group call; TG=1  RID=60094   Slot=1  2s
2020/06/18  06:22:46  Group call; TG=1  RID=60086   Slot=1  1s
2020/06/18  06:31:57  Group call; TG=1  RID=60002   Slot=1  2s
2020/06/18  06:32:01  Group call; TG=1  RID=60086   Slot=1  1s
2020/06/18  06:32:19  Group call; TG=1  RID=60021   Slot=1  7s
2020/06/18  06:32:28  Group call; TG=1  RID=60086   Slot=1  1s
------------------NXDN48-------------------------------------
2020/09/09  20:37:40  Group call; RID=14 [........rl@]    1s
2020/09/09  20:37:44  Group call; RID=1000 [Live Oak]    1s
2020/09/09  20:37:46  Group call; RID=14 [........ront....]    2s
2020/09/09  20:37:52  Group call; RID=1000 [Live Oak]    1s
2020/09/09  20:38:36  Enc Group call; RID=100 [1034]    Alg=Sc  1s
2020/09/09  20:38:41  Group call; RID=1000 [Live Oak]
2020/09/09  20:38:42  Group call; RID=100 [1034]    3s
2020/09/09  20:38:49  Group call; RID=1000 [Live Oak]
2020/09/09  20:38:56  Group call; RID=109 [SAFETY 1]    2s
2020/09/09  20:39:01  Enc Group call; RID=1000 [Live Oak]    Alg=Sc
2020/09/09  20:39:03  Group call; RID=109 [SAFETY 1]    8s
2020/09/09  20:39:17  Group call; RID=1000 [Live Oak]    3s
2020/09/09  20:39:23  Group call; RID=9    1s
2020/09/09  20:39:28  Group call; RID=1000 [Live Oak]    1s
2020/09/09  20:39:30  Enc Group call; RID=9 [---]    Alg=Sc  4s

DMR is very nice and consistent, and NXDN can vary, so its hard to $arLine[n] and always get the same results, just depends on what else is going on. I resorted to using this code change in the server.php and tweaking index.js as well so I could use NXDN48.

Code:
--------server.php line 250--------------------         
          foreach ($lines as $index => $line) {

                if ($line == null || stripos($line, " neighbor: ") || !str_contains($line, "Group call;") ||str_contains($line, "Enc Group call;")) {
                    continue;
                }

                $arTwoSplit = array_filter(explode('Group call;', $line));
                $line = str_replace('  ', ';', str_replace("   ", ";", $arTwoSplit[1]));
                $arLine = array_filter(explode(';', $line));

                if (count($arLine) < 2) {
                    continue;
                }

                $date = trim(str_replace("  ", ' ', $arTwoSplit[0]));
                //$tg = trim(str_replace("TG=", '', $arLine[0]));
                //$rid = trim(str_replace("RID=", '', $arLine[1]));
                $rid = trim(str_replace("RID=", '', $arLine[0]));
                //$slot = trim(str_replace("Slot=", '', $arLine[2]));
                $duration = trim(str_replace("s", '', $arLine[1]));
                //echo "\nPrinting Variables from Events line 0: $arLine[0] ";
                //echo "\nPrinting Variables from Events line 1: $arLine[1] ";
                //echo "\nPrinting Variables from Events line 2: $arLine[2] ";
                //echo "\nPrinting Variables from Events line 3: $arLine[3] ";

                //$message = [$date, $tg, $rid, $slot, $duration];
                $message = [$date, $rid, $duration];
Doing above, I was able to get rid of those pesky Alg-Sc lines by adding the "Enc Group call" condition above. I'll probably write a second if statement to cover what to do with the lines that have "Enc Group call" in it.

I can't even remember what I did in index.js, think I just canned the line with ${tg} in it.
Also, still seem to get either 'invalid date' or 'undefined' in my first line in each box, not sure why.

Another thing, since I don't have any LRRP, I'm trying to think of another use for the map. Maybe aircraft telemetry with dump 1090? Sadly I don't have a log file handy to explore the possibility at the moment, and not many flights nearby in a rural area in the middle of the night.
 

ianb

Member
Joined
May 12, 2020
Messages
22
Nice updates! I'll push some more changes soon. I now have ADSB and LRRP on one map with options for zooming to aircraft level or down to 3d buildings. More to come but here are a few screenshots from my mobile while on the go.
 

Attachments

  • Screenshot_20201017-105325_Chrome.jpg
    Screenshot_20201017-105325_Chrome.jpg
    44.7 KB · Views: 15
  • Screenshot_20201017-105336_Chrome.jpg
    Screenshot_20201017-105336_Chrome.jpg
    44.6 KB · Views: 15

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
Well, I finally figured out one thing, although I can't say WHY it was a problem, but with the certificate issue I was having and getting it to work with Chrome, I figured out if I changed my apache2 site-available setting from:

<VirtualHost localhost:443>
--------to-------
<VirtualHost *:443>

and change the server settings in config.php to my local static ip address, it would work perfectly fine. I figured out this was a bigger issue when I attempted to connect from another computer at home and couldn't get through, and after trying all sorts of stupid stuff, I didn't realize apache2 was only set up to listen to localhost:443, so no other computers on my local network could connect, and for whatever reason, that also fixed the chrome issue on the same computer. WHY? I have no idea.

Oh, and something else I only just realized I have an issue with, not sure why yet, but I can't get any playback on other computers on my local area network when I click on an event. Works fine on my computer where I'm serving it up, but not on the client end.
 

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL
Oh, and something else I only just realized I have an issue with, not sure why yet, but I can't get any playback on other computers on my local area network when I click on an event. Works fine on my computer where I'm serving it up, but not on the client end.

Okay, I think I figured this one out. If the map hasn't loaded in yet, no playback will occur. When I was testing this out on my other computer on my LAN, it was configured for Internet access, just local area network access. The map wouldn't load up because of no internet access, and therefore, for some reason, playback of files wouldn't happen.
 

ianb

Member
Joined
May 12, 2020
Messages
22
Glad you've got it working. I've been busy with many things but i'm trying to get back to CEM improvements. A major performance update I have planned will be to read files from the tail end to prevent wasted cycles reading through the same lines of a large (10 Mb+) event file at each interval. Also, with ADS-B, I'm using a FlightFeeder with FA beast-splitter to ensure I'm feeding FA's service as well as parsing raw data for myself from faup1080 --stdout instead of aircraft.json which is the more common and probably easier to bind data to than tab separated values into arrays.
 

ianb

Member
Joined
May 12, 2020
Messages
22
I'm still cleaning up things in my spare time but hope to release a more solid version soon. Here is a short video of UI/UX changes so far. When using Linear Playback mode, events will be ordered in sequence to play when a free time becomes available.


 
Status
Not open for further replies.
Top