Nokia 6310i and gammu

View: New views
8 Messages — Rating Filter:   Alert me  

Nokia 6310i and gammu

by Gergely CZUCZY :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

I'm trying to back up my phone address book on my nokia 6310i
(yeah, i know it's old, bit it still works), and I've got
some questions on this.

I'm on a few months old 6-STABLE.

1) i'd like to achive this with gammu, and currently it doesn't work,
--identify shows nothing but exists.

2) do i need bthidd? how should i write its configuration file, since
there are no manuals or anything on google for it?

3) many references mention /etc/rc.bluetooth, but i have no such file.
what should i do with this? how can i initalize my ubt0 device?


4) I don't know if it's gammu's or freebsd's fault, but when
i do "gammu --identify" it does simply nothing.
I'm unable to persuade it for some kind of verbose output, and
I'm still looking for some way to contact with the gammu devs.
i've tried all the related gammu connection methods, but nothing
works.

``hccontrol inquiry'' shows my phone, i've got that.
I don't really know what is this "key" thingie in the config,
wasn't able to find such a thing in my phone. And i've got
the PIN code turned off in the phone.

Where could I find some resources on how to get this thing
work?
Anybody had any successes with gammu and freebsd?

Are there other tools with which I can back up my
phone book on this nokia using bluetooth?

Thanks in advance

Sincerely,

Gergely Czuczy
mailto: gergely.czuczy@...

--
Weenies test. Geniuses solve problems that arise.


attachment0 (1K) Download Attachment

Re: Nokia 6310i and gammu

by Maksim Yevmenkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hello,

> I'm trying to back up my phone address book on my nokia 6310i
> (yeah, i know it's old, bit it still works), and I've got
> some questions on this.
>
> I'm on a few months old 6-STABLE.
>
> 1) i'd like to achive this with gammu, and currently it doesn't work,
> --identify shows nothing but exists.

ok

> 2) do i need bthidd? how should i write its configuration file, since
> there are no manuals or anything on google for it?

no you do not need it, and bthidd(8) comes with manual page in base system

> 3) many references mention /etc/rc.bluetooth, but i have no such file.
> what should i do with this? how can i initalize my ubt0 device?

the references are not correct (or you made a typo). there is a
/etc/rc.d/bluetooth  script that would initialize your device as soon
as you plugged it in. all you need to do is to

- load ng_ubt(4) module
- make sure devd(8) is running
- attach your device

for more details look at /etc/devd.conf and related manual pages

> 4) I don't know if it's gammu's or freebsd's fault, but when
> i do "gammu --identify" it does simply nothing.
> I'm unable to persuade it for some kind of verbose output, and
> I'm still looking for some way to contact with the gammu devs.
> i've tried all the related gammu connection methods, but nothing
> works.

gammu will use serial port profile to talk to bluetooth enabled phone.
before trying gammu you can try rfcomm_sppd(1) to see if your phone
allows you to use serial port profile. you will probably need to pair
your phone and pc. once you get rfcomm_sppd(1) working then you can
move to gammu.

> ``hccontrol inquiry'' shows my phone, i've got that.

then it means your bluetooth device was initialized and appear to be working

> I don't really know what is this "key" thingie in the config,
> wasn't able to find such a thing in my phone. And i've got
> the PIN code turned off in the phone.

key is the link key. pin is a pin code that you need for paring. since
most (all?) phones only allow to enter pin you need to configure pin
code for your phone in /etc/bluetooth/hcsecd.conf and then pair your
phone and pc. hint: enter the same pin code on your phone when
prompted

> Where could I find some resources on how to get this thing
> work?

freebsd handbook is a good start

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-bluetooth.html

> Anybody had any successes with gammu and freebsd?

yes, last time i tried it worked for me.

> Are there other tools with which I can back up my
> phone book on this nokia using bluetooth?

