| | |
| | | #define HPR_OK 0 |
| | | #define HPR_ERROR -1 |
| | | |
| | | #define MAX_NUM 16 |
| | | #define MAX_NUM 32 |
| | | #define MAX 1024 |
| | | #define fileread_buf 128 |
| | | |
| | |
| | | ET_HCNET_DECODER_POPWIN, // 3 |
| | | ET_HCNET_DECODER_LOGO, // 4 |
| | | ET_HCNET_DECODER_ALARMOUT, // 5 |
| | | ET_HCNET_DECODER_LOGO_ALARMOUT, // 6 |
| | | ET_HCNET_DECODER__LAST, |
| | | ET__LAST |
| | | }; |
| | |
| | | int channel; |
| | | uint16_t byWallNo; |
| | | uint16_t dwSubWinNo; |
| | | uint16_t dwWinNo; |
| | | std::vector<uint16_t> dwWinNo; |
| | | uint16_t lAlarmOutPort; |
| | | }; |
| | | |
| | |
| | | pthread_t thread_no[MAX_NUM]; |
| | | pthread_t thread_noEQ[MAX_NUM]; |
| | | pthread_t thread_Real[MAX_NUM]; |
| | | sockinfo equipments[16]; |
| | | int sock_upper[16],sock_down[16]; |
| | | int rsock_down[16]; |
| | | sockinfo equipments[MAX_NUM]; |
| | | int sock_upper[MAX_NUM],sock_down[MAX_NUM]; |
| | | int rsock_down[MAX_NUM]; |
| | | char byte_array[2600]; |
| | | int bbbbb=0; |
| | | int CommandEquipIdx=0; |
| | | int CommandKind[16]; |
| | | char sessionIDs[16][5]; |
| | | int CommandKind[MAX_NUM]; |
| | | char sessionIDs[MAX_NUM][5]; |
| | | |
| | | char linkequip_ip[32]; |
| | | char linkequip_port[10]; |
| | |
| | | |
| | | int NUM=0,equip_num=0; |
| | | |
| | | int SupperConnectedflag[16]={0,},EquipConnectedflag[16]={0,},serverflag=0,GPIO_flag=0; |
| | | int EquipRealAlarmConnectedflag[16]; |
| | | int SupperConnectedflag[MAX_NUM]={0,},EquipConnectedflag[MAX_NUM]={0,},serverflag=0,GPIO_flag=0; |
| | | int EquipRealAlarmConnectedflag[MAX_NUM]; |
| | | timer_t* timerID; |
| | | |
| | | std::vector<std::string> SupperConnectedIP; |
| | |
| | | int GPIO_READ(int PortNum); |
| | | void GPIO_WRITE(int PortNum,unsigned char DATA); |
| | | int RealEventStart(int Idx); |
| | | int gCapturing[16]; |
| | | char sessions[16][10]; |
| | | int gCapturing[MAX_NUM]; |
| | | char sessions[MAX_NUM][10]; |
| | | |
| | | int n=0,m=0,k=0; |
| | | unsigned char DownBuffer[16][614000]; |
| | | int DownCount[16]; |
| | | unsigned char DownBuffer[MAX_NUM][614000]; |
| | | int DownCount[MAX_NUM]; |
| | | int gCount=0; |
| | | int gCount30s=0; |
| | | int gCount2s=0; |
| | |
| | | gCount2s++; |
| | | if(gCount2s>=8){ |
| | | gCount2s=0; |
| | | for(;CommandEquipIdx<16;CommandEquipIdx++){//connected |
| | | for(;CommandEquipIdx<MAX_NUM;CommandEquipIdx++){//connected |
| | | if(EquipConnectedflag[CommandEquipIdx]>0) break; |
| | | } |
| | | if(CommandEquipIdx>=16){ |
| | | if(CommandEquipIdx>=MAX_NUM){ |
| | | CommandEquipIdx = 0; |
| | | } |
| | | } |
| | |
| | | |
| | | int hcnetsdk_get_userid(const std::string& decode_ip) |
| | | { |
| | | hcnetsdk_user_t::const_iterator iter = g_hcnetsdk_user.find(decode_ip); |
| | | if(iter == g_hcnetsdk_user.end()) |
| | | return -1; |
| | | else |
| | | return iter->second; |
| | | return hcnetsdk_user; |
| | | //hcnetsdk_user_t::const_iterator iter = g_hcnetsdk_user.find(decode_ip); |
| | | //if(iter == g_hcnetsdk_user.end()) |
| | | // return -1; |
| | | //else |
| | | // return iter->second; |
| | | } |
| | | |
| | | void CALLBACK hcnetsdk_ExceptionCallBack(DWORD dwType, LONG lUserID, LONG lHandle, void *pUser) |
| | |
| | | printf("hcnetsdk_ExceptionCallBack: %d\n", int(dwType)); |
| | | } |
| | | |
| | | int hcnetsdk_alarm_alarmout(LONG lUserID, const HCNetCameraConfig& camConfig) |
| | | int hcnetsdk_alarm_alarmout(LONG lUserID, const HCNetCameraConfig& camConfig, bool isDisalarm) |
| | | { |
| | | //报警时间段 |
| | | NET_DVR_SCHEDTIME net_dvr_schedtime = {0}; |
| | |
| | | } |
| | | |
| | | //开启警报 |
| | | if(NET_DVR_SetAlarmOut(lUserID,camConfig.lAlarmOutPort,1) == FALSE){ |
| | | printf("NET_DVR_SetAlarmOut failed, err: %d\n", NET_DVR_GetLastError()); |
| | | } |
| | | //if(NET_DVR_SetAlarmOut(lUserID,camConfig.lAlarmOutPort,1) == FALSE){ |
| | | // printf("NET_DVR_SetAlarmOut failed, err: %d\n", NET_DVR_GetLastError()); |
| | | //} |
| | | last_alarmout = time(NULL); |
| | | |
| | | sleep(3); |
| | | //sleep(2); |
| | | |
| | | if (time(NULL) - last_alarmout >= 3) |
| | | if (isDisalarm) |
| | | { |
| | | //解除警报 |
| | | NET_DVR_SetAlarmOut(lUserID,camConfig.lAlarmOutPort,0); |
| | | //if (time(NULL) - last_alarmout >= 2) |
| | | //{ |
| | | //解除警报 |
| | | NET_DVR_SetAlarmOut(lUserID,camConfig.lAlarmOutPort,0); |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | //开启警报 |
| | | if(NET_DVR_SetAlarmOut(lUserID,camConfig.lAlarmOutPort,1) == FALSE){ |
| | | printf("NET_DVR_SetAlarmOut failed, err: %d\n", NET_DVR_GetLastError()); |
| | | } |
| | | last_alarmout = time(NULL); |
| | | } |
| | | } |
| | | |
| | |
| | | LONG lUserID; |
| | | |
| | | NET_DVR_DEVICEINFO_V30 struDeviceInfo; |
| | | lUserID = NET_DVR_Login_V30((char*)g_hcnetsdkconfig.serverIP.c_str(), g_hcnetsdkconfig.serverport, |
| | | hcnetsdk_user = lUserID = NET_DVR_Login_V30((char*)g_hcnetsdkconfig.serverIP.c_str(), g_hcnetsdkconfig.serverport, |
| | | (char*)g_hcnetsdkconfig.username.c_str(), (char*)g_hcnetsdkconfig.passwd.c_str(), &struDeviceInfo); |
| | | if (lUserID < 0) { |
| | | printf("NET_DVR_Login_V30 failed, err: %d\n", NET_DVR_GetLastError()); |
| | |
| | | return lUserID; |
| | | } |
| | | |
| | | HCNetCameraConfig* hcnetsdk_find_config(const std::string& decoder_ip) |
| | | HCNetCameraConfig* hcnetsdk_find_config(const sockinfo& oldEquipConfig, int newChannel) |
| | | { |
| | | for (size_t i = 0; i < NUM; i++) |
| | | { |
| | |
| | | if (equip->m_type > ET_HCNET_DECODER__FIRST || equip->m_type < ET_HCNET_DECODER__LAST) |
| | | { |
| | | HCNetCameraConfig* camConfig = (HCNetCameraConfig*)equip->user_config; |
| | | if (camConfig != NULL && equip->serverIP == decoder_ip) |
| | | return camConfig; |
| | | if (camConfig != NULL && strcmp(equip->ip, oldEquipConfig.ip) == 0) |
| | | { |
| | | if (camConfig->channel == newChannel) |
| | | return camConfig; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | int hcnetsdk_alarm_logo(LONG lUserID, const HCNetCameraConfig& _camConfig, const std::string& ip, int channel, bool disalarm) |
| | | { |
| | | HCNetCameraConfig camConfig(_camConfig); |
| | | if (camConfig.channel != channel) |
| | | { |
| | | camConfig.channel = -1; |
| | | sockinfo* equipConfig = hcnetsdk_find_equip(ip, channel); |
| | | if (equipConfig != NULL) |
| | | camConfig = *(HCNetCameraConfig*)(equipConfig->user_config); |
| | | } |
| | | //if (camConfig.channel != channel) |
| | | //{ |
| | | // camConfig.channel = -1; |
| | | // sockinfo* equipConfig = hcnetsdk_find_equip(ip, channel); |
| | | // if (equipConfig != NULL) |
| | | // camConfig = *(HCNetCameraConfig*)(equipConfig->user_config); |
| | | //} |
| | | |
| | | printf("hcnetsdk_alarm_logo, channel=%d, matchc=%d\n", channel, camConfig.channel); |
| | | |
| | |
| | | net_dvr_win_logo_cfg.dwSize = sizeof(net_dvr_win_logo_cfg); |
| | | //设置窗口输出logo |
| | | int byWallNo=1,dwSubWinNo=2,dwWinNo=1; |
| | | DWORD dwDecChanNum=(camConfig.byWallNo << 24) | (camConfig.dwSubWinNo << 16) | camConfig.dwWinNo; |
| | | if(!NET_DVR_SetDVRConfig(lUserID,NET_DVR_SET_WIN_LOGO_CFG,dwDecChanNum,&net_dvr_win_logo_cfg,net_dvr_win_logo_cfg.dwSize)) |
| | | |
| | | for (int i= 0; i < camConfig.dwWinNo.size(); i++) |
| | | { |
| | | printf("NET_DVR_SetDVRConfig2 error, err: %d\n", NET_DVR_GetLastError()); |
| | | return -1; |
| | | DWORD dwDecChanNum=(camConfig.byWallNo << 24) | (camConfig.dwSubWinNo << 16) | camConfig.dwWinNo[i]; |
| | | if(!NET_DVR_SetDVRConfig(lUserID,NET_DVR_SET_WIN_LOGO_CFG,dwDecChanNum,&net_dvr_win_logo_cfg,net_dvr_win_logo_cfg.dwSize)) |
| | | { |
| | | printf("NET_DVR_SetDVRConfig2 error, err: %d\n", NET_DVR_GetLastError()); |
| | | //return -1; |
| | | } |
| | | else |
| | | { |
| | | printf("NET_DVR_SetDVRConfig2 done.\n"); |
| | | //return 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | printf("NET_DVR_SetDVRConfig2 done.\n"); |
| | | //return 0; |
| | | } |
| | | |
| | | return 0; |
| | | |
| | | //sleep(3); |
| | | //net_dvr_win_logo_cfg.byEnable = 0; |
| | | //NET_DVR_SetDVRConfig(lUserID,NET_DVR_SET_WIN_LOGO_CFG,dwDecChanNum,&net_dvr_win_logo_cfg,net_dvr_win_logo_cfg.dwSize); |
| | | } |
| | | |
| | | |
| | | int hcnetsdk_alarm_logo_alarmout(LONG lUserID, const HCNetCameraConfig& _camConfig, const std::string& ip, int channel, bool disalarm) |
| | | { |
| | | HCNetCameraConfig camConfig(_camConfig); |
| | | //if (camConfig.channel != channel) |
| | | //{ |
| | | // camConfig.channel = -1; |
| | | // sockinfo* equipConfig = hcnetsdk_find_equip(ip, channel); |
| | | // if (equipConfig != NULL) |
| | | // camConfig = *(HCNetCameraConfig*)(equipConfig->user_config); |
| | | //} |
| | | |
| | | printf("hcnetsdk_alarm_logo, channel=%d, matchc=%d\n", channel, camConfig.channel); |
| | | |
| | | if (camConfig.channel < 0) |
| | | return -1; |
| | | |
| | | //窗口配置信息 |
| | | NET_DVR_WIN_LOGO_CFG net_dvr_win_logo_cfg; |
| | | net_dvr_win_logo_cfg.dwLogoNo = 1; |
| | | net_dvr_win_logo_cfg.byEnable = (disalarm ? 0 : 1);//0:hidden,1:visible |
| | | net_dvr_win_logo_cfg.byRes1[3] =0; |
| | | net_dvr_win_logo_cfg.dwCoordinateX = 5; |
| | | net_dvr_win_logo_cfg.dwCoordinateY =5; |
| | | net_dvr_win_logo_cfg.byFlash = 1; |
| | | net_dvr_win_logo_cfg.byTranslucent = 0; |
| | | net_dvr_win_logo_cfg.byRes2[34] = 0; |
| | | |
| | | net_dvr_win_logo_cfg.dwSize = sizeof(net_dvr_win_logo_cfg); |
| | | //设置窗口输出logo |
| | | int byWallNo=1,dwSubWinNo=2,dwWinNo=1; |
| | | |
| | | for (int i= 0; i < camConfig.dwWinNo.size(); i++) |
| | | { |
| | | DWORD dwDecChanNum=(camConfig.byWallNo << 24) | (camConfig.dwSubWinNo << 16) | camConfig.dwWinNo[i]; |
| | | if(!NET_DVR_SetDVRConfig(lUserID,NET_DVR_SET_WIN_LOGO_CFG,dwDecChanNum,&net_dvr_win_logo_cfg,net_dvr_win_logo_cfg.dwSize)) |
| | | { |
| | | printf("NET_DVR_SetDVRConfig2 error, err: %d\n", NET_DVR_GetLastError()); |
| | | //return -1; |
| | | } |
| | | else |
| | | { |
| | | printf("NET_DVR_SetDVRConfig2 done.\n"); |
| | | //return 0; |
| | | } |
| | | } |
| | | |
| | | //if (!disalarm) |
| | | //{ |
| | | //int hcnetsdk_alarm_alarmout(LONG lUserID, const HCNetCameraConfig& camConfig) |
| | | hcnetsdk_alarm_alarmout(lUserID, camConfig, disalarm); |
| | | //} |
| | | |
| | | return 0; |
| | | |
| | | //sleep(3); |
| | | //net_dvr_win_logo_cfg.byEnable = 0; |
| | | //NET_DVR_SetDVRConfig(lUserID,NET_DVR_SET_WIN_LOGO_CFG,dwDecChanNum,&net_dvr_win_logo_cfg,net_dvr_win_logo_cfg.dwSize); |
| | | } |
| | | |
| | | |
| | | int main(int argc,char **argv) |
| | | { |
| | |
| | | if (hcnetsdk_user < 0) |
| | | { |
| | | printf("hcnetsdk_user < 0"); |
| | | exit(EXIT_FAILURE); |
| | | exit(EXIT_FAILURE);//#todo if debug equipment(analizer), remove this |
| | | } |
| | | |
| | | /*Install timer_handler as th siganl handler for SIGVTALRM */ |
| | |
| | | int length=0; |
| | | char buff[102400]; |
| | | |
| | | //puts("Step.1 ========>Server Thread is strarted......"); |
| | | puts("Step.1 ========>Server Thread is strarted......"); |
| | | unsigned char data[4096]; |
| | | //=======================================equipment data================================ |
| | | int idx=0; |
| | |
| | | // length-=3; |
| | | // if(length<=0) continue; |
| | | //} |
| | | |
| | | |
| | | if(buff[0]==0x68 && buff[1]==0x03 ) |
| | | { |
| | | |
| | |
| | | void* MyEquipmentthread(void* arg) |
| | | { |
| | | int eidx = (int)arg; |
| | | //printf("Step.3 ===%d=====>RealTimeEvent Thread is strarted......\n",eidx); |
| | | const sockinfo& equipConfig(equipments[eidx]); |
| | | printf("Step.3 ===%d=====>RealTimeEvent Thread is strarted......\n",eidx); |
| | | |
| | | int length=0; |
| | | char buff[102400]; |
| | |
| | | } |
| | | else if(length>0) |
| | | { |
| | | std::cout << "buff: " << buff<<std::endl; |
| | | |
| | | bool isDisalarm = false; |
| | | if (strstr(buff, "ViqEventNotificationAlert") == NULL) // <urn |
| | | continue; |
| | | if (strstr(buff, "startTime") == NULL) // <urn |
| | | isDisalarm = true; |
| | | //std::cout << buff<<std::endl; |
| | | |
| | | int channel = -1; |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (channel==1) |
| | | { |
| | | int aa=1;//#todo break |
| | | } |
| | | |
| | | if(gCapturing[eidx]==1) |
| | | { |
| | | //add 20170327 |
| | | const std::string& ip(equipConfig.ip); |
| | | const HCNetCameraConfig* camConfig = (HCNetCameraConfig*)equipConfig.user_config; |
| | | camConfig = hcnetsdk_find_config(equipConfig, channel); |
| | | int lUserData = hcnetsdk_get_userid(ip); |
| | | if (camConfig != NULL && hcnetsdk_user >= 0) |
| | | { |
| | | std::cout << "......alarm begin k=" << k << std::endl; |
| | | if (equipConfig.m_type == ET_HCNET_DECODER_ALARMOUT && !isDisalarm) |
| | | hcnetsdk_alarm_alarmout(lUserData, *camConfig, isDisalarm); |
| | | else if (equipConfig.m_type == ET_HCNET_DECODER_LOGO) |
| | | hcnetsdk_alarm_logo(lUserData, *camConfig, ip, channel, isDisalarm); |
| | | else if (equipConfig.m_type == ET_HCNET_DECODER_LOGO_ALARMOUT) |
| | | hcnetsdk_alarm_logo_alarmout(lUserData, *camConfig, ip, channel, isDisalarm); |
| | | std::cout << "......alarm end k=" << k << std::endl; |
| | | } |
| | | else |
| | | { |
| | | std::cout << "alarm lost k=" << k << std::endl; |
| | | } |
| | | |
| | | |
| | | int k; |
| | | for(k=0;k<16;k++) |
| | | for(k=0;k<MAX_NUM;k++) |
| | | { |
| | | //if(SupperConnectedflag[k]==1) |
| | | //{ |
| | |
| | | //printf("%s",buff); |
| | | //} |
| | | //else |
| | | { |
| | | if(SupperConnectedIP.size() > k) |
| | | { |
| | | const std::string& ip(SupperConnectedIP[k]); |
| | | sockinfo* equipConfig = hcnetsdk_find_equip(ip); |
| | | HCNetCameraConfig* camConfig = hcnetsdk_find_config(ip); |
| | | int lUserData = hcnetsdk_get_userid(ip); |
| | | if (camConfig != NULL && equipConfig != NULL && lUserData >= 0) |
| | | { |
| | | std::cout << "alarm begin k=" << k << std::endl; |
| | | if (equipConfig->m_type == ET_HCNET_DECODER_ALARMOUT && !isDisalarm) |
| | | hcnetsdk_alarm_alarmout(lUserData, *camConfig); |
| | | else if (equipConfig->m_type == ET_HCNET_DECODER_LOGO) |
| | | hcnetsdk_alarm_logo(lUserData, *camConfig, ip, channel, isDisalarm); |
| | | std::cout << "alarm end k=" << k << std::endl; |
| | | } |
| | | else |
| | | { |
| | | //std::cout << "alarm lost k=" << k << std::endl; |
| | | } |
| | | } |
| | | } |
| | | //{ |
| | | // if(SupperConnectedIP.size() > k) |
| | | // { |
| | | // const std::string& ip(SupperConnectedIP[k]); |
| | | // sockinfo* equipConfig = hcnetsdk_find_equip(ip); |
| | | // HCNetCameraConfig* camConfig = hcnetsdk_find_config(ip); |
| | | // int lUserData = hcnetsdk_get_userid(ip); |
| | | // if (camConfig != NULL && equipConfig != NULL && lUserData >= 0) |
| | | // { |
| | | // std::cout << "......alarm begin k=" << k << std::endl; |
| | | // if (equipConfig->m_type == ET_HCNET_DECODER_ALARMOUT && !isDisalarm) |
| | | // hcnetsdk_alarm_alarmout(lUserData, *camConfig); |
| | | // else if (equipConfig->m_type == ET_HCNET_DECODER_LOGO) |
| | | // hcnetsdk_alarm_logo(lUserData, *camConfig, ip, channel, isDisalarm); |
| | | // std::cout << "......alarm end k=" << k << std::endl; |
| | | // } |
| | | // else |
| | | // { |
| | | // std::cout << "alarm lost k=" << k << std::endl; |
| | | // } |
| | | // } |
| | | //} |
| | | } |
| | | continue; |
| | | } |
| | |
| | | camConfig->channel = jsonUserConfig["channel"].asInt(); |
| | | camConfig->byWallNo = jsonUserConfig["byWallNo"].asInt(); |
| | | camConfig->dwSubWinNo = jsonUserConfig["dwSubWinNo"].asInt(); |
| | | camConfig->dwWinNo = jsonUserConfig["dwWinNo"].asInt(); |
| | | |
| | | Json::Value dwWinNoArrays = jsonUserConfig["dwWinNo"]; |
| | | if (dwWinNoArrays.isArray()) |
| | | { |
| | | const int s = (int)(dwWinNoArrays.size()); |
| | | for(int i = 0; i < s; i++) |
| | | { |
| | | camConfig->dwWinNo.push_back(dwWinNoArrays[i].asInt()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | camConfig->dwWinNo.push_back(dwWinNoArrays.asInt()); |
| | | } |
| | | |
| | | camConfig->lAlarmOutPort = jsonUserConfig["lAlarmOutPort"].asInt(); |
| | | } |
| | | |
| | |
| | | return n; |
| | | } |
| | | //for real event |
| | | void MakeAuthorizedPacketReal(char* buff,int length, char* Method,char* uri,int Idx) |
| | | void MakeAuthorizedPacketReal_Digest(char* buff,int length, char* Method,char* uri,int Idx) |
| | | { |
| | | char Device[150] ; |
| | | char Realm_buf1[512] ; |
| | |
| | | memset(domain_buf4,0,512); |
| | | |
| | | CharToByte((char*)buff, Device, length,Realm_buf1,nonce_buf2,auth_buf3,domain_buf4, len); |
| | | const char* cnonce_buf="163acd0e58793a190f29ee879d4b224f";//"08a9d86c1b5e45963cf82f43dca59c51"; |
| | | const char* cnonce_buf="1oBAAAqkwXP9q9MorVCzgw5LNPc";//"08a9d86c1b5e45963cf82f43dca59c51"; |
| | | Realm_buf1[len[0]]=0; |
| | | nonce_buf2[len[1]]=0; |
| | | auth_buf3[len[2]]=0; |
| | |
| | | byte_array[iidx]=0; |
| | | |
| | | } |
| | | |
| | | void MakeAuthorizedPacketReal_Basic(char* buff,int length, char* Method,char* uri,int Idx) |
| | | { |
| | | /* |
| | | POST /PSIA/VIQ/System/sessions HTTP/1.1 |
| | | Content-Length: 0 |
| | | Host: 192.168.1.5:80 |
| | | Connection: Keep-Alive |
| | | Authorization: Basic c3VwZXJ2aXNvcjpzdXBlcnZpc29y |
| | | */ |
| | | |
| | | int i = 0; |
| | | sprintf(byte_array, |
| | | "%s %s HTTP/1.1\r\n" |
| | | "Content-Length: 0\r\n" |
| | | "Host: %s:80\r\n" |
| | | "Connection: Keep-Alive\r\n" |
| | | "Authorization: Basic %s\r\n" |
| | | "\r\n", |
| | | Method, |
| | | uri, |
| | | equipments[Idx].ip, |
| | | "c3VwZXJ2aXNvcjpzdXBlcnZpc29y" // base64(supervisor:supervisor) |
| | | ); |
| | | } |
| | | |
| | | //// 功能:开始查看实时监控 |
| | | //// 输入:分析器IP,用户,密码 |
| | | //// 输出:0(成功), -1(初始化失败),-2(连接失败) |
| | |
| | | sigset(SIGALRM, u_alarm_handler);//add 2016.11.22 |
| | | alarm(2); |
| | | length=read(rsock_down[Idx],&buff,sizeof(buff)); |
| | | //printf("RESPONSE: %s\n",&buff); |
| | | alarm(0); |
| | | sigrelse(SIGALRM); |
| | | //printf("Myequipment connect ==================length =%d:\n",length); |
| | |
| | | if(memorycmp((unsigned char*)buff,length, "WWW-Authenticate:",17)>0 && bbbb==0) |
| | | { |
| | | // analyse reception |
| | | MakeAuthorizedPacketReal(buff,length,"POST","/PSIA/VIQ/System/sessions/permanent",Idx); |
| | | zclock_sleep(100); |
| | | write(rsock_down[Idx],byte_array,strlen(byte_array)); |
| | | // printf("%s\n",(char*)byte_array); |
| | | MakeAuthorizedPacketReal_Basic(buff,length,"POST","/PSIA/VIQ/System/sessions/permanent",Idx); |
| | | //for(int ii=0;ii<4;ii++) |
| | | //{ |
| | | zclock_sleep(100); |
| | | write(rsock_down[Idx],byte_array,strlen(byte_array)); |
| | | //} |
| | | printf("%s\n",(char*)byte_array); |
| | | bbbb=1; |
| | | continue; |
| | | continue;//#todo 20170325 |
| | | //break; |
| | | } |
| | | if(bbbb==1){ |
| | | //if (strstr((char*)buff,"Unauthorized") != NULL) |
| | | //{ |
| | | // bbbb=0; |
| | | //} |
| | | |
| | | int sidx = stringcmp((char*)buff,"<urn:id>",8); |
| | | if(sidx >=0){//<urn:ViqDateTimeInterval urn:version="1.0" xmlns:urn="urn:videoiq-com"><urn:startTime urn:version="1.0"><urn:date>2016-08-18T01:07:20.749</urn:date><urn:offset>0</urn:offset></urn:startTime><urn:endTime urn:version="1.0"><urn:date>2016-08-29T08:33:48.231</urn:date><urn:offset>0</urn:offset></urn:endTime></urn:ViqDateTimeInterval> |
| | | int eidx = stringcmp((char*)buff,"</urn:id>",9); |
| | |
| | | } |
| | | char uri[200]; |
| | | sprintf(uri,"/PSIA/Custom/Event/notification/notificationStream?sessionId=%s",sessions[Idx]); |
| | | //sprintf(uri,"/PSIA/Custom/Event/notification/notificationStream?sessionId=5"); |
| | | printf("/PSIA/Custom/Event/notification/notificationStream?sessionId=%s\n",sessions[Idx]); |
| | | length = sprintf(byte_array,"GET %s HTTP/1.1\r\nContent-Type: text/xml\r\nHost: %s\r\nContent-Length: 0\r\nConnection: Keep-Alive\r\n\r\n",uri,equipments[Idx].ip); |
| | | write(rsock_down[Idx],byte_array,strlen(byte_array)); |
| | | while(1){ |
| | |
| | | { |
| | | char uri[200]; |
| | | sprintf(uri,"/PSIA/Custom/Event/notification/notificationStream?sessionId=%s",sessions[Idx]); |
| | | MakeAuthorizedPacketReal(buff,length,"GET",uri,Idx); |
| | | MakeAuthorizedPacketReal_Basic(buff,length,"GET",uri,Idx); |
| | | //for(int ii=0;ii<4;ii++) |
| | | //{ |
| | | zclock_sleep(100); |
| | | write(rsock_down[Idx],byte_array,strlen(byte_array)); |
| | | // printf("%s\n",(char*)byte_array); |
| | | //} |
| | | printf("%s\n",(char*)byte_array); |
| | | bbbb=3; |
| | | continue; |
| | | } |