Narrow CodingSource to the two bodies, and file Locality's remaining work
Mirror / push (push) Has been cancelled
Test / test (20) (pull_request) Successful in 1m33s
Test / test (22) (pull_request) Successful in 32s
Test / test (24) (pull_request) Successful in 33s
Test / test (26) (pull_request) Successful in 40s
Test / lint (pull_request) Successful in 24s
Test / test (18) (pull_request) Successful in 32s
Mirror / push (push) Has been cancelled
Test / test (20) (pull_request) Successful in 1m33s
Test / test (22) (pull_request) Successful in 32s
Test / test (24) (pull_request) Successful in 33s
Test / test (26) (pull_request) Successful in 40s
Test / lint (pull_request) Successful in 24s
Test / test (18) (pull_request) Successful in 32s
This commit is contained in:
+3
-3
@@ -75,23 +75,23 @@ type ResolvedBody = {
|
||||
* What the PDU's data_coding describes, and so what may set it: short_message wherever it holds an
|
||||
* octet, since messageOctets() reads it there, and message_payload only where it does not.
|
||||
*/
|
||||
type CodingSource = 'caller' | 'message_payload' | 'short_message';
|
||||
type CodingSource = 'message_payload' | 'short_message';
|
||||
|
||||
function codingOf(params: Record<string, ParamValue | undefined>): number | undefined {
|
||||
return typeof params.data_coding === 'number' ? params.data_coding : undefined;
|
||||
}
|
||||
|
||||
/** Only the short_message the command's own table will write, since writeParams() ignores any other. */
|
||||
function resolveShortMessage(
|
||||
params: Record<string, ParamValue | undefined>,
|
||||
definition: CommandDefinition,
|
||||
): Result<{ params: Record<string, ParamValue | undefined>; source: CodingSource }> {
|
||||
// Only the short_message the command's own table will write, since writeParams() ignores any other.
|
||||
const message = definition.params?.short_message === undefined ? undefined : params.short_message;
|
||||
|
||||
if (Buffer.isBuffer(message)) {
|
||||
return {
|
||||
params: params.sm_length === undefined ? { ...params, sm_length: message.length } : params,
|
||||
source: message.length > 0 ? 'caller' : 'message_payload',
|
||||
source: message.length > 0 ? 'short_message' : 'message_payload',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user