Skip to contentSkip to conversation

scan mode

PATCH Applied Claudio Takahasi 2 participants 4 messages Feb 13, 2006 – Feb 14, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scan mode

Hi guys,

This patch add/fix the following services:
1. Changed GetMode/SetMode arguments to string, instead of use byte
2. Added IsConnectable
3. Added IsDiscoverable

Next action:
- Discoverable timout functions.

Regards,
Claudio
--
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

hcid/dbus.h +6 -5
@@ -206,17 +206,18 @@
 #define DEV_SIG_DISCOVER_COMPLETE	"DiscoverComplete"
 #define DEV_SIG_DISCOVER_RESULT		"DiscoverResult"
 
-/* FIXME: Change to string
+/*
  * Scanning modes, used by DEV_SET_MODE
  * off: remote devices are not allowed to find or connect to this device
  * connectable: remote devices are allowed to connect, but they are not
  *              allowed to find it.
  * discoverable: remote devices are allowed to connect and find this device
+ * unknown: reserved to not allowed/future modes
  */
-#define MODE_OFF		0x00	
-#define MODE_CONNECTABLE	0x01	
-#define MODE_DISCOVERABLE	0x02	
-
+#define MODE_OFF		"off"
+#define MODE_CONNECTABLE	"connectable"
+#define MODE_DISCOVERABLE	"discoverable"
+#define MODE_UNKNOWN		"unknown"
 
 /* BLUEZ_DBUS_ERROR 
  * EFailed error messages signature is : su
hcid/dbus-device.c +46 -24

125 lines not on this page · raw message

hcid/dbus.c +2 -2
@@ -1054,7 +1054,7 @@
 	struct hci_request rq;
 	int id;
 	int dd = -1;
-	uint8_t scan_mode;
+	const char *scan_mode;
 
 	baswap(&tmp, local); local_addr = batostr(&tmp);
 	id = hci_devid(local_addr);
@@ -1123,7 +1123,7 @@
 	}
 
 	dbus_message_append_args(message,
-					DBUS_TYPE_BYTE, &scan_mode,
+					DBUS_TYPE_STRING, &scan_mode,
 					DBUS_TYPE_INVALID);
 
 	if (dbus_connection_send(connection, message, NULL) == FALSE) {
maintainer Applied
#1 lore raw

Hi Claudio,

Quoted 4 lines

This patch add/fix the following services:
1. Changed GetMode/SetMode arguments to string, instead of use byte
2. Added IsConnectable
3. Added IsDiscoverable

I applied the patch to keep it going, but we need to rework the data object associated with the device path. Using it like this

	const uint8_t hci_mode = dbus_data->path_data;

won't work forever and actually it is bad coding.

Quoted 2 lines

Next action:
- Discoverable timout functions.

Go ahead. I really like to see this in action.

Regards

Marcel

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw

Hi Marcel,

Quoted 7 lines · Marcel Holtmann

Hi Claudio,

Quoted 4 lines

This patch add/fix the following services:
1. Changed GetMode/SetMode arguments to string, instead of use byte
2. Added IsConnectable
3. Added IsDiscoverable

Quoted 6 lines

I applied the patch to keep it going, but we need to rework the data object associated with the device path. Using it like this

        const uint8_t hci_mode =3D dbus_data->path_data;

won't work forever and actually it is bad coding.

[Claudio Takahasi]
I don't know exactly what is problem, but I guess it should be related to uint32 to uint8 casting.

I will change the path_data to a device settings structure, where I want store the scan mode and the discoverable timeout. In my opinion the discoverable timeout should be unique for each local adapter. Do you have any comments or suggestion?

 struct device_settings {
         uint32_t discoverable_to;
         uint8_t  scan_mode;

};

 struct hci_dbus_data {
         uint16_t dev_id;
         uint16_t path_id;
         struct device_settings dev_settings;

};

Quoted 5 lines
Quoted 3 lines

Next action:
- Discoverable timout functions.

Go ahead. I really like to see this in action.

[Claudio Takahasi]
I am planning use the SIGALARM. Another option is integrate inside the main loop, using a poll timeout. However it is a little bit more complicated.
Do you agree with this approach?

Regards,
Claudio.

Quoted 10 lines

Regards

Marcel

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi=

les

Quoted 3 lines

for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486&dat=

=3D121642

Quoted 5 lines

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

--
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#3 lore raw

Hi Claudio,

Quoted 9 lines
Quoted 6 lines

I applied the patch to keep it going, but we need to rework the data object associated with the device path. Using it like this

        const uint8_t hci_mode = dbus_data->path_data;

won't work forever and actually it is bad coding.

I don't know exactly what is problem, but I guess it should be related to uint32 to uint8 casting.

the casting is not that big problem. It is a misuse of the variable, because the name is not clear. In other code paths you might use the path_data variable too and then it clashes. These things are really hard to debug.

Quoted 9 lines

I will change the path_data to a device settings structure, where I want store the scan mode and the discoverable timeout. In my opinion the discoverable timeout should be unique for each local adapter. Do you have any comments or suggestion?

 struct device_settings {
         uint32_t discoverable_to;
         uint8_t  scan_mode;
Quoted 7 lines

};

 struct hci_dbus_data {
         uint16_t dev_id;
         uint16_t path_id;
         struct device_settings dev_settings;

};

I don't see any need for another nested structure. Actually I would prefer using something like this:

	struct hci_dbus_data {
		uint16_t dev_id;
		uint16_t path_id;
		uint8_t mode;
		uint32_t discoverable_timeout;
	}
Quoted 3 lines

I am planning use the SIGALARM. Another option is integrate inside the main loop, using a poll timeout. However it is a little bit more complicated.

In the end we might need to integrate it into the main loop, because this looks like the cleanest approach to me. However for now it might be enough to use SIGALARM.

Regards

Marcel

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel