Android Question DSD Tech ReadData - what does 2, 4 or 8 relay return

Discussion in 'Android Questions' started by Robert Valentino, Sep 12, 2019 at 4:16 PM.

  1. Robert Valentino

    Robert Valentino Well-Known Member Licensed User

    I have a single relay DSD Tech board and when I do the following

    Code:
    Sub Manager_DataAvailable (ServiceId As String, Characteristics As Map)
       
    Dim BC As ByteConverter
       
       
    For Each DataString() As Byte In Characteristics.Values
           
    Log("DataString[" &BC.HexFromBytes(DataString) &"]")  
       
    Next
    End Sub

    Sub GetRelayInfo
       
    If  BLEEntry.IsInitialized And BLEEntry.IsValid Then
           manager.ReadData(BLEEntry.ServiceName)
       
    End If
    End Sub
    I get the following results:
    DataString[A00100A1] if OFF
    DataString[A00101A2] if ON

    Which is perfect for letting me know if the relay is on or off.

    I was wondering what you get for 2, 4 or 8 relay switches?

    Do you get one line for each switch?

    Just trying to write a routine that will work for all boards but only have a single switch/relay board.

    Thanks

    BobVal
     
  2. DonManfred

    DonManfred Expert Licensed User

    I guess two for each as you get two for the one you have.
    Best is to check the documentation
     
    emexes likes this.
  3. Robert Valentino

    Robert Valentino Well-Known Member Licensed User

    Well actually anytime I do a ReadData it returns the one line (just different if on or off).

    But maybe you are right that it returns a line for each relay - I will design for that until I get a board with more relays
     
  4. DonManfred

    DonManfred Expert Licensed User

    Maybe it comes with (or similar)
    just as example. Check the real value with the real relay :)
     
  5. Robert Valentino

    Robert Valentino Well-Known Member Licensed User

    Well. Bottom line does not work the way I thought. The value returned (in my 1 switch case) is always the last value sent.

    There is a button to manually turn on and off the switch.

    If I turn it on with software and turn it off manually and the software reads the info I get the turned on value

    So I guess there are no inquires - just settings.

    Oh well.
     
  6. DonManfred

    DonManfred Expert Licensed User

  7. Robert Valentino

    Robert Valentino Well-Known Member Licensed User

    Maybe I am not saying it right, so let me try it again.

    If I use code to change the switch then read I get the code string for what I did (A00101A2 for on or A00100A1 for off).

    If I turn the switch ON using code and then turn the switch OFF (using the toggle button on it) and then read the switch I get the code for A00101A2 for On but yet the switch is actually turned off. Works the same either way. If I turn the switch off in code and then toggle it with the button (now on) and read the device it returns the last string I sent which is Off but yet the switch is on.

    So as I see it, I can't read the switch and know what it's actual state is but rather only what I last sent it in code.

    Not really a big problem. If I want the switch on or off I should set it that way.
    But I am sure there are cases where I would like to know the actual status of the switch, especially when my program first starts.

    NOW, I may be doing something wrong - will report back if I learn anything new
     
  8. emexes

    emexes Well-Known Member Licensed User

    Does your Bluetooth relay board have an actual physical pressable toggle button on it?
     
    Last edited: Sep 14, 2019 at 3:21 AM
    Shelby likes this.
  9. Robert Valentino

    Robert Valentino Well-Known Member Licensed User

  10. emexes

    emexes Well-Known Member Licensed User

    Bummer :-/

    Sometimes I wish I knew what was going through a designer's head when they implement stuff like this. Like, it'd be better if they hadn't even bothered implementing a readback function, rather than one that returns misleading/wrong information.

    Is there any possibility that the readback packets are being queued, so that you don't miss button presses? What happens if you repeatedly read the relay board?
     
    Shelby likes this.
  11. Robert Valentino

    Robert Valentino Well-Known Member Licensed User

    Haven't tried that. Will give it a go this afternoon and report back.

    This is the board I have

    upload_2019-9-14_10-37-52.png
     
  12. emexes

    emexes Well-Known Member Licensed User

    It's a bit of a long-shot. The possibility made me laugh: this designer is either an idiot or a genius, just don't know which. There is no middle ground.

    I did something similar years ago with a hand controller that had two momentary pushbuttons - it would update the main system about control knob and button states at 10x per second, and we had to make sure that button presses didn't get lost in-between the updates.
     
    Shelby likes this.
  13. Robert Valentino

    Robert Valentino Well-Known Member Licensed User

    Well, for $13 bluetooth relay/switch it's fine.

    If it cost more then $13.00 then maybe I'd have something to complain about
     
    f0raster0 likes this.
  14. emexes

    emexes Well-Known Member Licensed User

    Yeah, that probably sounded a bit harsh. I truly hope that they turn out to be genius, and me the idiot for doubting them; the alternative makes be sad.

    What made me laugh was the extreme range of the possibilities, with no middle ground in-between. Decisions in life usually have some grey in them, a fuzzy border between the alternatives, whereas here we have either dark black or brilliant white.

    :)
     
    Shelby likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice