@canboat/canboatjs
Version:
Native javascript version of canboat
74 lines • 2.83 kB
TypeScript
import { PGN } from '@canboat/ts-pgns';
/**
* Build a raw PGN 126208 Command payload targeting PGN 126720 for Maretron
* proprietary device configuration. This bypasses canboatjs's structured
* 126208 encoder because Maretron's field index scheme doesn't match
* canboat's semantic field ordering for PGN 126720.
*
* Wire format (confirmed from live capture):
* ```
* [0] FC = 0x01 (Command)
* [1-3] Target PGN = 0x01EF00 (126720) LE
* [4] Priority + Reserved = 0xF8
* [5] Number of params = 0x04
* [6] Field idx 1
* [7-8] Mfr code packed = 0x9889 (mfr=137, rsvd=1, ind=4)
* [9] Field idx 2
* [10-11] Product code (LE)
* [12] Field idx 3
* [13-14] Sub-header = 0x0001
* [15+] Opcode + payload bytes
* ```
*
* @param dst Destination device address on the N2K bus
* @param productCode Maretron product code (e.g. 23603 for SIM100)
* @param opcodePayload Array of bytes: [opcode, ...data]
* @returns PGN object suitable for emission via nmea2000JsonOut
*/
export declare function buildMaretronConfigCommand(dst: number, productCode: number, opcodePayload: number[]): PGN & {
dst: number;
fields: {
data: string;
};
};
/**
* Build a raw PGN 126208 Command as an actisense-format hex string,
* suitable for emission via the nmea2000out event.
*
* @param dst Destination device address on the N2K bus
* @param productCode Maretron product code
* @param opcodePayload Array of bytes: [opcode, ...data]
* @returns Actisense serial format string
*/
export declare function buildMaretronConfigCommandActisense(dst: number, productCode: number, opcodePayload: number[]): string;
export interface MaretronConfigResponse {
productCode: number;
productName: string | undefined;
softwareCode: number;
opcode: number;
opcodeName: string | undefined;
payload: number[];
}
/**
* Parse a decoded PGN 126720 that matches the Maretron proprietary
* configuration format. Works with both the new maretronProprietaryConfiguration
* variant (which has named fields) and the generic maretronSlaveResponse.
*
* For maretronProprietaryConfiguration:
* fields.productCode, fields.softwareCode, fields.opcode, fields.payload
*
* For raw PGN objects with a data field, extracts bytes directly.
*
* @param pgn A decoded PGN 126720 object
* @returns Parsed Maretron config info, or null if not a Maretron config PGN
*/
export declare function parseMaretronConfigResponse(pgn: any): MaretronConfigResponse | null;
/**
* Get the product name for a Maretron product code.
*/
export declare function getMaretronProductName(productCode: number): string | undefined;
/**
* Get the opcode name for a Maretron config opcode.
*/
export declare function getMaretronOpcodeName(opcode: number): string | undefined;
//# sourceMappingURL=maretron.d.ts.map