mares_iconhd_freedive.h (1078B)
1 /* Internal matching of the Sirius freedive data response. */ 2 #ifndef MARES_ICONHD_FREEDIVE_H 3 #define MARES_ICONHD_FREEDIVE_H 4 5 #include <string.h> 6 #include "array.h" 7 8 #define SIRIUS 0x2F 9 #define OBJ_DIVE 0x3000 10 #define OBJ_DIVE_DATA 0x03 11 12 static int 13 mares_iconhd_freedive_unavailable (unsigned int model, const unsigned char *header, 14 unsigned int headersize, unsigned int index, unsigned int subindex, 15 const unsigned char *response, unsigned int length) 16 { 17 static const unsigned char suffix[] = {0x20, 0x00, 0x00, 0x08, 0, 0, 0, 0, 0, 0, 0, 0}; 18 19 // Two Sirius logs show this response for the data of a freedive (mode 5). 20 // Do not skip other modes, models or unexpected responses. 21 return model == SIRIUS && subindex == OBJ_DIVE_DATA && index >= OBJ_DIVE && 22 headersize >= 0x10 && array_uint16_le (header) == 1 && 23 (array_uint32_le (header + 0x0C) & 0x0F) == 5 && 24 length == 16 && response[0] == 0x80 && 25 response[1] == (index & 0xFF) && response[2] == ((index >> 8) & 0xFF) && 26 response[3] == subindex && memcmp (response + 4, suffix, sizeof (suffix)) == 0; 27 } 28 29 #endif