Not a good way to knowingly close a connection within the `onNext` of `establishConnection` and if connection is lost, only errors occurRxJava 2.0 - handling ressources for uncaught subsciber error in publish().refCount()RxAndroidBle waiting for client response

How to evaluate the performance of open source solver?

split one column into two columns based on it's value using t/sql

What does the multimeter dial do internally?

Was it ever illegal to name a pig "Napoleon" in France?

Category-theoretic treatment of diffs, patches and merging?

Can a UA Lore Mastery wizard use the Spell Secrets or Alchemical Casting features to modify spells cast through wands or staffs?

What is a writing material that persists forever or for a long time?

Computer name naming convention for security

Adjust the Table

Why did Old English lose both thorn and eth?

What exactly is a "murder hobo"?

Number of states in taxi environment (Dietterich 2000)

Is this Cambridge Dictionary example of "felicitate" valid?

Shrinking padding of node with label options

Password Hashing Security Using Scrypt & Argon2

"Distance" between summands in Taylor Series of Cosine

Is there a formal/better word than "skyrocket" for the given context?

Sum of even numbers N?

What are the effects of abstaining from eating a certain flavor?

What do you call a situation where you have choices but no good choice?

Replacement for Thyme

What factors could lead to bishops establishing monastic armies?

How many Jimmys can fit?

When do flights get cancelled due to fog?



Not a good way to knowingly close a connection within the `onNext` of `establishConnection` and if connection is lost, only errors occur


RxJava 2.0 - handling ressources for uncaught subsciber error in publish().refCount()RxAndroidBle waiting for client response






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















In the event that I'm writing a characteristic that will reboot the device, I run into a world of trouble. For example.



scanResult.bleDevice.establishConnection(false).flatMapCompletable connection ->
connection.writeCharacteristic(UUID, "reboot".toByteArray(Charset.defaultCharset())).ignoreElement()



The original establish connection never properly completes, only returns an error that the device has disconnected, which, with all other kinds of code in place to handle improper disconnections, this one becomes difficult.If I try to dispose of the connection during the onComplete of the writeCharacteristic I never seem to get a proper callback. I'm not sure that there is any specific bug with this, but rather, I'm looking for insight into how to properly










