Header Encoding Test

The header element of a ribbit message is a blob of bits that contains the following information:

Following is a list of the fields and their bit lengths: 4bit (0-9) "nibble"
5bit (A-Z, -, space) "nibblebit"
Callsign is 8 character long to accommodate all countries. Location is encoded as Gridsquare8. Name is limited to 16+16 characters. Year/month is a number starting Jan2025 Time is a number starting on 1st of the month with a 14h offset to account for the date change time zone line. Each 2sec increment is a unit. 30 (2sec)×60min×24h×31.5 days

The version number is a nibble for 4 bits. Range: 0-15 This comes first in the header.

Year/month is a number starting Jan2025 Time is a number starting on 1st of the month with a 14h offset to account for the date change time zone line. Each 2sec increment is a unit. 30 (2sec)x60minx24hx31.5 days
Also note that the month begins with 0, not 1. so January is month 0, February is month 1, etc.

The gridsquare is a 6 character string that follows the pattern letter, letter, number, number, letter, letter. This Encoding allows for a pair of 5 bits, a pair of 4 bits, and a last pair of 5 bits for a total of 10bits 8bits 10bits, or 28bits. The first two letters are called the "Field", the next two numbers are the "Square", and the last two letters are the "Locator".

The callsign is a 8 character string using only letters. The so we only need 6 bits per character as they could be letters or numbers. But we need to encode all 8 characters to ensure the header is always the same length so the total is 48 bits.

The name is a 32 character string using only letters. The so we only need 5 bits per character. But we need to encode all 32 characters to ensure the header is always the same length so the total is 160 bits.
However, by putting the name at the end of the header, we only need to count the first set of bits of known length, then we can just read the rest of the header till we get to a special character indicating the end of the name.

Output

0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000