Code Monkey home page Code Monkey logo

Comments (7)

ardmn avatar ardmn commented on July 30, 2024

It is topical issue for me too. With Every connecting to ble device i need send "start" commnad and after that i can send next commands. In my case the ble device store some data for 7 days . To obtain the all data for one day I need send 3 commands. Therefore to get the data in the last 7 days, need to send a list of 21 (+ start command). Please can you give advice how solve this problem ? May be you know nice solution for commands queue that can easily integrated with rxAndroidBle lib? Thanks.

from rxandroidble.

uKL avatar uKL commented on July 30, 2024

I'm not sure if I get it correctly. Are you trying to write some data to a characteristic in a given order? If yes, you can just flatMap write operations and the order will be preserved.

from rxandroidble.

uKL avatar uKL commented on July 30, 2024

@DKKovalev @ardmn Could you follow up?

from rxandroidble.

ardmn avatar ardmn commented on July 30, 2024

Sorry, @uKL I will try it tomorrow :)

from rxandroidble.

KolinLoures avatar KolinLoures commented on July 30, 2024

@uKL Hi. I tried to find answer to this issue, but it still not work. May you give some helpful advice if it is not difficult for you :)

public void startWriteCommucation(final ArrayList<byte[]> b) {
        if (isConnected()){
                connectionObservable
                        .flatMap(new Func1<RxBleConnection, Observable<Observable<byte[]>>>() {
                            @Override
                            public Observable<Observable<byte[]>> call(RxBleConnection rxBleConnection) {
                                final List<Observable<byte[]>> list = new ArrayList<>();
                                for (byte[]  bytes: b){
                                    Log.e("MyTag", Arrays.toString(bytes));
                                    list.add(rxBleConnection.writeCharacteristic(BleDevice.characteristicWrite, bytes));
                                }
                                return Observable.from(list);
                            }
                        })
                        .flatMap(new Func1<Observable<byte[]>, Observable<byte[]>>() {
                            @Override
                            public Observable<byte[]> call(Observable<byte[]> observable) {
                                return observable;
                            }
                        })
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(
                                new Action1<byte[]>() {
                                    @Override
                                    public void call(byte[] bytes) {
                                        Log.e("MyTag2", Arrays.toString(bytes));
                                        view.setTextStatus("WRITE SUCCESS");
                                    }
                                },
                                new Action1<Throwable>() {
                                    @Override
                                    public void call(Throwable throwable) {
                                        view.setTextStatus("!!!FAIL WRITE!!!");
                                        throwable.printStackTrace();
                                    }
                                }
                        );
            }
    }

This code works, and writes that it was successfull, but device does't responed.

from rxandroidble.

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024

I think this question should go to www.stackoverflow.com with #rxandroidble
If I understood you correctly - you just want to perform some data exchange between the device and the app before something else will happen. In this situation you can write your own connecting function like:

public Observable<RxBleConnection> establishConnectionToMySpecificDevice(RxBleDevice device) {
  return rxBleDevice.establishConnection(this, false)
    .flatMap(rxBleConnection ->
        rxBleConnection.writeCharacteristic(uuid, bytes)
        .flatMap(bytes -> rxBleConnection.readCharacteristic(uuid))
        .map(bytes1 -> /*do something with read bytes*/ rxBleConnection)
    );
}

And use it wherever you need in the code?

from rxandroidble.

KolinLoures avatar KolinLoures commented on July 30, 2024

@dariuszseweryn we have detail description of this issue on stackoverflow.
http://stackoverflow.com/questions/38250610/sending-the-list-of-commands-to-device-using-rxandroidble-rxjava

from rxandroidble.

Related Issues (20)

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.