Home/Support/Support Forum/Is there a way to read a digital input state on an XBee S6B using legacy RCI? How about SCI encapsulated RCI?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Is there a way to read a digital input state on an XBee S6B using legacy RCI? How about SCI encapsulated RCI?

0 votes
If this needs to be forced or scheduled, can I do this using RCI?
asked Jan 12, 2016 in Digi Remote Manager by jhthurber New to the Community (1 point)

Please log in or register to answer this question.

2 Answers

+1 vote
I could not find a working SCI/RCI syntax for this.

The easiest way I know of to gather a pin state, is to do a HTTP GET. For example:

/ws/DataStream/00000000-00000000-00409DFF-FFXXXXXX/DIO/#
answered Jan 14, 2016 by userid0 Veteran of the Digi Community (2,158 points)
Do you have an example of how to do this using javascript or similar?  Thanks!
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.util.Scanner;

/* Can replace this with any base 64 encoder for basic authentication. For java 6
 * installations on Sun's JRE you can use "sun.misc.BASE64Encoder" however this will
 * not work in some installations (using OpenJDK).  Java mail
 * (javax.mail.internet.MimeUtility) also contains a Base 64 encoder in Java 6.  A
 * public domain version exists at http://iharder.sourceforge.net/current/java/base64/
 */
import org.apache.commons.codec.binary.Base64;

/**
 * This is a stub class with a main method to run a Device Cloud web service.
 */
public class WebServiceRequest {
    private static final String username = "username"; // put your Device Cloud username here
    private static final String password = "password"; // put your Device Cloud password here

    /**
     * Run the web service request
     */
    public static void main(String[] args) {
        HttpsURLConnection conn = null;

        try {
            // Create url to the Device Cloud server for a given web service request
            URL url = new URL("https://my.idigi.com/ws/DataStream/00000000-00000000-00409DFF-FFXXXXXX/DIO/#");
            conn = (HttpsURLConnection) url.openConnection();
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setRequestMethod("GET");
            
            // Build authentication string
            String userpassword = username + ":" + password;

            // can change this to use a different base64 encoder
            String encodedAuthorization = Base64.encodeBase64String(userpassword.getBytes()).trim();

            // set request headers
            conn.setRequestProperty("Authorization", "Basic "
                    + encodedAuthorization);
// Get input stream from response and convert to String
            InputStream is = conn.getInputStream();

            Scanner isScanner = new Scanner(is);
            StringBuffer buf = new StringBuffer();
            while (isScanner.hasNextLine()) {
                buf.append(isScanner.nextLine() + "\n");
            }
            String responseContent = buf.toString();

            // add line returns between tags to make it a bit more readable
            responseContent = responseContent.replaceAll("><", ">\n<");

            // Output response to standard out
            System.out.println(responseContent);
        } catch (Exception e) {
            // Print any exceptions that occur
            e.printStackTrace();
        } finally {
            if (conn != null)
                conn.disconnect();
        }
    }
}
0 votes
I think I found the syntax for this:

<sci_request version="1.0">
<send_message cache="false">
<targets>
<device id="00000000-00000000-00409DFF-FF######"/>
</targets>
<rci_request version="1.1">
<query_setting>
<InputOutput>
<P0></P0>
</InputOutput>
</query_setting>
</rci_request>
</send_message>
</sci_request>
answered Jan 14, 2016 by userid0 Veteran of the Digi Community (2,158 points)
So the syntax works, but I only get back the indication that P0 is set as an input.  This is the reply I get:
<sci_reply version="1.0"><send_message><device id="00000000-00000000-00409DFF-FF######"><rci_reply version="1.1"><query_setting><InputOutput><P0>Input</P0></InputOutput></query_setting></rci_reply></device></send_message></sci_reply>
Unfortunately, this only seems to show the setting and not the state.  I am not able to find a means to query the state via SCI/RCI.
...