FreeBSD/usr.sbin/bluetooth/hccontrol/status.c
static int
hci_get_link_quality(int s, int argc, char **argv)
{
	ng_hci_get_link_quality_cp	cp;
	ng_hci_get_link_quality_rp	rp;
	int				n;

	switch (argc) {
	case 1:
		/* connection handle */
		if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
			return (USAGE);
  
		cp.con_handle = (uint16_t) (n & 0x0fff);
		cp.con_handle = htole16(cp.con_handle);
		break;

	default:
		return (USAGE);
	}

	/* send command */
	n = sizeof(rp);
	if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_STATUS,
			NG_HCI_OCF_GET_LINK_QUALITY),
			(char const *) &cp, sizeof(cp),
			(char *) &rp, &n) == ERROR)
		return (ERROR);

	if (rp.status != 0x00) {
		fprintf(stdout, "Status: %s [%#02x]\n", 
			hci_status2str(rp.status), rp.status);
		return (FAILED);
	}

	fprintf(stdout, "Connection handle: %d\n", le16toh(rp.con_handle));
	fprintf(stdout, "Link quality: %d\n", le16toh(rp.quality));
	
	return (OK);
}
/* Sent Get_Link_Quality command to the unit */
Sent Get_Link_Quality command to the unit
Sent Get_Link_Quality command to the unit
static int
hci_get_link_quality(int s, int argc, char **argv)
{
	ng_hci_get_link_quality_cp	cp;
	ng_hci_get_link_quality_rp	rp;
	int				n;
	switch (argc) {
	case 1:
		if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
			return (USAGE);
		cp.con_handle = (uint16_t) (n & 0x0fff);
		cp.con_handle = htole16(cp.con_handle);
		break;
	default:
		return (USAGE);
	}
	n = sizeof(rp);
	if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_STATUS,
			NG_HCI_OCF_GET_LINK_QUALITY),
			(char const *) &cp, sizeof(cp),
			(char *) &rp, &n) == ERROR)
		return (ERROR);
	if (rp.status != 0x00) {
		fprintf(stdout, "Status: %s [%#02x]\n", 
			hci_status2str(rp.status), rp.status);
		return (FAILED);
	}
	fprintf(stdout, "Connection handle: %d\n", le16toh(rp.con_handle));
	fprintf(stdout, "Link quality: %d\n", le16toh(rp.quality));
	return (OK);
}
static int hci_get_link_quality ( int s , int argc , char * * argv ) { ng_hci_get_link_quality_cp cp ; ng_hci_get_link_quality_rp rp ; int n ; switch ( argc ) { case 1 : if ( sscanf ( argv [ 0 ] , " " , & n ) != 1 || n <= 0 || n > 0x0eff ) return ( USAGE ) ; cp . con_handle = ( uint16_t ) ( n & 0x0fff ) ; cp . con_handle = htole16 ( cp . con_handle ) ; break ; default : return ( USAGE ) ; } n = sizeof ( rp ) ; if ( hci_request ( s , NG_HCI_OPCODE ( NG_HCI_OGF_STATUS , NG_HCI_OCF_GET_LINK_QUALITY ) , ( char const * ) & cp , sizeof ( cp ) , ( char * ) & rp , & n ) == ERROR ) return ( ERROR ) ; if ( rp . status != 0x00 ) { fprintf ( stdout , " \n " , hci_status2str ( rp . status ) , rp . status ) ; return ( FAILED ) ; } fprintf ( stdout , " \n " , le16toh ( rp . con_handle ) ) ; fprintf ( stdout , " \n " , le16toh ( rp . quality ) ) ; return ( OK ) ; }
Sent Get_Link_Quality command to the unit
Sent Get_Link_Quality command to the unit
/* connection handle */ /* send command */