예제 #1
0
파일: avctp.c 프로젝트: BirdAndEarth/RPi
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;
}
예제 #2
0
파일: bnep.c 프로젝트: ghent360/bluez
static bool setup_conn_req(struct bnep_frame *bnep_frame, uint8_t indent)
{

	struct l2cap_frame *frame = &bnep_frame->l2cap_frame;
	uint8_t uuid_size;
	uint32_t src_uuid = 0, dst_uuid = 0;

	if (!l2cap_frame_get_u8(frame, &uuid_size))
		return false;

	print_field("%*cSize: 0x%02x ", indent, ' ', uuid_size);

	switch (uuid_size) {
	case 2:
		if (!l2cap_frame_get_be16(frame, (uint16_t *) &dst_uuid))
			return false;

		if (!l2cap_frame_get_be16(frame, (uint16_t *) &src_uuid))
			return false;
		break;
	case 4:
		if (!l2cap_frame_get_be32(frame, &dst_uuid))
			return false;

		if (!l2cap_frame_get_be32(frame, &src_uuid))
			return false;
		break;
	case 16:
		if (!l2cap_frame_get_be32(frame, &dst_uuid))
			return false;

		l2cap_frame_pull(frame, frame, 12);

		if (!l2cap_frame_get_be32(frame, &src_uuid))
			return false;

		l2cap_frame_pull(frame, frame, 12);
		break;
	default:
		l2cap_frame_pull(frame, frame, (uuid_size * 2));
		return true;
	}

	print_field("%*cDst: 0x%x(%s)", indent, ' ', dst_uuid,
						bt_uuid32_to_str(dst_uuid));
	print_field("%*cSrc: 0x%x(%s)", indent, ' ', src_uuid,
						bt_uuid32_to_str(src_uuid));
	return true;
}
예제 #3
0
파일: avctp.c 프로젝트: BirdAndEarth/RPi
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;
}
예제 #4
0
파일: avctp.c 프로젝트: BirdAndEarth/RPi
static bool avrcp_get_element_attributes(struct avctp_frame *avctp_frame,
						uint8_t ctype, uint8_t len,
						uint8_t indent)
{
	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
	uint64_t id;
	uint8_t num;

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	if (!l2cap_frame_get_be64(frame, &id))
		return false;

	print_field("%*cIdentifier: 0x%jx (%s)", (indent - 8), ' ',
					id, id ? "Reserved" : "PLAYING");

	if (!l2cap_frame_get_u8(frame, &num))
		return false;

	print_field("%*cAttributeCount: 0x%02x", (indent - 8), ' ', num);

	for (; num > 0; num--) {
		uint32_t attr;

		if (!l2cap_frame_get_be32(frame, &attr))
			return false;

		print_field("%*cAttribute: 0x%08x (%s)", (indent - 8),
					' ', attr, mediattr2str(attr));
	}

	return true;

response:
	switch (avctp_frame->pt) {
	case AVRCP_PACKET_TYPE_SINGLE:
	case AVRCP_PACKET_TYPE_START:
		if (!l2cap_frame_get_u8(frame, &num))
			return false;

		avrcp_continuing.num = num;
		print_field("%*cAttributeCount: 0x%02x", (indent - 8),
								' ', num);
		len--;
		break;
	case AVRCP_PACKET_TYPE_CONTINUING:
	case AVRCP_PACKET_TYPE_END:
		num = avrcp_continuing.num;

		if (avrcp_continuing.size > 0) {
			uint16_t size;

			if (avrcp_continuing.size > len) {
				size = len;
				avrcp_continuing.size -= len;
			} else {
				size = avrcp_continuing.size;
				avrcp_continuing.size = 0;
			}

			printf("ContinuingAttributeValue: ");
			for (; size > 0; size--) {
				uint8_t c;

				if (!l2cap_frame_get_u8(frame, &c))
					goto failed;

				printf("%1c", isprint(c) ? c : '.');
			}
			printf("\n");

			len -= size;
		}
		break;
	default:
		goto failed;
	}

	while (num > 0 && len > 0) {
		uint32_t attr;
		uint16_t charset, attrlen;

		if (!l2cap_frame_get_be32(frame, &attr))
			goto failed;

		print_field("%*cAttribute: 0x%08x (%s)", (indent - 8),
						' ', attr, mediattr2str(attr));

		if (!l2cap_frame_get_be16(frame, &charset))
			goto failed;

		print_field("%*cCharsetID: 0x%04x (%s)", (indent - 8),
				' ', charset, charset2str(charset));

		if (!l2cap_frame_get_be16(frame, &attrlen))
			goto failed;

		print_field("%*cAttributeValueLength: 0x%04x",
						(indent - 8), ' ', attrlen);

		len -= sizeof(attr) + sizeof(charset) + sizeof(attrlen);
		num--;

		print_field("%*cAttributeValue: ", (indent - 8), ' ');
		for (; attrlen > 0 && len > 0; attrlen--, len--) {
			uint8_t c;

			if (!l2cap_frame_get_u8(frame, &c))
				goto failed;

			printf("%1c", isprint(c) ? c : '.');
		}

		if (attrlen > 0)
			avrcp_continuing.size = attrlen;
	}

	avrcp_continuing.num = num;
	return true;

failed:
	avrcp_continuing.num = 0;
	avrcp_continuing.size = 0;
	return false;
}