share|improve this question






























    0















    In the event that I'm writing a characteristic that will reboot the device, I run into a world of trouble. For example.



    scanResult.bleDevice.establishConnection(false).flatMapCompletable connection ->
    connection.writeCharacteristic(UUID, "reboot".toByteArray(Charset.defaultCharset())).ignoreElement()



    The original establish connection never properly completes, only returns an error that the device has disconnected, which, with all other kinds of code in place to handle improper disconnections, this one becomes difficult.If I try to dispose of the connection during the onComplete of the writeCharacteristic I never seem to get a proper callback. I'm not sure that there is any specific bug with this, but rather, I'm looking for insight into how to properly










    share|improve this question


























      0












      0








      0








      In the event that I'm writing a characteristic that will reboot the device, I run into a world of trouble. For example.



      scanResult.bleDevice.establishConnection(false).flatMapCompletable connection ->
      connection.writeCharacteristic(UUID, "reboot".toByteArray(Charset.defaultCharset())).ignoreElement()



      The original establish connection never properly completes, only returns an error that the device has disconnected, which, with all other kinds of code in place to handle improper disconnections, this one becomes difficult.If I try to dispose of the connection during the onComplete of the writeCharacteristic I never seem to get a proper callback. I'm not sure that there is any specific bug with this, but rather, I'm looking for insight into how to properly










      share|improve this question
















      In the event that I'm writing a characteristic that will reboot the device, I run into a world of trouble. For example.



      scanResult.bleDevice.establishConnection(false).flatMapCompletable connection ->
      connection.writeCharacteristic(UUID, "reboot".toByteArray(Charset.defaultCharset())).ignoreElement()



      The original establish connection never properly completes, only returns an error that the device has disconnected, which, with all other kinds of code in place to handle improper disconnections, this one becomes difficult.If I try to dispose of the connection during the onComplete of the writeCharacteristic I never seem to get a proper callback. I'm not sure that there is any specific bug with this, but rather, I'm looking for insight into how to properly







      rx-java2 rxandroidble






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 10:58









      Dariusz Seweryn

      2,2741 gold badge8 silver badges19 bronze badges




      2,2741 gold badge8 silver badges19 bronze badges










      asked Mar 25 at 22:45









      Nic CapdevilaNic Capdevila

      9898 silver badges23 bronze badges




      9898 silver badges23 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The question is more related to the usage of RxJava 2 than about the library. To solve your problem you would need to first keep the subscription to .establishConnection() until it will emit and a subsequent write will happen. The code could look like this:



          scanResult.bleDevice.establishConnection(false) // establish the connection
          .publish connectionObs ->
          // it will be needed to be subscribed until something will happen on it so a need to publish
          connectionObs.takeUntil( // keep the connection subscribed until...
          connectionObs.flatMapSingle
          // ...the first write will complete
          it.writeCharacteristic(
          uuid,
          "reboot".toByteArray(Charset.defaultCharset())
          )

          )

          .ignoreElements()





          share|improve this answer

























          • This is beautiful. Yes, my question was more directed towards RxJava2, you are correct. Thank you for the help

            – Nic Capdevila
            Mar 28 at 0:13










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347464%2fnot-a-good-way-to-knowingly-close-a-connection-within-the-onnext-of-establish%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The question is more related to the usage of RxJava 2 than about the library. To solve your problem you would need to first keep the subscription to .establishConnection() until it will emit and a subsequent write will happen. The code could look like this:



          scanResult.bleDevice.establishConnection(false) // establish the connection
          .publish connectionObs ->
          // it will be needed to be subscribed until something will happen on it so a need to publish
          connectionObs.takeUntil( // keep the connection subscribed until...
          connectionObs.flatMapSingle
          // ...the first write will complete
          it.writeCharacteristic(
          uuid,
          "reboot".toByteArray(Charset.defaultCharset())
          )

          )

          .ignoreElements()





          share|improve this answer

























          • This is beautiful. Yes, my question was more directed towards RxJava2, you are correct. Thank you for the help

            – Nic Capdevila
            Mar 28 at 0:13















          1














          The question is more related to the usage of RxJava 2 than about the library. To solve your problem you would need to first keep the subscription to .establishConnection() until it will emit and a subsequent write will happen. The code could look like this:



          scanResult.bleDevice.establishConnection(false) // establish the connection
          .publish connectionObs ->
          // it will be needed to be subscribed until something will happen on it so a need to publish
          connectionObs.takeUntil( // keep the connection subscribed until...
          connectionObs.flatMapSingle
          // ...the first write will complete
          it.writeCharacteristic(
          uuid,
          "reboot".toByteArray(Charset.defaultCharset())
          )

          )

          .ignoreElements()





          share|improve this answer

























          • This is beautiful. Yes, my question was more directed towards RxJava2, you are correct. Thank you for the help

            – Nic Capdevila
            Mar 28 at 0:13













          1












          1








          1







          The question is more related to the usage of RxJava 2 than about the library. To solve your problem you would need to first keep the subscription to .establishConnection() until it will emit and a subsequent write will happen. The code could look like this:



          scanResult.bleDevice.establishConnection(false) // establish the connection
          .publish connectionObs ->
          // it will be needed to be subscribed until something will happen on it so a need to publish
          connectionObs.takeUntil( // keep the connection subscribed until...
          connectionObs.flatMapSingle
          // ...the first write will complete
          it.writeCharacteristic(
          uuid,
          "reboot".toByteArray(Charset.defaultCharset())
          )

          )

          .ignoreElements()





          share|improve this answer















          The question is more related to the usage of RxJava 2 than about the library. To solve your problem you would need to first keep the subscription to .establishConnection() until it will emit and a subsequent write will happen. The code could look like this:



          scanResult.bleDevice.establishConnection(false) // establish the connection
          .publish connectionObs ->
          // it will be needed to be subscribed until something will happen on it so a need to publish
          connectionObs.takeUntil( // keep the connection subscribed until...
          connectionObs.flatMapSingle
          // ...the first write will complete
          it.writeCharacteristic(
          uuid,
          "reboot".toByteArray(Charset.defaultCharset())
          )

          )

          .ignoreElements()






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 27 at 11:17

























          answered Mar 27 at 10:17









          Dariusz SewerynDariusz Seweryn

          2,2741 gold badge8 silver badges19 bronze badges




          2,2741 gold badge8 silver badges19 bronze badges












          • This is beautiful. Yes, my question was more directed towards RxJava2, you are correct. Thank you for the help

            – Nic Capdevila
            Mar 28 at 0:13

















          • This is beautiful. Yes, my question was more directed towards RxJava2, you are correct. Thank you for the help

            – Nic Capdevila
            Mar 28 at 0:13
















          This is beautiful. Yes, my question was more directed towards RxJava2, you are correct. Thank you for the help

          – Nic Capdevila
          Mar 28 at 0:13





          This is beautiful. Yes, my question was more directed towards RxJava2, you are correct. Thank you for the help

          – Nic Capdevila
          Mar 28 at 0:13








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347464%2fnot-a-good-way-to-knowingly-close-a-connection-within-the-onnext-of-establish%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?