nokia's are notoriously bad (imo) in this regard. the only way, i know
of, is to use serial port profile and issue a bunch of at commands to
get entries in phone book and that is what gammu/gnoki does.

other (than nokia) phones will allow you to push all phone book and/or
individual entries using obex and there is comms/opexapp application
in freebsd port collections for that.

thanks,
max
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Parent Message unknown Re: Nokia 6310i and gammu

by Maksim Yevmenkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 8/17/07, Gergely CZUCZY <phoemix@...> wrote:
> > yes, last time i tried it worked for me.
> may i ask for your .gammurc?
> i couldn't really figure out what kind of connection setting
> i need to make this work... at least, what i've tried, those
> failed to work

first of all, please *always* include freebsd-bluetooth@ list into cc:
so i do not have to answer the same question(s) over and over.

i just installed gammu-1.12.0 from ports and was able to make it work
with my se k700i.

below is my .gammurc

===

[gammu]
 port = 00:0a:d9:XX:XX:XX
 connection = bluerfat

===

note: port should contain bd_addr of your phone. the output looks like

beetle% ./gammu/gammu --identify
Manufacturer         : Sony Ericsson
Model                : K700i (AAB-1021041-BV)
Firmware             : R2AE033  R2AE033     prgCXC125821_EU_1_C
IMEI                 : xxxxxxxxxxxxxxx
Product code         : AAB-1021041-BV
SIM IMSI             : xxxxxxxxxxxxxxx

so it should work,

however

there is a problem with the gammu-1.12.0 port because gammu developers
switched to new configuration system (cmake) and it no longer able to
detect bluetooth support on freebsd. i had to hack gammu port to
convince it to detect bluetooth support, and once i've done it, it
worked.

the above is NOT a problem with bluetooth. this is a problem with
gammu port. please email gammu port maintainer (or possibly gammu
developers directly) and ask them to address this issue.

another possible solution for you is to use older (pre-cmake) gammu
port or try gnokii.

thanks,
max
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: Nokia 6310i and gammu

by Gergely CZUCZY :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Aug 18, 2007 at 02:15:59PM +0200, Michal Čihař wrote:
> Gammu does have support for Linux and Win32 bluetooth stack only for
> now, however you're welcome to send patches for others ;-).
Please consider the following message from Maksim Yevmenkin. Personally,
I haven't checked all the details myself, but he might have pointed out
something important.

On Fri, Aug 17, 2007 at 12:00:02PM -0700, Maksim Yevmenkin wrote:

> On 8/17/07, Gergely CZUCZY <phoemix@...> wrote:
> > > yes, last time i tried it worked for me.
> > may i ask for your .gammurc?
> > i couldn't really figure out what kind of connection setting
> > i need to make this work... at least, what i've tried, those
> > failed to work
>
> i just installed gammu-1.12.0 from ports and was able to make it work
> with my se k700i.
>
> below is my .gammurc
>
> ===
>
> [gammu]
>  port = 00:0a:d9:XX:XX:XX
>  connection = bluerfat
>
> ===
>
> note: port should contain bd_addr of your phone. the output looks like
>
> beetle% ./gammu/gammu --identify
> Manufacturer         : Sony Ericsson
> Model                : K700i (AAB-1021041-BV)
> Firmware             : R2AE033  R2AE033     prgCXC125821_EU_1_C
> IMEI                 : xxxxxxxxxxxxxxx
> Product code         : AAB-1021041-BV
> SIM IMSI             : xxxxxxxxxxxxxxx
>
> so it should work,
>
> however
>
> there is a problem with the gammu-1.12.0 port because gammu developers
> switched to new configuration system (cmake) and it no longer able to
> detect bluetooth support on freebsd. i had to hack gammu port to
> convince it to detect bluetooth support, and once i've done it, it
> worked.
>
> the above is NOT a problem with bluetooth. this is a problem with
> gammu port. please email gammu port maintainer (or possibly gammu
> developers directly) and ask them to address this issue.
>
> another possible solution for you is to use older (pre-cmake) gammu
> port or try gnokii.
>
> thanks,
> max
Sincerely,

