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

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

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