AceInfinity
Emeritus, Contributor
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:
Here's a little bit of code I used to help me format the CGI payload strings written in C:
Code:
[NO-PARSE]#ifdef _MSC_VER
# pragma warning(disable: 4996)
#endif
#include <stdio.h>
#include <stdint.h>
#define UNUSED(x) (void)(x)
#define MAX_PAYLOAD 64
#define CONF_BICOM_COMMAND 0x09A5
#define BICOM_FLAG_NO_RETURN_PAYLOAD 0x80
#define BICOM_FLAG_RETURN_PAYLOAD 0x81
#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_OPCODE_SET_GET_DEFAULT 0x09
#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 */
bicom_payload(
BICOM_FLAG_NO_RETURN_PAYLOAD,
BICOM_SERVER_CAMERA,
obj_id, member_id,
BICOM_OPCODE_SET_GET,
data, sizeof(data) - 1,
payload
);
print_rcp_relative_path(CONF_BICOM_COMMAND, "P_OCTET", 1, "WRITE", payload);
UNUSED(argc);
UNUSED(argv);
return 0;
}[/NO-PARSE]