BrandMeister / bm-rpt2aprs

Uploads repeaters of a BrandMeister network to APRS
MIT License
3 stars 4 forks source link

Callsign fix - Removes spaces and replaces with "-" #6

Closed pjao closed 7 years ago

pjao commented 7 years ago

Fix for second issue on https://github.com/BrandMeister/bm-rpt2aprs/issues/3

pjao commented 7 years ago

If you look at aprs.fi, there are lots of stations like this. Even two characters minus big strings.

I understand that at AX.25, should be callsign and minus following digits, but it looks like it as bean forgotten.

I could do it another way, just remove spaces and other unusable characters, and put it all together, in this case, use preg_replace or preg_match

Just a question, if you know, ids that have callsign with spaces exits? Or is it only the same callsign with multiple locations? Should not be used the same protocol as AX.25?

cyanide-burnout commented 7 years ago

Just a question, if you know, ids that have callsign with spaces exits? Or is it only the same callsign with multiple locations? Should not be used the same protocol as AX.25?

It should use different SSID. Specification exists to follow it. It says: TNC-2 format shall be used to pass APRS messages. Why do you prefer to not follow this?

http://www.aprs-is.net/specification.aspx http://www.aprs.org/aprs12.html https://www.tapr.org/pdf/AX25.2.2.pdf

pjao commented 7 years ago

Don't understand what to say, all world seams not following that, and aprs.fi don't care.

Why don't you reject out non standard callsigns at brandmeister?

If you don't want close this PR and get some fix to the issue.

cyanide-burnout commented 7 years ago

BM filters callsign when forwards to APRS. Please fix the code first to follow rules.

pjao commented 7 years ago

If you have already this filter, what is the reason you don't make it here.

We are all losing time and energy in something already done.

pjao commented 7 years ago

APRS Callsigns

APRS was originally built on top of AX.25, which limited each station to a six character callsign with an additional four bit secondary station identifier (SSID). This limit still exists on AX.25, but APRS stations operating exclusively on the APRS-IS Internet system aren't as limited.

Callsigns for AX.25 must:

Callsigns for APRS must:

Callsigns should be:

The APRS limitation of nine characters causes confusion as to if base callsigns of lengths 7-9 are allowed.

In this context alphanumeric is defined as any ASCII values in the range:

In addition to legally identifying callsigns and tactical calls, APRS defines additional calls which fall in these categories:

cyanide-burnout commented 7 years ago

If you have already this filter, what is the reason you don't make it here. We are all losing time and energy in something already done.

Because repeater list of BM is not a list of APRS callsigns. I do extract on APRSGate interface. Please don't debate. If you want to make this utility compatible to standard, use pcre to extract callsign from the repeater name at BM. You got applicable expression from me at this discussion.

pjao commented 7 years ago

What about now? Was this you talking about?

sm0tsc commented 7 years ago

Seems to work now

//SM0TSC - Johan

pjao commented 7 years ago

Thanks @sm0tsc !

I'm very please to know that is working fine!

I can know see SK0NN (https://aprs.fi/?c=raw&call=SK0NN) and SK0SX (https://aprs.fi/?c=raw&call=SK0SX&limit=50&view=normal).

cyanide-burnout commented 7 years ago

Doen't work properly. For example it gives success for AX1DCX-12223323123 where should not. I recommend to use preg_match and expression ^([A-Z0-9]{3,9}|[A-Z0-9]{3,7}-[0-9A-Z]|[A-Z0-9]{3,6}-1[0-5])([\s\/].*)?$ https://regex101.com/r/3iC8D5/2

sm0tsc commented 7 years ago

Ok will you guys update the code and I will implement it...

//Johan - SM0TSC

sm0tsc commented 7 years ago

I guess we also need a function to sanitize input and convert callsigns like SM6TKT/R

//Johan - SM0TSC

pjao commented 7 years ago

I chose to take a totally different approach.

I've created a function that transforms an input string into a valid callsign, making the most of the data provided by applying the AX.25 rules.

For the tests carried out, a valid callsign is always obtained and must correspond to the desired one: [SK0NN Stockholm] ==> [SK0NN] [SM6TKT/R] ==> [SM6TKT] [AX1DCX-12223323123] ==> [AX1DCX]

I'm running out of ideas, since the purpose would be to correct the callsign and send it, avoiding to the maximum discard this sending.

cyanide-burnout commented 7 years ago

Too complex :)

` function check($call) { if (preg_match('/^([A-Z0-9]{3,9}|[A-Z0-9]{3,7}-[0-9A-Z]|[A-Z0-9]{3,6}-1[0-5])((\s|\/).*)?$/', $call, $matches)) printf("%s --> %s\n", $call, $matches[1]); else printf("%s is invalid\n", $call); }

check("SK0NN Stockholm"); check("SM6TKT/R"); check("AX1DCX-1222332312"); check("R3ABM-11"); `

pjao commented 7 years ago

I think this was not originally done because aprs.fi already validated and discarded or maybe because the callsign field was supposed to be correctly filled in according to the registry.

The goal now was to work the string to make it something valid, most like the register and rules of ax.25.

Despite being somewhat complex, I think the goal is achieved with this PR. The issues raised have been resolved but have obviously increased the degree of complexity.

Most of the callsigns of "Johan - SM0TSC" were invalid, because they contained spaces, because they had bars and other cases, with this solution they are all valid. On the other hand, those who already had them valid remain exactly the same.

In terms of runtime may increase a few more cycles, but nothing significant, because, this script will always run with times longer than half an hour according to ax.25 recommendations.

nonoo commented 7 years ago

Please match the code formatting of the patch to the rest of the app.

pjao commented 7 years ago

@nonoo one day I'll get it at first time.