Extend the AIS protocol with a new sentence [!ABVDM ]

Nikolay a year ago

Hello,

I need some advice, which is the better approach to add !ABVDM to the AisProtocolDecoder.

To extend the current one or to implement a new protocol, the only difference is the initial sentence - !ABVDM instead of !AIVDM

Anton Tananaeva year ago

Extending the existing one is what we usually prefer.

Nikolay a year ago

Is it possible to switch .text in PatternBuilder?

private static final Pattern PATTERN = new PatternBuilder()
.text("!AIVDM,")
.number("(d+),")
.number("(d+),")
.number("(d+)?,")
.expression(".,")
.expression("([^,]+),")
.any()
.compile();
Anton Tananaeva year ago

No, you need an expression.

Nikolay a year ago

What this expression should look like?

I thought that if I pass to Parser "!ABVDM,|!AIVDM,...." it would work, but it doesn't.

Would it be possible to get some help?

Anton Tananaeva year ago

I would probably do something like this:

.text("!")
.expression("A[DI]VDM,")
Nikolay a year ago
private static final Pattern PATTERN = new PatternBuilder()
            .text("!")
            .expression("A[BI]VDM,")
            .number("(d+),")                     // count
            .number("(d+),")                     // index
            .number("(d+)?,")                    // id
            .expression(".,")                    // radio channel
            .expression("([^,]+),")              // payload
            .any()
            .compile();

It works like a charm.
All tests passed successfully.

Thank you very much