Gergely Czuczy
mailto: gergely.czuczy@...

--
Weenies test. Geniuses solve problems that arise.


attachment0 (1K) Download Attachment

Re: FBSD bt gammu [was:Nokia 6310i and gammu]

by Peter Stuge-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Aug 18, 2007 at 03:36:34PM +0200, Gergely CZUCZY wrote:
> On Sat, Aug 18, 2007 at 02:15:59PM +0200, Michal ??iha?? wrote:
> > Gammu does have support for Linux and Win32 bluetooth stack only for
> > now, however you're welcome to send patches for others ;-).
>
> Please consider the following message from Maksim Yevmenkin.
> Personally, I haven't checked all the details myself, but he might
> have pointed out something important.

There are no details, unfortunately.


> On Fri, Aug 17, 2007 at 12:00:02PM -0700, Maksim Yevmenkin wrote:
> > i just installed gammu-1.12.0 from ports and was able to make it
> > work with my se k700i.

Sweet!


> > there is a problem with the gammu-1.12.0 port because gammu
> > developers switched to new configuration system (cmake) and it no
> > longer able to detect bluetooth support on freebsd. i had to hack
> > gammu port to convince it to detect bluetooth support, and once
> > i've done it, it worked.

Could you let us know what you needed to do to make bluetooth work on
FBSD? I'd be happy to see that included into the source.


> > the above is NOT a problem with bluetooth. this is a problem with
> > gammu port.

Yes, completely correct. I hope noone got the wrong impression from
the gammu list.


> > please email gammu port maintainer (or possibly gammu developers
> > directly) and ask them to address this issue.

I don't think any gammu developers know FBSD so hints with technical
details about what is needed to make it play are very welcome.


//Peter
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: FBSD bt gammu [was:Nokia 6310i and gammu]

by Maksim Yevmenkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter,

thanks for the reply and sorry for the delay with answering to your
email. please read my comments inline.

On 9/2/07, Peter Stuge <peter@...> wrote:

> On Sat, Aug 18, 2007 at 03:36:34PM +0200, Gergely CZUCZY wrote:
> > On Sat, Aug 18, 2007 at 02:15:59PM +0200, Michal ??iha?? wrote:
> > > Gammu does have support for Linux and Win32 bluetooth stack only for
> > > now, however you're welcome to send patches for others ;-).
> >
> > Please consider the following message from Maksim Yevmenkin.
> > Personally, I haven't checked all the details myself, but he might
> > have pointed out something important.
>
> There are no details, unfortunately.

Boris Samorodov (bsam@...) did all the work to port gammu
bluetooth onto freebsd. he is the gammu's port maintainer. all his
patches can be found at

http://www.freebsd.org/cgi/cvsweb.cgi/ports/comms/gammu/

(actual patches at
http://www.freebsd.org/cgi/cvsweb.cgi/ports/comms/gammu/files/)

bsam's patches work on gammu version 1.13.0, however cmake scripts do
not have support for detecting bluetooth on freebsd. i'm not familiar
with cmake, so i simply applied bsam's patches and hacked cmake
generated .h files to enable relevant bluetooth defines. once i
compiled hacked version, bluetooth worked fine.

> > > there is a problem with the gammu-1.12.0 port because gammu
> > > developers switched to new configuration system (cmake) and it no
> > > longer able to detect bluetooth support on freebsd. i had to hack
> > > gammu port to convince it to detect bluetooth support, and once
> > > i've done it, it worked.
>
> Could you let us know what you needed to do to make bluetooth work on
> FBSD? I'd be happy to see that included into the source.

please take a look at bsam's patches to see if they can be included into gammu

please modify cmake scripts so it can properly detect bluetooth on freebsd

> > > please email gammu port maintainer (or possibly gammu developers
> > > directly) and ask them to address this issue.
>
> I don't think any gammu developers know FBSD so hints with technical
> details about what is needed to make it play are very welcome.

please feel free to ask in freebsd-bluetooth@... any questions
you might have

thanks,
max
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: FBSD bt gammu

by Boris Samorodov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 5 Sep 2007 09:56:26 -0700 Maksim Yevmenkin wrote:

> please modify cmake scripts so it can properly detect bluetooth on freebsd

Michal incorporated all FreeBSD patches to svn version. All bluetooth
functions except channel searching (switched off for FreeBSD) should
work fine.

Those who are interested may test it and give a feedback.
Those who are interested may look into channel searching problem and
produce patches. ;-)

Thanks.


WBR
--
Boris Samorodov (bsam)
Research Engineer, http://www.ipt.ru Telephone & Internet SP
FreeBSD committer, http://www.FreeBSD.org The Power To Serve
_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."

Re: FBSD bt gammu

by Iain Hibbert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 6 Sep 2007, Boris Samorodov wrote:

> On Wed, 5 Sep 2007 09:56:26 -0700 Maksim Yevmenkin wrote:
>
> > please modify cmake scripts so it can properly detect bluetooth on freebsd
>
> Michal incorporated all FreeBSD patches to svn version. All bluetooth
> functions except channel searching (switched off for FreeBSD) should
> work fine.
>
> Those who are interested may test it and give a feedback.
> Those who are interested may look into channel searching problem and
> produce patches. ;-)
Hi Boris,

This was some time ago but I have just rewritten the FBSD support in gammu
to be generic BSD support and implemented channel searching using the new
device access (already in FreeBSD) and service discovery (which Max is
working on porting) routines. I wonder if you can validate that my work
doesn't cause any regressions on FreeBSD?

The attached patch adds
        cmake/FindBSDBluetooth.cmake
        libgammu/device/bluetoth/blue_bsd.c
        libgammu/device/bluetoth/blue_bsd.h

and converts the build to use those files instead of the 'fbsd' versions,
which can be removed, and the cmake framework will enable the channel
searching if the new API is present.

I'm not quite ready to commit the bt_dev stuff into NetBSD but will push
this upstream after we have all caught up. I'm not sure if it will be
worth putting the patches into ports or not, will leave that up to you.

iain
diff -Nru orig/gammu-1.24.0/CMakeLists.txt gammu-1.24.0/CMakeLists.txt
--- orig/gammu-1.24.0/CMakeLists.txt 2009-04-15 14:39:54.000000000 +0100
+++ gammu-1.24.0/CMakeLists.txt 2009-05-25 13:04:36.000000000 +0100
@@ -270,12 +270,12 @@
             set(BLUETOOTH_SEARCH TRUE)
             message(STATUS "Using BlueZ stack")
         endif (BLUEZ_FOUND)
-        find_package (FBSDBluetooth)
-        if (FBSD_BLUE_FOUND)
+        find_package (BSDBluetooth)
+        if (BSD_BLUE_FOUND)
             set(BLUETOOTH_FOUND ON)
-            set(BLUETOOTH_SEARCH FALSE)
-            message(STATUS "Using FreeBSD Bluetooth stack")
-        endif (FBSD_BLUE_FOUND)
+    check_library_exists(bluetooth sdp_service_search_attribute "" BLUETOOTH_SEARCH)
+            message(STATUS "Using BSD Bluetooth stack")
+        endif (BSD_BLUE_FOUND)
         find_package (OSXBluetooth)
         if (OSX_BLUE_FOUND)
             set(BLUETOOTH_FOUND ON)
@@ -360,11 +360,11 @@
     endif (NOT "${BLUEZ_LIBRARIES}" STREQUAL "")
 endif (BLUEZ_FOUND)
 
-if (FBSD_BLUE_FOUND)
-    if (NOT "${FBSD_BLUE_LIBRARIES}" STREQUAL "")
-        set (GAMMU_LIBS "${GAMMU_LIBS} -l${FBSD_BLUE_LIBRARIES}")
-    endif (NOT "${FBSD_BLUE_LIBRARIES}" STREQUAL "")
-endif (FBSD_BLUE_FOUND)
+if (BSD_BLUE_FOUND)
+    if (NOT "${BSD_BLUE_LIBRARIES}" STREQUAL "")
+        set (GAMMU_LIBS "${GAMMU_LIBS} -l${BSD_BLUE_LIBRARIES}")
+    endif (NOT "${BSD_BLUE_LIBRARIES}" STREQUAL "")
+endif (BSD_BLUE_FOUND)
 
 if (ICONV_FOUND)
     if (NOT "${ICONV_LIBRARIES}" STREQUAL "")
diff -Nru orig/gammu-1.24.0/cmake/FindBSDBluetooth.cmake gammu-1.24.0/cmake/FindBSDBluetooth.cmake
--- orig/gammu-1.24.0/cmake/FindBSDBluetooth.cmake 1970-01-01 01:00:00.000000000 +0100
+++ gammu-1.24.0/cmake/FindBSDBluetooth.cmake 2009-05-22 09:48:26.000000000 +0100
@@ -0,0 +1,35 @@
+# - Finds Bluetooth library on BSD
+# This module defines
+#  BSD_BLUE_INCLUDE_DIR, where to find bluetooth.h
+#  BSD_BLUE_LIBRARIES, the libraries needed to use BSD Bluetooth.
+#  BSD_BLUE_FOUND, If false, do not try to use BSD Bluetooth.
+#
+# Copyright (c) 2007, Michal Cihar, <michal@...>
+#
+# vim: expandtab sw=4 ts=4 sts=4:
+
+if (NOT DEFINED BSD_BLUE_FOUND)
+    if (NOT CROSS_MINGW)
+        find_path(BSD_BLUE_INCLUDE_DIR NAMES bluetooth.h
+           PATHS
+           /usr/include
+           /usr/local/include
+        )
+
+        find_library(BSD_BLUE_LIBRARIES NAMES bluetooth
+           PATHS
+           /usr/lib
+           /usr/local/lib
+        )
+
+        if(BSD_BLUE_INCLUDE_DIR AND BSD_BLUE_LIBRARIES)
+           set(BSD_BLUE_FOUND TRUE CACHE INTERNAL "BSD Bluetooth found")
+           message(STATUS "Found BSD Bluetooth: ${BSD_BLUE_INCLUDE_DIR}, ${BSD_BLUE_LIBRARIES}")
+        else(BSD_BLUE_INCLUDE_DIR AND BSD_BLUE_LIBRARIES)
+           set(BSD_BLUE_FOUND FALSE CACHE INTERNAL "BSD Bluetooth found")
+           message(STATUS "BSD Bluetooth not found.")
+        endif(BSD_BLUE_INCLUDE_DIR AND BSD_BLUE_LIBRARIES)
+
+        mark_as_advanced(BSD_BLUE_INCLUDE_DIR BSD_BLUE_LIBRARIES)
+    endif (NOT CROSS_MINGW)
+endif (NOT DEFINED BSD_BLUE_FOUND)
diff -Nru orig/gammu-1.24.0/cmake/templates/gammu-config.h.cmake gammu-1.24.0/cmake/templates/gammu-config.h.cmake
--- orig/gammu-1.24.0/cmake/templates/gammu-config.h.cmake 2009-03-17 15:01:11.000000000 +0000
+++ gammu-1.24.0/cmake/templates/gammu-config.h.cmake 2009-05-22 09:49:28.000000000 +0100
@@ -322,8 +322,8 @@
 /* Do we have libusb-1.0 ? */
 #cmakedefine LIBUSB_FOUND
 
-/* Will be used FreeBSD Bluetooth stack ? */
-#cmakedefine FBSD_BLUE_FOUND
+/* Will be used BSD Bluetooth stack ? */
+#cmakedefine BSD_BLUE_FOUND
 
 /* Will be used OSX Bluetooth stack ? */
 #cmakedefine OSX_BLUE_FOUND
diff -Nru orig/gammu-1.24.0/libgammu/CMakeLists.txt gammu-1.24.0/libgammu/CMakeLists.txt
--- orig/gammu-1.24.0/libgammu/CMakeLists.txt 2009-03-18 09:16:38.000000000 +0000
+++ gammu-1.24.0/libgammu/CMakeLists.txt 2009-05-22 09:46:23.000000000 +0100
@@ -76,9 +76,9 @@
 if (LIBUSB_FOUND)
     list (APPEND LIBRARY_SRC device/usb/usb.c)
 endif (LIBUSB_FOUND)
-if (FBSD_BLUE_FOUND)
-    list (APPEND LIBRARY_SRC device/bluetoth/blue_fbsd.c)
-endif (FBSD_BLUE_FOUND)
+if (BSD_BLUE_FOUND)
+    list (APPEND LIBRARY_SRC device/bluetoth/blue_bsd.c)
+endif (BSD_BLUE_FOUND)
 if (OSX_BLUE_FOUND)
     list (APPEND LIBRARY_SRC device/bluetoth/blue_osx.c)
 endif (OSX_BLUE_FOUND)
@@ -126,10 +126,10 @@
     include_directories (${LIBUSB_INCLUDE_DIR})
 endif (LIBUSB_FOUND)
 
-if (FBSD_BLUE_FOUND)
-    target_link_libraries (libGammu ${FBSD_BLUE_LIBRARIES})
-    include_directories (${FBSD_BLUE_INCLUDE_DIR})
-endif (FBSD_BLUE_FOUND)
+if (BSD_BLUE_FOUND)
+    target_link_libraries (libGammu ${BSD_BLUE_LIBRARIES})
+    include_directories (${BSD_BLUE_INCLUDE_DIR})
+endif (BSD_BLUE_FOUND)
 
 if (OSX_BLUE_FOUND)
     target_link_libraries (libGammu ${OSX_BLUE_LIBS})
diff -Nru orig/gammu-1.24.0/libgammu/device/bluetoth/blue_bsd.c gammu-1.24.0/libgammu/device/bluetoth/blue_bsd.c
--- orig/gammu-1.24.0/libgammu/device/bluetoth/blue_bsd.c 1970-01-01 01:00:00.000000000 +0100
+++ gammu-1.24.0/libgammu/device/bluetoth/blue_bsd.c 2009-05-25 13:37:40.000000000 +0100
@@ -0,0 +1,265 @@
+/*-
+ * Copyright (c) 2009 Iain Hibbert
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../../gsmstate.h"
+
+#ifdef GSM_ENABLE_BLUETOOTHDEVICE
+#ifdef BSD_BLUE_FOUND
+
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#include <bluetooth.h>
+#include <errno.h>
+#include <netdb.h>
+#include <sdp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "../../gsmcomon.h"
+#include "../devfunc.h"
+#include "bluetoth.h"
+
+/*
+ * Handle FreeBSD compatibility
+ */
+#ifndef BTPROTO_RFCOMM
+#define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM
+#define BDADDR_ANY NG_HCI_BDADDR_ANY
+#define sockaddr_bt sockaddr_rfcomm
+#define bt_len rfcomm_len
+#define bt_family rfcomm_family
+#define bt_channel rfcomm_channel
+#define bt_bdaddr rfcomm_bdaddr
+#endif
+
+static GSM_Error bluetooth_open(GSM_StateMachine *s, bdaddr_t *bdaddr, int channel)
+{
+ GSM_Device_BlueToothData *d = &s->Device.Data.BlueTooth;
+ struct sockaddr_bt sa;
+ int fd;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.bt_len = sizeof(sa);
+ sa.bt_family = AF_BLUETOOTH;
+
+ smprintf(s, "Connecting to RF channel %i\n", channel);
+
+ fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
+ if (fd < 0) {
+ smprintf(s, "Can't create socket\n");
+ return ERR_DEVICENODRIVER;
+ }
+
+ bdaddr_copy(&sa.bt_bdaddr, BDADDR_ANY);
+
+ if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
+ smprintf(s, "Can't bind socket: %s\n", strerror(errno));
+ close(fd);
+ return ERR_DEVICEOPENERROR;
+ }
+
+ sa.bt_channel = channel;
+ bdaddr_copy(&sa.bt_bdaddr, bdaddr);
+
+ if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
+ smprintf(s, "Can't connect to %s: %s\n", bt_ntoa(bdaddr, NULL), strerror(errno));
+ close(fd);
+ return ERR_DEVICEOPENERROR;
+ }
+
+ d->hPhone = fd;
+     return ERR_NONE;
+}
+
+GSM_Error bluetooth_connect(GSM_StateMachine *s, int port, char *device)
+{
+ bdaddr_t bdaddr;
+ struct hostent *he = NULL;
+
+ if (!bt_aton(device, &bdaddr)) {
+ if ((he = bt_gethostbyname(device)) == NULL) {
+ smprintf(s, "%s: %s\n", device, hstrerror(h_errno));
+ return ERR_UNKNOWN;
+ }
+
+ bdaddr_copy(&bdaddr, (bdaddr_t *)he->h_addr);
+ }
+
+ return bluetooth_open(s, &bdaddr, port);
+}
+
+#ifdef BLUETOOTH_RF_SEARCHING
+
+static int bluetooth_channel(sdp_data_t *value)
+{
+ sdp_data_t pdl, seq;
+ uintmax_t channel;
+
+ sdp_get_alt(value, value); /* strip any alt container */
+
+ while (sdp_get_seq(value, &pdl)) {
+ if (sdp_get_seq(&pdl, &seq)
+    && sdp_match_uuid16(&seq, SDP_UUID_PROTOCOL_L2CAP)
+    && sdp_get_seq(&pdl, &seq)
+    && sdp_match_uuid16(&seq, SDP_UUID_PROTOCOL_RFCOMM)
+    && sdp_get_uint(&seq, &channel)
+    && channel >= 1 && channel <= 30)
+ return channel;
+ }
+
+ return -1;
+}
+
+static char *bluetooth_service(sdp_data_t *value)
+{
+ char *str;
+ size_t len;
+
+ if (!sdp_get_str(value, &str, &len))
+ return NULL;
+
+ return strndup(str, len);
+}
+
+static GSM_Error bluetooth_search(GSM_StateMachine *s, bdaddr_t *bdaddr)
+{
+ sdp_data_t rec, rsp, ssp, value;
+ uint8_t buf[3];
+ uint16_t attr;
+ sdp_session_t ss;
+ int ch, channel, sc, score;
+ char *sv;
+
+ smprintf(s, "Searching for services on %s\n", bt_ntoa(bdaddr, NULL));
+
+ ss = sdp_open(NULL, bdaddr);
+ if (ss == NULL) {
+ smprintf(s, "SDP Connection failed: %s\n", strerror(errno));
+ return ERR_TIMEOUT;
+ }
+
+ ssp.next = buf;
+ ssp.end = buf + sizeof(buf);
+ sdp_put_uuid16(&ssp, SDP_UUID_PROTOCOL_RFCOMM);
+ ssp.end = ssp.next;
+ ssp.next = buf;
+
+ if (!sdp_service_search_attribute(ss, &ssp, NULL, &rsp)) {
+ smprintf(s, "SDP Service Search Attribute failed: %s\n", strerror(errno));
+ sdp_close(ss);
+ return ERR_UNKNOWN;
+ }
+
+ channel = -1;
+ score = 0;
+
+ while (sdp_get_seq(&rsp, &rec)) {
+ ch = -1;
+ sv = NULL;
+
+ while (sdp_get_attr(&rec, &attr, &value)) {
+ switch (attr) {
+ case SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST:
+ ch = bluetooth_channel(&value);
+ break;
+
+ case SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET:
+ sv = bluetooth_service(&value);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (ch != -1) {
+ smprintf(s, "   Channel %i", ch);
+ if (sv != NULL) {
+ sc = bluetooth_checkservicename(s, sv);
+ smprintf(s, " - \"%s\" (score=%d)", sv, sc);
+ if (sc > score) {
+ score = sc;
+ channel = ch;
+ }
+ }
+ smprintf(s, "\n");
+ }
+
+ free(sv);
+ }
+
+ sdp_close(ss);
+
+ if (channel == -1) {
+ smprintf(s, "No suitable service found!\n");
+ return ERR_NOTSUPPORTED;
+ }
+
+ return bluetooth_open(s, bdaddr, channel);
+}
+
+GSM_Error bluetooth_findchannel(GSM_StateMachine *s)
+{
+ char *device = s->CurrentConfig->Device;
+ bdaddr_t bdaddr;
+ struct hostent *he;
+ struct bt_devinquiry *ii;
+ int n;
+
+ if (bt_aton(device, &bdaddr))
+ return bluetooth_search(s, &bdaddr);
+
+ if ((he = bt_gethostbyname(device)) != NULL)
+ return bluetooth_search(s, (bdaddr_t *)he->h_addr);
+
+ smprintf(s, "Device \"%s\" unknown. Starting inquiry..\n");
+
+ if ((n = bt_devinquiry(NULL, 10, 20, &ii)) == -1) {
+ smprintf(s, "Inquiry failed: %s\n", strerror(errno));
+ return ERR_UNKNOWN;
+ }
+
+ smprintf(s, "Found %d devices\n", n);
+
+ while (n-- > 0) {
+ if (bluetooth_search(s, &ii->bdaddr) == ERR_NONE)
+ return ERR_NONE;
+
+ ii++;
+ }
+
+ return ERR_UNKNOWN;
+}
+
+#endif
+#endif
+#endif
+
+/* How should editor hadle tabs in this file? Add editor commands here.
+ * vim: noexpandtab sw=8 ts=8 sts=8:
+ */
diff -Nru orig/gammu-1.24.0/libgammu/device/bluetoth/blue_bsd.h gammu-1.24.0/libgammu/device/bluetoth/blue_bsd.h
--- orig/gammu-1.24.0/libgammu/device/bluetoth/blue_bsd.h 1970-01-01 01:00:00.000000000 +0100
+++ gammu-1.24.0/libgammu/device/bluetoth/blue_bsd.h 2009-05-25 13:35:44.000000000 +0100
@@ -0,0 +1 @@
+/* empty file */
diff -Nru orig/gammu-1.24.0/libgammu/device/bluetoth/bluetoth.c gammu-1.24.0/libgammu/device/bluetoth/bluetoth.c
--- orig/gammu-1.24.0/libgammu/device/bluetoth/bluetoth.c 2009-02-12 14:19:01.000000000 +0000
+++ gammu-1.24.0/libgammu/device/bluetoth/bluetoth.c 2009-05-22 09:44:29.000000000 +0100
@@ -21,8 +21,8 @@
 #ifdef BLUEZ_FOUND
 #  include "bluez.h"
 #endif
-#ifdef FBSD_BLUE_FOUND
-#  include "blue_fbsd.h"
+#ifdef BSD_BLUE_FOUND
+#  include "blue_bsd.h"
 #endif
 #ifdef OSX_BLUE_FOUND
 #  include "blue_osx.h"

_______________________________________________
freebsd-bluetooth@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bluetooth
To unsubscribe, send any mail to "freebsd-bluetooth-unsubscribe@..."