# ${proto.name} ICD

- Generated with PolyPacket on ${proto.genTime}
- CRC: ${proto.hash}
- Transport Encoding: (COBS) Consistent Overhead ByteStuffing

## Description:

${proto.desc}

## Index

%if len(proto.packets) > 0: Packets:

%for packet in proto.packets:
- ${"[%0.2X]" % packet.packetId} ${packet.name}
%endfor

%endif %if len(proto.structs) > 0: Structs:

%for struct in proto.structs:
- ${"[%0.2X]" % struct.packetId} ${struct.name}
%endfor

%endif

## Packets

### Ping

- Packet ID: [00]
- Requests: Ack

Ping to request an Ack. Used for testing and ICD verification

Fields:

Field | Type | Description
--- | --- | ---
icd | uint32_t | 32bit Hash of protocol description. This is used to verify endpoints are using the same protocol

### Ack

- Packet ID: [01]
- Responds To: Ping

This Packet type does not contain any data fields

%for packet in proto.packets: %if not packet.standard:

### ${packet.name}

- Packet ID: [${"%0.2X" % packet.packetId}]
%if packet.hasResponse:
- Requests: ${packet.response.name}
%endif %if len(packet.respondsTo) > 0:
- Responds To: \ %for idx,request in enumerate(packet.respondsTo): %if idx == 0: ${request}\ %else: , ${request}\ %endif %endfor
%endif

${packet.desc}

%if len(packet.fields) > 0:
Fields:

Field | Type | Description
--- | --- | ---
%for field in packet.fields:
%if field.isRequired: ${field.name} %else: | ${field.name} %endif | ${field.cType}\ %if field.isArray: [${field.arrayLen}]\ %endif | ${field.desc}\ %if field.isEnum: %for idx,val in enumerate(field.vals): ${field.valsFormat % idx} : ${val.name} - ${val.desc} %endfor %endif %if field.isMask: %for idx,val in enumerate(field.vals): ${field.valsFormat % (1 << idx)} : ${val.name} - ${val.desc} %endfor %endif
%endfor

%else: ## zero data fields This Packet type does not contain any data fields
%endif

%endif %endfor %if len(proto.structs) > 0:

## Structs

%for packet in proto.structs: %if not packet.standard:

### ${packet.name}

- Packet ID: [${"%0.2X" % packet.packetId}]
%if packet.hasResponse:
- Requests: ${packet.response.name}
%endif %if len(packet.respondsTo) > 0:
- Responds To: \ %for idx,request in enumerate(packet.respondsTo): %if idx == 0: ${request}\ %else: , ${request}\ %endif %endfor
%endif

${packet.desc}

%if len(packet.fields) > 0:
Fields:

Field | Type | Description
--- | --- | ---
%for field in packet.fields:
%if field.isRequired: ${field.name} %else: | ${field.name} %endif | ${field.cType}\ %if field.isArray: [${field.arrayLen}]\ %endif | ${field.desc}\ %if field.isEnum: %for idx,val in enumerate(field.vals): ${field.valsFormat % idx} : ${val.name} - ${val.desc} %endfor %endif %if field.isMask: %for idx,val in enumerate(field.vals): ${field.valsFormat % (1 << idx)} : ${val.name} - ${val.desc} %endfor %endif
%endfor

%else: ## zero data fields This Packet type does not contain any data fields
%endif

%endif %endfor %endif