Code Monkey home page Code Monkey logo

bluetooth-serial-port's People

Contributors

changspivey avatar kaegi avatar ntninja avatar raof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bluetooth-serial-port's Issues

read timeout

Hello,

I am trying to implement an application that closes the connection if the other device does not send any data.

The problem I find myself in is that the BtSocket.read() is blocking if the other device does not send any data, and killing threads is not supported (and/or safe) in rust.

Do you have any ideas on how to implement safely connection reset in case of timeout?

Reevaluate license

GPL-3 is quite restrictive for something as fundamental as RFCOMM. Please consider changing to MIT or BSD type license.

wrong data recieved via read

I want to connect with gps device via bluetooth on linux.

In console I did:

$ sudo rfcomm connect 0 10:C6:FC:FE:6D:D0 &
$ sudo cat /dev/rfcomm0
$GPGSA,A,3,08,27,11,69,14,18,77,32,,,,,2.5,1.6,1.9*35
$GPRMC,161659.5,A,5521.76350,N,03731.92747,E,000.57,058.2,040718,010.2,E,A*35
$GPGGA,161659.5,5521.76350,N,03731.92747,E,1,08,1.6,204.7,M,13.1,M,,*55
$GPVTG,058.2,T,048.0,M,000.57,N,0001.06,K,A*15

as you can see all data is is ascii, this is nmea protocol,
it is text based.

Then I modify example.rs:

extern crate bluetooth_serial_port;
extern crate mio;
use bluetooth_serial_port::{BtProtocol, BtSocket};
use std::io::Read;

fn main() {
    // scan for devices
    let devices = bluetooth_serial_port::scan_devices().unwrap();
    if devices.len() == 0 {
        panic!("No devices found");
    }

    let device = devices.iter().position(|x| x.name.contains("GLO")).unwrap();
    let device = &devices[device];
    println!("Connecting to `{}` ({})", device.name, device.addr.to_string());

    // create and connect the RFCOMM socket
    let mut socket = BtSocket::new(BtProtocol::RFCOMM).unwrap();
    socket.connect(device.addr).unwrap();

    loop {
        let mut buffer: [u8; 20] = [0; 20];
        let num_bytes_read = socket.read(&mut buffer[..]).unwrap();
        if num_bytes_read == 0 {
            println!("read nothing, retry");
        }
        let s = &buffer[0..num_bytes_read];
        println!("raw bytes: {:?}", s);
    }
}

and output is:

raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]
raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]
raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]
raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]
raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]
raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]
raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]
raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]
raw bytes: [192, 1, 22, 0, 3, 1, 0, 37, 1, 10, 1, 128, 0, 232, 3, 232, 3, 184, 207, 4]
raw bytes: [0, 19]

this looks completly wrong for me, byte with 0 value, bytes with value 1 and so on.

Implement win32 support

I'va started today work on win32 support,
so I create this issue to coordinate work on this issue.

Able to use uuid for open socket

So I tried to use you library for connection to my headphones. But they to use custom uuid for RFCOMM service.
https://github.com/Toxblh/sony-headphones-control-rust-linux as real example.
So I also wrote python prototype, with use custom uuid. And that is log from python

Searching for 70:26:05:10:48:04...
service_matches [{'service-classes': ['96CC203E-5068-46AD-B32D-E316F5E069BA'], 'profiles': [('96CC203E-5068-46AD-B32D-E316F5E069BA', 256)], 'name': None, 'description': None, 'provider': None, 'service-id': None, 'protocol': 'RFCOMM', 'port': 15, 'host': '70:26:05:10:48:04'}]

When I tried to connect via your lib I saw that error:

Error: No RFCOMM service on remote device

Will be cool if will be possible to pass also and uuid if it is custom for device.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.