lib/xbee-rx.js
function _remoteCommand(command, destination64, destination16, timeoutMs, commandParameter, broadcast) {
        var frame = {
                type: xbee_api.constants.FRAME_TYPE.REMOTE_AT_COMMAND_REQUEST,
                command: command,
                commandParameter: commandParameter,
                destination64: destination64,
                destination16: destination16
            },
            responseStream;

        if (debug) {
            console.log("Sending", command, "to", destination64, "with parameter", commandParameter || []);
        }

        responseStream = _sendFrameStreamResponse(frame, timeoutMs, xbee_api.constants.FRAME_TYPE.REMOTE_COMMAND_RESPONSE).pipe(
            rx.operators.flatMap(function(frame) {
                if (frame.commandStatus === xbee_api.constants.COMMAND_STATUS.REMOTE_CMD_TRANS_FAILURE) {
                    // if there was a remote command transmission failure, throw error
                    return rx.throwError(new Error(xbee_api.constants.COMMAND_STATUS[frame.commandStatus]));
                }
                // any other response is returned
                return rx.of(frame);
            })
        );

        if (broadcast) {
            return responseStream;
        } else {
            // if not broadcast, there can be only one response packet
            return responseStream.pipe(rx.operators.take(1));
        }
    }
function _remoteCommand(command, destination64, destination16, timeoutMs, commandParameter, broadcast) {
        var frame = {
                type: xbee_api.constants.FRAME_TYPE.REMOTE_AT_COMMAND_REQUEST,
                command: command,
                commandParameter: commandParameter,
                destination64: destination64,
                destination16: destination16
            },
            responseStream;

        if (debug) {
            console.log("Sending", command, "to", destination64, "with parameter", commandParameter || []);
        }

        responseStream = _sendFrameStreamResponse(frame, timeoutMs, xbee_api.constants.FRAME_TYPE.REMOTE_COMMAND_RESPONSE).pipe(
            rx.operators.flatMap(function(frame) {
                if (frame.commandStatus === xbee_api.constants.COMMAND_STATUS.REMOTE_CMD_TRANS_FAILURE) {
                    // if there was a remote command transmission failure, throw error
                    return rx.throwError(new Error(xbee_api.constants.COMMAND_STATUS[frame.commandStatus]));
                }
                // any other response is returned
                return rx.of(frame);
            })
        );

        if (broadcast) {
            return responseStream;
        } else {
            // if not broadcast, there can be only one response packet
            return responseStream.pipe(rx.operators.take(1));
        }
    }
function _remoteCommand ( command , destination64 , destination16 , timeoutMs , commandParameter , broadcast ) { var frame = { type : xbee_api . constants . FRAME_TYPE . REMOTE_AT_COMMAND_REQUEST , command : command , commandParameter : commandParameter , destination64 : destination64 , destination16 : destination16 } , responseStream ; if ( debug ) { console . log ( "Sending" , command , "to" , destination64 , "with parameter" , commandParameter || [ ] ) ; } responseStream = _sendFrameStreamResponse ( frame , timeoutMs , xbee_api . constants . FRAME_TYPE . REMOTE_COMMAND_RESPONSE ) . pipe ( rx . operators . flatMap ( function ( frame ) { if ( frame . commandStatus === xbee_api . constants . COMMAND_STATUS . REMOTE_CMD_TRANS_FAILURE ) { // if there was a remote command transmission failure, throw error return rx . throwError ( new Error ( xbee_api . constants . COMMAND_STATUS [ frame . commandStatus ] ) ) ; } // any other response is returned return rx . of ( frame ) ; } ) ) ; if ( broadcast ) { return responseStream ; } else { // if not broadcast, there can be only one response packet return responseStream . pipe ( rx . operators . take ( 1 ) ) ; } }
Sends a the given command and parameter to the given destination. A stream is returned that will emit to the resulting command data on success or end in an Error with the failed status as the text. Only one of destination64 or destination16 should be given; the other should be undefined.
Sends a the given command and parameter to the given destination . A stream is returned that will emit to the resulting command data on success or end in an Error with the failed status as the text . Only one of destination64 or destination16 should be given ; the other should be undefined .