Commit b047506b authored by captainwong's avatar captainwong

1.3.1

parent 4e780248
# Ademco Change Log
## 1.3.1
- compile with warning level 4
- change `static inline` function to micro
## 1.3.0
- add `file` for parse error
......
......@@ -616,7 +616,9 @@ int ademcoMakeXData(AdemcoXDataSegment* xdata,
}
int isAdemcoPacketId(const char* standard, const char* id, size_t len) {
return strncmp(standard, id, strlen(standard)) == 0;
size_t standard_len = strlen(standard);
len = standard_len < len ? standard_len : len;
return strncmp(standard, id, len) == 0;
}
static const char* const ids[AID_COUNT] = {
......@@ -1003,7 +1005,7 @@ AdemcoParseResult ademcoPacketParse(const ademco_char_t* buff, size_t len,
// crc
crc = 0;
for (const char* q = p; p - q < 4; p++) {
for (q = p; p - q < 4; p++) {
uint8_t h = char2hex(*p);
if (h == 0xFF) {
ADEMCO_FILL_PARSE_ERROR(err, p - buff, "crc contains non-hex characters");
......@@ -1014,7 +1016,7 @@ AdemcoParseResult ademcoPacketParse(const ademco_char_t* buff, size_t len,
// len
pkt->len = 0;
for (const char* q = p; p - q < 4; p++) {
for (q = p; p - q < 4; p++) {
uint8_t h = char2hex(*p);
if (h == 0xFF) {
ADEMCO_FILL_PARSE_ERROR(err, p - buff, "len contains non-hex characters");
......
......@@ -36,9 +36,8 @@ typedef uint32_t AdemcoZone;
#define ADEMCO_ID_MIN 1
#define ADEMCO_ID_MAX 999999 // 兼容性考虑,最大安定宝 ID 为 0x0F423F
#define ADEMCO_ID_SENTINEL (ADEMCO_ID_MAX + 1)
static inline int ademcoIsValidAdemcoId(AdemcoId ademcoId) {
return ADEMCO_ID_MIN <= ademcoId && ademcoId <= ADEMCO_ID_MAX;
}
#define ademcoIsValidAdemcoId(ademcoId) \
((ADEMCO_ID_MIN <= (ademcoId)) && ((ademcoId) <= ADEMCO_ID_MAX))
// 防区号为0时表示主机自身
#define ADEMCO_ZONE_FOR_MACHINE_SELF 0
......@@ -49,14 +48,12 @@ static inline int ademcoIsValidAdemcoId(AdemcoId ademcoId) {
#define ADEMCO_ZONE_SENTINEL (ADEMCO_ZONE_MAX + 1)
// 对任何主机类型,防区号是否合法(可以包含0防区)
static inline int ademcoIsValidZone(AdemcoZone zone) {
return ADEMCO_ZONE_FOR_MACHINE_SELF <= zone && zone <= ADEMCO_ZONE_MAX;
}
#define ademcoIsValidZone(zone) \
((ADEMCO_ZONE_FOR_MACHINE_SELF <= (zone)) && ((zone) <= ADEMCO_ZONE_MAX))
// 对任何主机类型,防区号是否合法(不可以包含0防区)
static inline int ademcoIsValidZoneStrict(AdemcoZone zone) {
return ADEMCO_ZONE_MIN <= zone && zone <= ADEMCO_ZONE_MAX;
}
#define ademcoIsValidZoneStrict(zone) \
((ADEMCO_ZONE_MIN <= (zone)) && ((zone) <= ADEMCO_ZONE_MAX))
#define ADEMCO_GG_MIN 0
#define ADEMCO_GG_MAX 99
......
......@@ -8,7 +8,7 @@
#define ADEMCO_VERSION_MAJOR 1
#define ADEMCO_VERSION_MINOR 3
#define ADEMCO_VERSION_PATCH 0
#define ADEMCO_VERSION_PATCH 1
#define ADEMCO_VERSION_IS_RELEASE 1
#define ADEMCO_VERSION_SUFFIX ""
......
......@@ -970,7 +970,7 @@ void hbComMakeRespA2_getMachineZones(HbComData* data,
*p++ = zones[i] & 0xFF;
*p++ = props[i];
}
*p++ = (count > 0) ? p1 : HbComResp_A2_p1_nomore;
*p++ = (count > 0) ? (uint8_t)p1 : (uint8_t)HbComResp_A2_p1_nomore;
data->len = (++p - data->data) & 0xFF;
hbSum(data->data, data->len);
}
......@@ -1042,7 +1042,7 @@ void hbComMakeRespAD_getMachineZoneLostConfig(HbComData* data,
*p++ = zones[i] & 0xFF;
}
}
*p++ = (count > 0) ? p2 : HbComResp_AD_p2_nomore;
*p++ = (count > 0) ? (uint8_t)p2 : (uint8_t)HbComResp_AD_p2_nomore;
data->len = (++p - data->data) & 0xFF;
hbSum(data->data, data->len);
}
......@@ -1063,10 +1063,10 @@ void hbComMakeRespB1_get3SectionMachineStatus(HbComData* data,
HbMachineStatus statusSec2,
HbMachineStatus statusSec3) {
memcpy(data->data, HbComResp_B1_head, 6);
data->data[6] = (statusMachine << 6) |
(statusSec1 << 4) |
(statusSec2 << 2) |
(statusSec3);
data->data[6] = ((uint8_t)statusMachine << 6) |
((uint8_t)statusSec1 << 4) |
((uint8_t)statusSec2 << 2) |
((uint8_t)statusSec3);
data->len = HbComResp_B1_len;
hbSum(data->data, data->len);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment