Type each known TLV's value by its tag, on read and on write #30

Merged
lilleman merged 14 commits from tlv-types into main 2026-09-27 16:48:06 +02:00
2 changed files with 5 additions and 6 deletions
Showing only changes of commit 58e622143b - Show all commits
+4 -5
View File
@@ -434,11 +434,10 @@ rule and an index of the titles below.
`writeParams()` ignores it, so an empty one, an absent one and one the wire cannot carry are the `writeParams()` ignores it, so an empty one, an absent one and one the wire cannot carry are the
same input rather than three. A `data_coding` on a command that declares no such field is honoured same input rather than three. A `data_coding` on a command that declares no such field is honoured
the other way round, since it is `replace_sm`'s only way to name the alphabet its octets are in. the other way round, since it is `replace_sm`'s only way to name the alphabet its octets are in.
Rejected: refusing a string Rejected: refusing a string `message_payload` outright and demanding octets, which contradicts
`message_payload` outright and demanding `short_message` on the same PDU. Rejected: guarding every string-valued field against
octets, which contradicts `short_message` on the same PDU. Rejected: guarding every string-valued `data_coding`, which says nothing about them — a text field on the wire has an alphabet of its
field against `data_coding`, which says nothing about them — a text field on the wire has an own.
alphabet of its own.
- **A GSM 03.38 message declares `data_coding` 0x00, and an inbound 0x01 is still read as GSM.** - **A GSM 03.38 message declares `data_coding` 0x00, and an inbound 0x01 is still read as GSM.**
Maintainer's call, 2026-09-09: `dataCodingFor()` and `encodeBody()` both resolved an alphabet Maintainer's call, 2026-09-09: `dataCodingFor()` and `encodeBody()` both resolved an alphabet
+1 -1
View File
@@ -554,7 +554,7 @@ describe('TLVs', () => {
assert.deepEqual([id, state, unknown], ['0199d8a4-5e2c-7b3f-9a61-c4e07f2d8b15', 2, Buffer.from('01', 'hex')]); assert.deepEqual([id, state, unknown], ['0199d8a4-5e2c-7b3f-9a61-c4e07f2d8b15', 2, Buffer.from('01', 'hex')]);
// @ts-expect-error an octet field takes no number, which would go out as its digits // @ts-expect-error an octet field takes no number, which would go out as its digits
assert.ok(objToPdu({ cmdName: 'deliver_sm', params: {}, tlvs: { network_error_code: { tagValue: 5 } } })); objToPdu({ cmdName: 'deliver_sm', params: {}, tlvs: { network_error_code: { tagValue: 5 } } });
// @ts-expect-error message_state is an integer // @ts-expect-error message_state is an integer
assert.ok(objToPdu({ cmdName: 'deliver_sm', params: {}, tlvs: { message_state: { tagValue: 'ENROUTE' } } }).err); assert.ok(objToPdu({ cmdName: 'deliver_sm', params: {}, tlvs: { message_state: { tagValue: 'ENROUTE' } } }).err);
}); });