Hello There, Guest!
View New Posts  |  View Today's Posts
Bosch RCP CGI command formatting

  • 0 Vote(s) - 0 Average

11-17-2016, 03:47 PM #1
Posts: 9,733 Threads:1,026 Joined: Jun 2011 Reputation: 76

Bosch RCP CGI command formatting
Might not be entirely useful to a lot of people unless you have one of these Bosch cameras. I was writing a module that would help me control it and I didn't need FULL control so I decided to go with the RCP over CGI protocol and basic HTTP authentication in the request header.

Here's a little bit of code I used to help me format the CGI payload strings written in C:

#ifdef _MSC_VER
#  pragma warning(disable: 4996)

#include <stdio.h>
#include <stdint.h>
#define UNUSED(x) (void)(x)

#define MAX_PAYLOAD 64



#define BICOM_OPCODE_GET              0x01
#define BICOM_OPCODE_SET              0x02
#define BICOM_OPCODE_SET_GET          0x03
#define BICOM_OPCODE_INC              0x04
#define BICOM_OPCODE_INC_GET          0x05
#define BICOM_OPCODE_DEC              0x06
#define BICOM_OPCODE_DEC_GET          0x07
#define BICOM_OPCODE_SET_DEFAULT      0x08

#define BICOM_SERVER_DEVICE  0x0002
#define BICOM_SERVER_CAMERA  0x0004
#define BICOM_SERVER_PTZ     0x0006
#define BICOM_SERVER_CA      0x0008
#define BICOM_SERVER_IO      0x0010
#define BICOM_SERVER_VCA     0x0012

#define OBJECT_ID(id) ((id) >> 4)
#define MEMBER_ID(id) ((id) & 0xf)

char *bicom_payload(int flag, int serverID, int obj_id, int member_id,
                   int opcode, const char *databytes, size_t datalen,
                   char *payload)
    int n;
    size_t l = 0;
    n = sprintf(payload, "0x%02X%04X%03X%01X%02X", flag, serverID, obj_id, member_id, opcode);
    for (; l < datalen; ++l)
        sprintf((payload + n + l), "%02X", databytes[l]);
    payload[l + n + 1] = 0;
    return payload;

void print_rcp_relative_path(int command, const char *type, int num, const char *operation, const char *payload)
    /* /rcp.xml?command=0x09A5&type=P_OCTET&num=1&direction=WRITE&payload=0x800004024101 */
    printf("/rcp.xml?command=0x%04X&type=%s&num=%d&direction=%s&payload=%s", command, type, num, operation, payload);

int main(int argc, const char *argv[])
    char payload[MAX_PAYLOAD];

    unsigned int obj_id    = 0x024;   /* wiper */
    unsigned int member_id = 0x1;     /* movement */
    const char data[]     = "\x01";   /* start */

        obj_id, member_id,
        data, sizeof(data) - 1,

    print_rcp_relative_path(CONF_BICOM_COMMAND, "P_OCTET", 1, "WRITE", payload);

    return 0;

Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer

Development Site: aceinfinity.net

 ▲ ▲

Forum Jump:

Users browsing this thread: 1 Guest(s)