/******************************************************************************* ** ** Function bta_gatts_uuid_compare ** ** Description Compare two UUID to see if they are the same. ** ** Returns TRUE if two uuid match; FALSE otherwise. ** *******************************************************************************/ BOOLEAN bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src) { UINT8 su[LEN_UUID_128], tu[LEN_UUID_128]; UINT8 *ps, *pt; /* any of the UUID is unspecified */ if (src.len == 0 || tar.len == 0) { return TRUE; } /* If both are 16-bit, we can do a simple compare */ if (src.len == 2 && tar.len == 2) { return src.uu.uuid16 == tar.uu.uuid16; } /* One or both of the UUIDs is 128-bit */ if (src.len == LEN_UUID_16) { /* convert a 16 bits UUID to 128 bits value */ bta_gatt_convert_uuid16_to_uuid128(su, src.uu.uuid16); ps = su; } else { ps = src.uu.uuid128; } if (tar.len == LEN_UUID_16) { /* convert a 16 bits UUID to 128 bits value */ bta_gatt_convert_uuid16_to_uuid128(tu, tar.uu.uuid16); pt = tu; } else { pt = tar.uu.uuid128; } return (memcmp(ps, pt, LEN_UUID_128) == 0); }
/******************************************************************************* ** ** Function bta_gattc_uuid_compare ** ** Description Compare two UUID to see if they are the same. ** ** Returns TRUE if two uuid match; FALSE otherwise. ** *******************************************************************************/ BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_precise) { UINT8 su[LEN_UUID_128], tu[LEN_UUID_128]; UINT8 *ps, *pt; /* any of the UUID is unspecified */ if (p_src == 0 || p_tar == 0) { if (is_precise) return FALSE; else return TRUE; } /* If both are 16-bit, we can do a simple compare */ if (p_src->len == 2 && p_tar->len == 2) { return p_src->uu.uuid16 == p_tar->uu.uuid16; } /* One or both of the UUIDs is 128-bit */ if (p_src->len == LEN_UUID_16) { /* convert a 16 bits UUID to 128 bits value */ bta_gatt_convert_uuid16_to_uuid128(su, p_src->uu.uuid16); ps = su; } else ps = p_src->uu.uuid128; if (p_tar->len == LEN_UUID_16) { /* convert a 16 bits UUID to 128 bits value */ bta_gatt_convert_uuid16_to_uuid128(tu, p_tar->uu.uuid16); pt = tu; } else pt = p_tar->uu.uuid128; return(memcmp(ps, pt, LEN_UUID_128) == 0); }