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

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I have a single relay DSD Tech board and when I do the following

B4X:
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
 

DonManfred

Expert
Licensed User
Longtime User
I guess two for each as you get two for the one you have.
Best is to check the documentation
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

emexes

Expert
Licensed User
read the device it returns the last string I sent
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?
 
Upvote 0

emexes

Expert
Licensed User
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?
Haven't tried that. Will give it a go this afternoon and report back.
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.
 
Upvote 0

emexes

Expert
Licensed User
The possibility made me laugh: this designer is either an idiot or a genius, just don't know which.
If it cost more then $13.00 then maybe I'd have something to complain about
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 me 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.

:)
 
Last edited:
Upvote 0
Top