IOS

CGI操作

版本/作者/日期修改内容
1.0/Sandy/2015-09-24初版

16.CGI操作

条件:
摄像机连接成功
语法:
1)设置参数cgi

set_params.cgi?

2)消息通知

FOUNDATION_EXPORT NSString* const IPCamera_SetParam_Result;

3) 设置成功后的消息回调

-(void)IPCamera_response_function:(NSNotification*)note;

IPCamera.h宏定义了两种注册消息的方法
#define ADD_IPCAMERA_RESPONSE_WITHOUT_ARG(notice_name) \
    [[NSNotificationCenter defaultCenter] addObserver: self selector:               @selector(IPCamera_response_function:) name: notice_name object: nil]

#define ADD_IPCAMERA_RESPONSE_WITH_ARG(notice_name,camera_object) \
    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(IPCamera_response_function:) name: notice_name object: camera_object]
示列:
设置cam 频率  60HZ: int frequency_ = 0  50HZ: int frequency_ = 1  室外: int frequency_ = 2
cgi:http://192.168.0.79:80/set_params.cgi?user= admin&pwd=123456hh&powerfreq=0&save=1&reinit_camera=1
1)注册消息

ADD_IPCAMERA_RESPONSE_WITH_ARG( IPCamera_SetParam_Result, cam_)

2)cgi设置参数
    设置cam 频率  60HZ: int frequency_ = 0  50HZ: int frequency_ = 1  室外: int frequency_ = 2
    cgi:http://192.168.0.79:80/set_params.cgi?user= admin&pwd=123456hh&powerfreq=0&save=1&reinit_camera=1



NSString *getURLString =[NSString stringWithFormat:@"http://%@:%@/set_params.cgi?user=%@&pwd=%@&save=1&powerfreq=%@&reinit_camera=1",
                                  cam_.host,
                                  cam_.port,
                                  cam_.user,
                                  cam_.pwd,
                                  frequency_
                                  ];
[NSString stringWithContentsOfURL:[NSURL URLWithString:getURLString] encoding:NSUTF8StringEncoding error:&error];
3)参数设置成功后的消息回调
 -(void)IPCamera_response_function:(NSNotification*)note
{    

    NSDictionary* dic = note.userInfo;

    if( [note.name isEqualToString: IPCamera_SetParam_Result ])
    {
        NSLog(@"设置参数成功!");}
}
版权所有:深圳新瑞彩网络科技有限公司

信产部备案号:粤ICP备09050685号