killswitch implemented
This commit is contained in:
parent
c7ad0b69ab
commit
d8966aae22
|
@ -172,6 +172,17 @@
|
|||
<inttypes.h>
|
||||
<arpa/inet.h>
|
||||
|
||||
1395876458 source:/home/chch/HengLongUDPclient/checkvideo.c
|
||||
1395878369 source:/home/chch/HengLongUDPclient/checkvideo.c
|
||||
"checkvideo.h"
|
||||
|
||||
1396204073 source:/home/chch/HengLongUDPclient/checkkillswitch.c
|
||||
"checkkillswitch.h"
|
||||
|
||||
1396202748 /home/chch/HengLongUDPclient/checkkillswitch.h
|
||||
<stdio.h>
|
||||
<string.h>
|
||||
<unistd.h>
|
||||
<arpa/inet.h>
|
||||
<string.h>
|
||||
<sys/time.h>
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,62 @@
|
|||
|
||||
#include "checkkillswitch.h"
|
||||
|
||||
|
||||
int getPage(char* ip, uint16_t port, char* url, char* recvBuffer, uint32_t size)
|
||||
{
|
||||
int sockfd = 0, n = 0;
|
||||
//char recvBuff[1024];
|
||||
char sendBuff[1024];
|
||||
struct sockaddr_in serv_addr;
|
||||
|
||||
memset(recvBuffer, '0',size);
|
||||
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
printf("\n Error : Could not create socket \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(&serv_addr, '0', sizeof(serv_addr));
|
||||
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_port = htons(port);
|
||||
|
||||
if(inet_pton(AF_INET, ip, &serv_addr.sin_addr)<=0)
|
||||
{
|
||||
printf("\n inet_pton error occured\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
|
||||
{
|
||||
printf("\n Error : Connect Failed \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sprintf(sendBuff, "GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", url, ip);
|
||||
|
||||
n = write(sockfd, sendBuff, strlen(sendBuff));
|
||||
|
||||
n = read(sockfd, recvBuffer, size-1);
|
||||
recvBuffer[n] = 0;
|
||||
|
||||
printf("%s\n", recvBuffer);
|
||||
|
||||
if(n < 0)
|
||||
{
|
||||
printf("\n Read error \n");
|
||||
}
|
||||
close(sockfd);
|
||||
return n;
|
||||
}
|
||||
|
||||
int checkkillswitch(char* ip, uint16_t port, char* url)
|
||||
{
|
||||
char rb[1024];
|
||||
int n;
|
||||
if(0==ip[0]) return 0;
|
||||
getPage(ip, port, url, rb, sizeof(rb));
|
||||
n = strstr(rb, "true");
|
||||
if(NULL != n) return 1;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef CHECKKILLSWITCH_H_INCLUDED
|
||||
#define CHECKKILLSWITCH_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
int getPage(char* ip, uint16_t port, char* url, char* recvBuffer, uint32_t size);
|
||||
int checkkillswitch(char* ip, uint16_t port, char* url);
|
||||
|
||||
#endif // CHECKKILLSWITCH_H_INCLUDED
|
|
@ -9,3 +9,4 @@ SERVER 192.168.1.13:32000
|
|||
TIMEOUT 250
|
||||
CLINBR 0
|
||||
VIDEO 192.168.1.20:8080
|
||||
KILLSW 192.168.1.20:8080/status
|
||||
|
|
17
main.c
17
main.c
|
@ -24,6 +24,7 @@
|
|||
#include "wansview.h"
|
||||
#include "extern.h"
|
||||
#include "checkvideo.h"
|
||||
#include "checkkillswitch.h"
|
||||
|
||||
typedef struct outtty_t
|
||||
{
|
||||
|
@ -266,10 +267,12 @@ typedef struct henglongconf_t
|
|||
in_addr_t ip; // v4 only
|
||||
char cam[64];
|
||||
char video[16];
|
||||
char killsw[16];
|
||||
char killurl[256];
|
||||
char user[64];
|
||||
char pwd[64];
|
||||
uint32_t caminterval;
|
||||
uint16_t port, videoport;
|
||||
uint16_t port, videoport, killport;
|
||||
uint8_t timeout;
|
||||
uint8_t clinbr;
|
||||
} henglongconf_t;
|
||||
|
@ -296,6 +299,9 @@ henglongconf_t getconfig(char* conffilename)
|
|||
conf.pwd[0] = 0;
|
||||
conf.video[0] = 0;
|
||||
conf.videoport = 0;
|
||||
conf.killsw[0] = 0;
|
||||
conf.killport = 0;
|
||||
conf.killurl[0] = 0;
|
||||
while(fgets(line, 256, configFile)){
|
||||
sscanf(line, "%16s %256s", parameter, value);
|
||||
if(0==strcmp(parameter,"KEYBOARD")){
|
||||
|
@ -332,6 +338,9 @@ henglongconf_t getconfig(char* conffilename)
|
|||
if(0==strcmp(parameter,"VIDEO")){
|
||||
sscanf(value, "%16[^:]:%" SCNu16, conf.video, &conf.videoport);
|
||||
}
|
||||
if(0==strcmp(parameter,"KILLSW")){
|
||||
sscanf(value, "%16[^:]:%" SCNu16 "%256s", conf.killsw, &conf.killport, conf.killurl);
|
||||
}
|
||||
}
|
||||
return conf;
|
||||
}
|
||||
|
@ -374,6 +383,7 @@ void *cam_ctrl_thread_fcn(void* arg)
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
|
||||
pthread_t keybthread, joythread, refl_thread, cam_ctrl_thread;
|
||||
input_thread_t keyboard_thread_args;
|
||||
input_thread_t joystick_thread_args;
|
||||
|
@ -456,6 +466,11 @@ int main(int argc, char* argv[])
|
|||
printf("No video stream connection from %s:%u, remote control locked!\n", conf.video, conf.videoport);
|
||||
continue;
|
||||
}
|
||||
if(0==checkkillswitch(conf.killsw,conf.killport,conf.killurl)){
|
||||
printf("Killswitch pressed or no connection.!\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
frame = 0xc0ffee;
|
||||
|
||||
time_us = get_us();
|
||||
|
|
Binary file not shown.
BIN
obj/Debug/main.o
BIN
obj/Debug/main.o
Binary file not shown.
Loading…
Reference in New Issue