static void avrcp_get_play_status_dump(int level, struct frame *frm, uint8_t ctype, uint16_t len) { uint32_t interval; uint8_t status; if (ctype <= AVC_CTYPE_GENERAL_INQUIRY) return; p_indent(level, frm); if (len < 9) { printf("PDU Malformed\n"); raw_dump(level, frm); return; } interval = get_u32(frm); printf("SongLength: 0x%08x (%u miliseconds)\n", interval, interval); p_indent(level, frm); interval = get_u32(frm); printf("SongPosition: 0x%08x (%u miliconds)\n", interval, interval); p_indent(level, frm); status = get_u8(frm); printf("PlayStatus: 0x%02x (%s)\n", status, playstatus2str(status)); }
static bool avrcp_get_play_status(struct avctp_frame *avctp_frame, uint8_t ctype, uint8_t len, uint8_t indent) { struct l2cap_frame *frame = &avctp_frame->l2cap_frame; uint32_t interval; uint8_t status; if (ctype <= AVC_CTYPE_GENERAL_INQUIRY) return true; if (!l2cap_frame_get_be32(frame, &interval)) return false; print_field("%*cSongLength: 0x%08x (%u miliseconds)", (indent - 8), ' ', interval, interval); if (!l2cap_frame_get_be32(frame, &interval)) return false; print_field("%*cSongPosition: 0x%08x (%u miliseconds)", (indent - 8), ' ', interval, interval); if (!l2cap_frame_get_u8(frame, &status)) return false; print_field("%*cPlayStatus: 0x%02x (%s)", (indent - 8), ' ', status, playstatus2str(status)); return true; }
static void avrcp_register_notification_dump(int level, struct frame *frm, uint8_t ctype, uint16_t len) { uint8_t event, status; uint16_t uid; uint32_t interval; uint64_t id; p_indent(level, frm); if (ctype > AVC_CTYPE_GENERAL_INQUIRY) goto response; if (len < 5) { printf("PDU Malformed\n"); raw_dump(level, frm); return; } event = get_u8(frm); printf("EventID: 0x%02x (%s)\n", event, event2str(event)); p_indent(level, frm); interval = get_u32(frm); printf("Interval: 0x%08x (%u seconds)\n", interval, interval); return; response: if (len < 1) { printf("PDU Malformed\n"); raw_dump(level, frm); return; } event = get_u8(frm); printf("EventID: 0x%02x (%s)\n", event, event2str(event)); p_indent(level, frm); switch (event) { case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED: status = get_u8(frm); printf("PlayStatus: 0x%02x (%s)\n", status, playstatus2str(status)); break; case AVRCP_EVENT_TRACK_CHANGED: id = get_u64(frm); printf("Identifier: 0x%jx (%s)\n", id, id ? "Reserved" : "PLAYING"); break; case AVRCP_EVENT_PLAYBACK_POS_CHANGED: interval = get_u32(frm); printf("Position: 0x%08x (%u miliseconds)\n", interval, interval); break; case AVRCP_EVENT_BATT_STATUS_CHANGED: status = get_u8(frm); printf("BatteryStatus: 0x%02x (%s)\n", status, status2str(status)); break; case AVRCP_EVENT_SYSTEM_STATUS_CHANGED: status = get_u8(frm); printf("SystemStatus: 0x%02x ", status); switch (status) { case 0x00: printf("(POWER_ON)\n"); case 0x01: printf("(POWER_OFF)\n"); case 0x02: printf("(UNPLUGGED)\n"); default: printf("(UNKOWN)\n"); } break; case AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED: status = get_u8(frm); printf("AttributeCount: 0x%02x\n", status); for (; status > 0; status--) { uint8_t attr, value; p_indent(level, frm); attr = get_u8(frm); printf("AttributeID: 0x%02x (%s)\n", attr, attr2str(attr)); p_indent(level, frm); value = get_u8(frm); printf("ValueID: 0x%02x (%s)\n", value, value2str(attr, value)); } break; case AVRCP_EVENT_VOLUME_CHANGED: status = get_u8(frm) & 0x7F; printf("Volume: %.2f%% (%d/127)\n", status/1.27, status); break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: uid = get_u16(frm); printf("PlayerID: 0x%04x (%u)\n", uid, uid); p_indent(level, frm); uid = get_u16(frm); printf("UIDCounter: 0x%04x (%u)\n", uid, uid); break; } }
static bool avrcp_register_notification(struct avctp_frame *avctp_frame, uint8_t ctype, uint8_t len, uint8_t indent) { struct l2cap_frame *frame = &avctp_frame->l2cap_frame; uint8_t event, status; uint16_t uid; uint32_t interval; uint64_t id; if (ctype > AVC_CTYPE_GENERAL_INQUIRY) goto response; if (!l2cap_frame_get_u8(frame, &event)) return false; print_field("%*cEventID: 0x%02x (%s)", (indent - 8), ' ', event, event2str(event)); if (!l2cap_frame_get_be32(frame, &interval)) return false; print_field("%*cInterval: 0x%08x (%u seconds)", (indent - 8), ' ', interval, interval); return true; response: if (!l2cap_frame_get_u8(frame, &event)) return false; print_field("%*cEventID: 0x%02x (%s)", (indent - 8), ' ', event, event2str(event)); switch (event) { case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED: if (!l2cap_frame_get_u8(frame, &status)) return false; print_field("%*cPlayStatus: 0x%02x (%s)", (indent - 8), ' ', status, playstatus2str(status)); break; case AVRCP_EVENT_TRACK_CHANGED: if (!l2cap_frame_get_be64(frame, &id)) return false; print_field("%*cIdentifier: 0x%16" PRIx64 " (%" PRIu64 ")", (indent - 8), ' ', id, id); break; case AVRCP_EVENT_PLAYBACK_POS_CHANGED: if (!l2cap_frame_get_be32(frame, &interval)) return false; print_field("%*cPosition: 0x%08x (%u miliseconds)", (indent - 8), ' ', interval, interval); break; case AVRCP_EVENT_BATT_STATUS_CHANGED: if (!l2cap_frame_get_u8(frame, &status)) return false; print_field("%*cBatteryStatus: 0x%02x (%s)", (indent - 8), ' ', status, status2str(status)); break; case AVRCP_EVENT_SYSTEM_STATUS_CHANGED: if (!l2cap_frame_get_u8(frame, &status)) return false; print_field("%*cSystemStatus: 0x%02x ", (indent - 8), ' ', status); switch (status) { case 0x00: printf("(POWER_ON)\n"); break; case 0x01: printf("(POWER_OFF)\n"); break; case 0x02: printf("(UNPLUGGED)\n"); break; default: printf("(UNKOWN)\n"); break; } break; case AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED: if (!l2cap_frame_get_u8(frame, &status)) return false; print_field("%*cAttributeCount: 0x%02x", (indent - 8), ' ', status); for (; status > 0; status--) { uint8_t attr, value; if (!l2cap_frame_get_u8(frame, &attr)) return false; print_field("%*cAttributeID: 0x%02x (%s)", (indent - 8), ' ', attr, attr2str(attr)); if (!l2cap_frame_get_u8(frame, &value)) return false; print_field("%*cValueID: 0x%02x (%s)", (indent - 8), ' ', value, value2str(attr, value)); } break; case AVRCP_EVENT_VOLUME_CHANGED: if (!l2cap_frame_get_u8(frame, &status)) return false; status &= 0x7F; print_field("%*cVolume: %.2f%% (%d/127)", (indent - 8), ' ', status/1.27, status); break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: if (!l2cap_frame_get_be16(frame, &uid)) return false; print_field("%*cPlayerID: 0x%04x (%u)", (indent - 8), ' ', uid, uid); if (!l2cap_frame_get_be16(frame, &uid)) return false; print_field("%*cUIDCounter: 0x%04x (%u)", (indent - 8), ' ', uid, uid); break; case AVRCP_EVENT_UIDS_CHANGED: if (!l2cap_frame_get_be16(frame, &uid)) return false; print_field("%*cUIDCounter: 0x%04x (%u)", (indent - 8), ' ', uid, uid); break; } return true; }