LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-13-2009, 12:02 AM   #1
hadrix
LQ Newbie
 
Registered: Jul 2009
Posts: 4

Rep: Reputation: 0
Bluez Programming - set scan mode with normal user


Hi all.

I have writen a bluez code for setting up bluetooth mode. Here is a function to set the mode to discoverable.

Code:
void discoverable()
{
	int dd, ctl, err;
	struct hci_dev_req dr;
	dd = hci_get_route(NULL);
	dr.dev_id = dd;
	dr.dev_opt = SCAN_PAGE | SCAN_INQUIRY;
	
	ctl = hci_open_dev(dd);
	if (ctl < 0) {
		err = -errno;
		error("Can't open device hci%d: %s (%d)",
				dd, strerror(errno), errno);
		exit(1);
	}
	if (ioctl(ctl, HCISETSCAN, dr.dev_id) < 0) {
		fprintf(stderr, "Can't set scan mode on hci%d: %s (%d)\n",
						dd, strerror(errno), errno);
		exit(1);
	}
}
the output that i got is:
Code:
Can't set scan mode on hci0: Permission denied (13)
I am suspect that it fail to write the mode since it run with normal user. Is there any way to run this function without superuser previlige in the source code?
 
Old 07-13-2009, 06:15 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
You can use udev to set the permissions of the bluetooth device. In fact, depending on your current rules, all you might need to do is add your user to the bluetooth group.
 
Old 07-14-2009, 12:52 AM   #3
hadrix
LQ Newbie
 
Registered: Jul 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for your reply.I have try to change bluetooth.conf in /etc/dbus-1/system.d from root to normal user from

Code:
 <policy user="root">
    <allow own="org.bluez"/>
  </policy>
to

Code:
 <policy user="user">
    <allow own="org.bluez"/>
  </policy>
Seems like nothing much changes. Actually how to add user in bluetooth group? Still not know how to add it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bluez + hcitool not able to scan kewl Linux - Software 3 06-23-2009 03:40 PM
Linux Wireless access in normal user mode msskiran Linux - Networking 3 06-16-2009 12:08 AM
Cannot access Graphical mode as normal user. Why not!? fc6_user Slackware - Installation 16 06-06-2007 10:34 PM
DC-Gui, Active mode as normal user? Borka Linux - Software 0 06-25-2004 06:22 AM
mplayer - in normal user mode problem ruhl22 Linux - Software 1 06-20-2004 01:20 PM


All times are GMT -5. The time now is 09:50 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration