Menu

How to automatically find obex push channel?

Help
drakkan
2007-09-12
2013-04-25
  • drakkan

    drakkan - 2007-09-12

    Hi,

    I would like to send file via obex push to all phone in the range automatically 

    I done some tests using the following commands:

    finddevices()
    [('00:16:41:23:70:44', u'PORTGLAI6320', 851969), ('00:15:B9:9A:29:91', u'SGH-ZV10', 16339458), ('00:13:70:0D:96:2C', u'Nokia 6021', 15094274)]

    findservices('00:15:B9:9A:29:91')
    [('00:15:B9:9A:29:91', 3, u'QC Voice Gateway'), ('00:15:B9:9A:29:91', 4, u'QC Voice Gateway'), ('00:15:B9:9A:29:91', 16, u'FTP'), ('00:15:B9:9A:29:91', 17, u'OPP'), ('00:15:B9:9A:29:91', 18, u'Serial Port'), ('00:15:B9:9A:29:91', 8, u'Dial-up Networking')]

    and finally

    obex.sendfile('00:15:B9:9A:29:91',17,"/path/to/test.jpg")

    and all is ok, however all the parameter in obex.sendfile are variable per phone basis (both channel and service description), for example in an HP smartphone the description isn't OPP but Obex push ..., so it is difficult to build a regular expression on service description to find obex push channel,

    something like:

    if re.compile("OPP").search(s[2]) or re.compile("Push").search(s[2]) or re.compile("Push di oggetti OBEX").search(s[2]):
               obex.sendfile(s[0],s[1],file))

    is difficult to mantain

    there is an alternate way to identify obex push channel?

    sorry for my bad english,

    thanks
    drakkan

     
    • blam

      blam - 2007-09-12

      Hi drakkan,

      You can use the third keyword argument to findservices() to narrow the discovery results to OBEX services, like this:

          lightblue.findservices(servicetype=lightblue.OBEX)

      However this doesn't narrow it down to only Object Push services, because a device might have other OBEX-based services. In the case of the results you listed for '00:15:B9:9A:29:91', you'd probably get these results instead:

      [('00:15:B9:9A:29:91', 16, u'FTP'), ('00:15:B9:9A:29:91', 17, u'OPP')]

      since the FTP service must be the OBEX File Transfer service. Unfortunately there's nothing in the LightBlue API at the moment to narrow it down to only OBEX Object Push services.

       
    • drakkan

      drakkan - 2007-09-13

      Thanks for your answer,

      I think the best solution to my question is to use pybluez to find obex push service and then lightblue to send the file,

      something like this:

      >>> import bluetooth
      >>> bluetooth.find_service(address='00:15:B9:9A:29:91')
      [{'protocol': 'RFCOMM', 'name': 'QC Voice Gateway', 'service-id': None, 'profiles': [('1108', 256)], 'service-classes': ['1112', '1203'], 'host': '00:15:B9:9A:29:91', 'provider': None, 'port': 3, 'description': None}, {'protocol': 'RFCOMM', 'name': 'QC Voice Gateway', 'service-id': None, 'profiles': [('111E', 257)], 'service-classes': ['111F', '1203'], 'host': '00:15:B9:9A:29:91', 'provider': None, 'port': 4, 'description': None}, {'protocol': 'RFCOMM', 'name': 'FTP', 'service-id': None, 'profiles': [('1106', 256)], 'service-classes': ['1106'], 'host': '00:15:B9:9A:29:91', 'provider': None, 'port': 16, 'description': None}, {'protocol': 'RFCOMM', 'name': 'OPP', 'service-id': None, 'profiles': [('1105', 256)], 'service-classes': ['1105'], 'host': '00:15:B9:9A:29:91', 'provider': None, 'port': 17, 'description': None}, {'protocol': 'RFCOMM', 'name': 'Serial Port', 'service-id': None, 'profiles': [('1101', 0)], 'service-classes': ['1101'], 'host': '00:15:B9:9A:29:91', 'provider': None, 'port': 18, 'description': None}, {'protocol': 'RFCOMM', 'name': 'Dial-up Networking', 'service-id': None, 'profiles': [('1103', 256)], 'service-classes': ['1103'], 'host': '00:15:B9:9A:29:91', 'provider': None, 'port': 8, 'description': None}]

      the obex-push object service is identified by service-class 1105 for every phone (I test with nokia, hp, samsung)

      thanks
      drakkan

       
    • drakkan

      drakkan - 2007-09-13

      this way is better:

      bluetooth.find_service(uuid='1105',address='00:15:B9:9A:29:91')

      thanks
      drakkan

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.