QR Code Network Setup Process Explanation
1 Import libP6SCore.a ,libEchoSoftUICore.a, libEchoSoftAPICore.a,libPPCS_API_64.a and P6Score, libEchoSoftUICore,libEchoSoftAPICore,FFmpeg-iOS folder and EchoP2Pclient.h EchoP2Pclient.mm file into the project
3.Set Enable Testability in the Build settings to No
xxxxxxxxxx
/// Initialization
/**
*@param userId use @""
* @param codeStr1 use @""
* @param codeStr2 use@""
* @return`
*/
-(BOOL)p2pConnectWithId:(NSString*)userId codeStr1:(NSString*)codeStr1 codeStr2:(NSString*)codeStr2;
1.Function description
SDK initialization
Declaration class:
DevicesManage.h
2.Parameter
Parameter | Description |
---|---|
userId | use @"" |
codeStr1 | use @"" |
codeStr2 | use @"" |
Return value
4.Simple sample code
xxxxxxxxxx
4.Simple sample code
[[EchoP2PClient sharedP2PClient] p2pConnectWithId:@"" codeStr1:@"" codeStr2:@""];
xxxxxxxxxx
/**
* @brief Deinitialize the P2P SDK
*/
-(void) uninitOperate;
1.Function description
Deinitialize the P2P SDK
Declaration class:
DevicesManage.h
2.Parameter:
3.Return value:
4.Simple sample code:
xxxxxxxxxx
/// Deinitialize
[[EchoP2PClient sharedP2PClient] uninitOperate];
xxxxxxxxxx
/**
@brief Detect device P2P connection status
@param in_strDID Device DID
@return 0 indicates that the P2P connection is successful, non-zero indicates that the P2P connection fails
*/
-(int) checkStatus:(NSString*) in_strDID;
Function description
Obtain the connection status of APP and device P2P
Declaration class
xxxxxxxxxx
DevicesManage.h
Specify the context (depending on or with which interfaces)
Before making a P2P connection with the device, this interface needs to be called to detect the P2P connection status between the APP and the device.
Usually used with the following functions
xxxxxxxxxx
-(void) getContactsState:(NSString *)DID;//Establish a P2P connection with the device
Parameter
Parameter | Instructions |
---|---|
in_strDID | Device DID |
Return value
Return value | Instructions |
---|---|
The connection status of the device(Int) | 0 indicates that the P2P connection is successful, non-zero indicates that the P2P connection fails |
Simple sample code
xxxxxxxxxx
int iStatus = [[EchoP2PClient sharedP2PClient] checkStatus:self.contactId];
xxxxxxxxxx
/**
@brief Establish a P2P connection with the device
@discusstion Before interacting with the device, it is necessary to establish a P2P connection with the device
@param DID Device DID
*/
-(void) getContactsState:(NSString *)DID;
Function description
Establish a P2P connection with the device
Declaration class
xxxxxxxxxx
DevicesManage.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | Instructions |
---|---|
DID | Device DID |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] getContactsState:did];
xxxxxxxxxx
/**
Send password verification
@param in_strDID Device did
@param strUserName device account
@param strUserpassword device password
*/
-(void) sendAuth:(NSString*) in_strDID withUserName:(NSString*)strUserName withUserpassword:(NSString*)strUserpassword;
Function description
Log in to the device and authenticate (device without sharing)
Declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Instructions |
---|---|
in_strDID | Device DID |
strUserName | username |
strUserpassword | password |
Return value(notification return code:RET_VALIDATION_PASSWORD)
Return value | Instructions |
---|---|
AutoBind | Whether to support reset unbinding, 0: not supported, 1: supported |
DeviceShared | Whether to support sharing, 0: not supported, 1: supported |
auth | ok: authentication succeeded, failed: authentication failed |
authContactId | device did |
did | device did |
is_pwd_correct | Whether the device password is correct, 0: wrong, 1: correct (only some devices support) |
key | command number |
result | ok: authentication succeeded, failed: authentication failed |
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendAuth:did withUserName:username withUserpassword:password];
xxxxxxxxxx
/**
Send password verification (for shared devices, pass in the secretString of the owner or visitor)
@param in_strDID device did
@param strUserName device account
@param strUserpassword device password
@param secretString Secret key (obtained from the bonded device or become the master interface)
@param isOWN Is it the master
*/
-(void) sendAuthV2:(NSString*) in_strDID withUserName:(NSString*)strUserName withUserpassword:(NSString*)strUserpassword withSecretString:(NSString *)secretString isOWN:(BOOL)isOWN;
Function Description
Log in to the device and authenticate (device sharing)
Declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
All devices need to perform V1 authentication after the P2P connection is successful, and then judge whether V2 authentication is required according to the result of V1 authentication
xxxxxxxxxx
///V1 authentication interface
-(void) sendAuth:(NSString*) in_strDID withUserName:(NSString*)strUserName withUserpassword:(NSString*)strUserpassword;
Parameter
Parameter | Instructions |
---|---|
in_strDID | device did |
strUserName | device account |
strUserpassword | device password |
secretString | Device authentication key Obtain the device list after logging in to the device, and obtain the value corresponding to the encrpt field as secretString. If encrpt is empty, use the value of the attr1 field as secretString |
isOWN | Whether it is the owner (share and reset the unbound device, there is a relationship between the owner and the guest, if it is the owner, pass YES, and NO is the guest) |
Return value(notification return code:RET_VALIDATION_PASSWORDV2)
Return value | Instructions |
---|---|
key | command number |
result | ok: authentication succeeded, failed: authentication failed |
DeviceShared | Whether to support sharing, 0: not supported, 1: supported |
auth | ok: authentication succeeded, failed: authentication failed |
authContactId | device did |
did | device did |
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendAuthV2:self.did withUserName:username withUserpassword:password withSecretString:key isOWN:YES];
xxxxxxxxxx
/**
@brief Close P2P connection
@param in_strDID device DID
*/
- (void)closeConnect:(NSString *)in_strDID;
Function Description
Close P2P connection
Declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Instructions |
---|---|
in_strDID | device DID |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] closeConnect:cont.contactId];
xxxxxxxxxx
/**
@brief Query the time when the device is offline
@param in_strDID Device DID
@return Returns the time interval (in seconds) from the current offline distance, using the current timestamp - return = offline timestamp
*/
- (int)getDeviceLastTimeWithDID:(NSString *)in_strDID;
Function Description
Returns the time the device was last online
Declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Instructions |
---|---|
in_strDID | Device DID |
Return value
Return value | Instructions |
---|---|
The number of seconds since the device was last online from the current timestamp | Use the current timestamp - return value = offline timestamp (-1: the device has never been online or was online 1 year ago, 0: means the device was just online) |
Simple sample code
xxxxxxxxxx
int ret = [EchoP2PClient.sharedP2PClient getDeviceLastTimeWithDID:DID];
xxxxxxxxxx
/**
@brief Query the online status of the device on the server
@param DIDString Device DID
@param onlineStatuCallback Device state callback
void(^)(int queryResult, NSString *DID)
@param queryResult device status >0 device online -6 device offline -3 query timeout
@param DID Device DID
*/
- (void)queryDeviceOnlineStatuWithDID:(NSString *)DIDString callback:(void(^)(int queryResult, NSString *DID))onlineStatuCallback;
Function description
Query the online status of the device on the server
Declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Query the online status of the device on the server
Generally, first query the online status of the device on the server
When the device is online, establish a P2P connection with the device
xxxxxxxxxx
-(void) getContactsState:(NSString *)DID;//Establish a P2P connection with the device
If the device is not online, get the offline time of the device
xxxxxxxxxx
- (int)getDeviceLastTimeWithDID:(NSString *)in_strDID;
Parameter
Parameter | Instructions |
---|---|
DIDString | Device DID |
onlineStatuCallback | Device state callback |
queryResult device status >0 device online -6 device offline -3 query timeout | |
DID Device DID |
Return value
Simple sample code
xxxxxxxxxx
[EchoP2PClient.sharedP2PClient queryDeviceOnlineStatuWithDID:array[0] callback:^(int queryResult, NSString *DID) {
}];
xxxxxxxxxx
//P2P connected devices
-(void)getContactsState:(NSString *)DID;
Function Description
Connect device
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
DID | Device did |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] getContactsState:did];
xxxxxxxxxx
//Get device information
- (void)sendDeviceInfo:(NSString*)in_strDID
Function Description
Get device information
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
in_strDID | Device did |
Return value
Return value | Instructions |
---|---|
ID | Device did (this field is commonly used) |
dwSrcID | Device did |
Key | command number |
model | Device model |
version | Device version number |
resultDic | dictionary |
resultDic key value | Instructions |
---|---|
channel | Total number of channels |
dev_type | Device type, such as: IPC, NVR, HVR, etc. |
limit | |
mac | mac address (this field is invalid and must be obtained through other interfaces) |
serial_no | serial number |
verdor | |
zwp2p_ver | zwp2p protocol version |
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendDeviceInfo:did];
xxxxxxxxxx
//V1 authentication
- (void)sendAuth:(NSString*)in_strDID withUserName:(NSString*)strUserName withUserpassword:(NSString*)strUserpassword
Function Description
The device performs V1 authentication
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
in_strDID | device did |
strUserName | device username |
strUserpassword | device password |
Return value(notification return code:RET_VALIDATION_PASSWORD)
Return value | Instructions |
---|---|
AutoBind | Whether to support reset unbinding, 0: not supported, 1: supported |
DeviceShared | Whether to support sharing, 0: not supported, 1: supported |
auth | ok: authentication succeeded, failed: authentication failed |
authContactId | device did |
did | device did |
is_pwd_correct | Whether the device password is correct, 0: wrong, 1: correct (only some devices support) |
key | command number |
result | ok: authentication succeeded, failed: authentication failed |
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendAuth:did withUserName:username withUserpassword:password];
xxxxxxxxxx
//Query the status of the master
static NSString *const kCheckDeviceHostUrlPath = @"safe/get-device-host-status";
Function Description
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
did | Device DID |
Return value
Return value | Instructions |
---|---|
code | return code 200 means success |
data | dictionary |
error | prompt information |
Return value | Instructions |
---|---|
status | 1-Currently has master information (the current database has master information but does not match the master Parameters; the peer database has no master information) 2-The peer has master information (the current database has no master information, but the peer database has this master information) 3- No owner information (the current database has no owner information, and the peer database has no owner information) 4- I am the owner (the current database has owner information and the account matches) |
did | device did |
xxxxxxxxxx
//return value example
{
code = 200;
data = {
did = "IOTBBB-685146-HNDLB";
status = 4;
};
error = "\U6210\U529f\Uff01";
}
Simple sample code
xxxxxxxxxx
[NetManager.sharedManager publicRequestWithActionPath:[NSString stringWithFormat:@"%@?did=%@",kCheckDeviceHostUrlPath,_did] Parameter:nil withMethod:@"GET" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
if (r.m_iCode == 200) {
NSDictionary *data = (NSDictionary *)r.m_strData;
int status = [data[@"status"] intValue];
if (status == 3) {
[weakSelf bindDevice:@""];
}else {
[SVProgressHUD showWithStatus:@"Device is bound"];
[SVProgressHUD dismissWithDelay:1];
}
}else {
[SVProgressHUD showErrorWithStatus:r.m_strError];
}
} failure:^(NSError *error) {
NSLog(@"error %@",error);
}];
xxxxxxxxxx
//add device
static NSString *const kAddDeviceUrlPath = @"safe/add-device";
Function Description
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
did | device did |
sn | Enterprise serial number |
alias | device alias |
Return value
Return value | Instructions |
---|---|
data | When the code is 200, return the added device table id |
code | return code 200 means success |
error | prompt information |
xxxxxxxxxx
//return value example
{
code = 200;
data = 2553182;
error = "\U6210\U529f\Uff01";
}
Simple sample code
xxxxxxxxxx
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{@"alias":@"test",@"did":_did,@"sn":NetManager.sharedManager.m_strCompnySn}];
[NetManager.sharedManager publicRequestWithActionPath:kAddDeviceUrlPath Parameter:dict withMethod:@"POST" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
if (r.m_iCode == 200) {
if ([scode isEqualToString:@""]) {
if (weakSelf.deviceType == 1) {
[weakSelf bindDevice1];
}else if (weakSelf.deviceType == 2) {
[weakSelf bindDevice2];
}
}else {
[weakSelf unbindDevice:scode];
}
}else {
[SVProgressHUD showErrorWithStatus:r.m_strError];
}
} failure:^(NSError *error) {
NSLog(@"error %@",error);
}];
xxxxxxxxxx
//Get Scode
@"GET /System/DeviceBindConfig"
Function Description
Get device Scode code
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
did | Device did |
Return value(notification return code:RET_HTTP_API)
Return value | Instructions |
---|---|
SCodeVaild | true: with Scode, false: without Scode |
SCode | When SCodeValid is true, you can get the Scode code |
__name | command name |
xxxxxxxxxx
//Returned resultDic data
{
DID = "IOTBBB-685146-HNDLB";
commandSeq = 9;
key = 902;
result = "HTTP/1.0 200 OK
\nServer: CGI/0.1.0
\nContent-Length:142
\nContent-Type:application/xml
\nConnection:close
\n
\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<DeviceBindConfig Version=\"1.0\">\n <SCodeValid>false</SCodeValid>\n <SCode />\n</DeviceBindConfig>\n";
}
//Returned resultDic data
NSString *dataStr = [[resultDic[@"result"] componentsSeparatedByString:@"\r\n\r\n"] lastObject];
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[NSDictionary dictionaryWithXMLString:dataStr]];
//dic
{
SCodeValid = false;
"_Version" = "1.0";
"__name" = DeviceBindConfig;
}
//logic processing
if ([dic[@"__name"] isEqualToString:@"DeviceBindConfig"]){
if (dic[@"SCodeValid"] isEqualToString:@"fasle") {
}
}
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendHTTP:did Method:@"GET /System/DeviceBindConfig" param:nil];
xxxxxxxxxx
// Upload Scode
@"PUT /System/DeviceBindConfig"
Function description
Upload device Scode code
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
SCode | Scode |
Return value(notification return code:RET_HTTP_API)
Return value | Instructions |
---|---|
__name | Unified return ResponseStatus of PUT command |
requestURL | requested URL |
statusCode | Status code, 0 The request is successful |
xxxxxxxxxx
//Returned resultDic data
{
DID = "NGLSPE-368863-SBXNE";
commandSeq = 14;
key = 902;
result = "HTTP/1.0 200 OK
\nServer: CGI/0.94.14rc21
\nContent-Type: application/xml
\nConnection: close
\nContent-Length: 174
\n
\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<ResponseStatus Version=\"1.0\">\n <requestURL>/System/DeviceBindConfig</requestURL>\n <statusCode>0</statusCode>\n</ResponseStatus>\n";
}
//resultDic data processing
NSString *dataStr = [[resultDic[@"result"] componentsSeparatedByString:@"\r\n\r\n"] lastObject];
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[NSDictionary dictionaryWithXMLString:dataStr]];
//dic
{
"_Version" = "1.0";
"__name" = ResponseStatus;
requestURL = "/System/DeviceBindConfig";
statusCode = 0;
}
//logic processing
if ([dic[@"__name"] isEqualToString:@"ResponseStatus"]){
if (dic[@"requestURL"] isEqualToString:@"/System/DeviceBindConfig") {
}
}
Simple sample code
xxxxxxxxxx
NSString *xmlStr=[NSString stringWithFormat:@"<DeviceBindConfig>\n <SCode>%@</SCode>\n</DeviceBindConfig>",scode];
[[EchoP2PClient sharedP2PClient] sendHTTP:weakSelf.did Method:@"PUT /System/DeviceBindConfig" param:xmlStr ];
xxxxxxxxxx
//Device reset unbind
static NSString *const kDeviceUnbindUrlPath = @"safe/device-unbind";
Function Description
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
did | Device did |
sCode | Device Scode |
Return value
xxxxxxxxxx
//return value example
{
code = 200;
data = "<null>";
error = "\U6210\U529f\Uff01";
}
Simple sample code
xxxxxxxxxx
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:@{@"sCode":scode,@"did":_did}];
[NetManager.sharedManager publicRequestWithActionPath:kDeviceUnbindUrlPath Parameter:dic withMethod:@"POST" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
if (r.m_iCode == 200) {
[weakSelf bindDevice2];
}
} failure:^(NSError *error) {
}];
xxxxxxxxxx
//become the master
static NSString *const kAddHostUrlPath = @"safe/device-to-host";
Function description
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
did | device did |
sn | Enterprise serial number |
Return value
Return value | Instructions |
---|---|
data | Device identity encryption information |
code | return code 200 means success |
error | prompt information |
xxxxxxxxxx
//return value example
{
code = 200;
data = "SMjOwVRLRHr/5Ct+yG/q655hpOoyShhszVNSL1ll7TaJl8LniWGMMJ/QyTatjNn0IqpqvXMAYQs=";;
error = "\U6210\U529f\Uff01";
}
Simple sample code
xxxxxxxxxx
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:@{@"sn":NetManager.sharedManager.m_strCompnySn,@"did":_did}];
[NetManager.sharedManager publicRequestWithActionPath:kAddHostUrlPath Parameter:dic withMethod:@"POST" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
if (r.m_iCode == 200) {
NSString *key = r.m_strData;
[weakSelf authV2:key];
}
} failure:^(NSError *error) {
}];
xxxxxxxxxx
//Device reset binding
static NSString *const kBindDeviceUrlPath = @"safe/device-bind";
Function Description
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
did | Device did |
sn | Enterprise serial number |
Return value
Return value | Instructions |
---|---|
code | return code 200 means success |
data | key value pair |
error | prompt information |
data key-value pair | Instructions |
---|---|
sCode | Unbind the scode used |
encrypt | Device authentication information |
id | device table id |
xxxxxxxxxx
//return value example
{
code = 200;
data = {
encrypt = "SMjOwVRLRHr/5Ct+yG/q655hpOoyShhszVNSL1ll7TaJl8LniWGMMJ/QyTatjNn0IqpqvXMAYQs=";
id = 2553182;
sCode = "164938234123568514602102-0400000";
};
error = "\U6210\U529f\Uff01";
}
Simple sample code
xxxxxxxxxx
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:@{@"sn":NetManager.sharedManager.m_strCompnySn,@"did":_did}];
[NetManager.sharedManager publicRequestWithActionPath:kBindDeviceUrlPath Parameter:dic withMethod:@"POST" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
NSLog(@"data======%@",r.m_strData);
if (r.m_iCode == 200) {
NSDictionary *data = (NSDictionary *)r.m_strData;
NSString *scode = data[@"sCode"];
NSString *xmlStr=[NSString stringWithFormat:@"<DeviceBindConfig>\n <SCode>%@</SCode>\n</DeviceBindConfig>",scode];
[[EchoP2PClient sharedP2PClient] sendHTTP:weakSelf.did Method:@"PUT /System/DeviceBindConfig" param:xmlStr ];
[EchoP2PClient sharedP2PClient].putDeviceBindConfigCallBack = ^(NSString *did, NSString *resultDict) {
NSString *key = data[@"encrypt"];
[weakSelf authV2:key];
};
}
} failure:^(NSError *error) {
}];
xxxxxxxxxx
//Device reset binding
- (void)sendAuthV2:(NSString*) in_strDID withUserName:(NSString*)strUserName withUserpassword:(NSString*)strUserpassword withSecretString:(NSString *)secretString isOWN:(BOOL)isOWN
Function description
V2 authentication
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
in_strDID | Device did |
strUserName | device username |
strUserpassword | device password |
secretString | Device authentication key |
isOWN | Is it the master |
Return value(notification return code:RET_VALIDATION_PASSWORDV2)
Return value | Instructions |
---|---|
key | command number |
result | ok: authentication succeeded, failed: authentication failed |
DeviceShared | Whether to support sharing, 0: not supported, 1: supported |
auth | ok: authentication succeeded, failed: authentication failed |
authContactId | device did |
did | device did |
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendAuthV2:self.did withUserName:username withUserpassword:password withSecretString:key isOWN:YES];
xxxxxxxxxx
//Get device list
static NSString *const kGetDeviceListUrlPath = @"safe/get-device-list";
Function description
Describe contextual relationships (depending on interfaces or working with those interfaces)
Parameter
Parameter | Instructions |
---|---|
sn | Enterprise serial number |
Return value (entries key-value pair)
Return | Instructions |
---|---|
data | Contains entries key-value pairs |
code | return code 200 means success |
error | prompt information |
entries key-value pair | Instructions |
---|---|
id | device table id |
dtype | Device type [1-ipc;2-nvr;3-dvr;4-panorama;5-alarm box;6-low power consumption] |
sn | Enterprise serial number |
account | user account |
did | device did |
pwd | device password |
alias | device alias |
username | username |
auth | |
attr1 | Device verification information |
attr2 | List of functions supported by device sharing |
attr3 | Device identity information (null is the old device; 0 is the master device; other numbers are guest devices) |
attr5 | multipurpose field |
createTime | |
host | Device owner account information |
shareNumber | Shared quantity |
encrpt | Device verification information |
passwordHint | Whether to prompt to change the password (false-no prompt; true-prompt) |
xxxxxxxxxx
//return value example
{
code = 200;
data = {
entries = (
{
account = "<null>";
alias = test;
attr1 = "SMjOwVRLRHr/5Ct+yG/q6yuImWMh2XIa";
attr2 = "<null>";
attr3 = 0;
attr5 = {
aiotuiedit = false;
cloudStoreAbility = 1;
deviceinfotype = "ewogICJ2ZXJkb3IiIDogInp3IiwKICAic2VyaWFsX25vIiA6ICJJMjA3RjE0MTM3MTExMkE2MUIyMkI1RSIsCiAgImNoYW5uZWwiIDogIjEiLAogICJtYWMiIDogIiIsCiAgImRldl90eXBlIiA6ICJJUENfUiIsCiAgIm1vZGVsIiA6ICJTODM0XC81NTIwUEhSLUFJIiwKICAibGltaXQiIDogIiIsCiAgInp3cDJwX3ZlciIgOiAiVjIuMi40LjgzMTUiLAogICJ2ZXJzaW9uIiA6ICIxLjEuOS0yMDIwMDkwOVoxUyIKfQ==";
mac = "7c:a7:b0:ff:23:64";
uuidpush = "IOTBBB-685146-HNDLB,PRUYFI#AYYTBU";
};
auth = "<null>";
createTime = "<null>";
did = "IOTBBB-685146-HNDLB";
dtype = 1;
encrypt = "SMjOwVRLRHr/5Ct+yG/q655hpOoyShhsHUO6hG+uqGs5PxDxDZ66NTUZh8h3j69EIqpqvXMAYQs=";
host = "<null>";
id = 2552044;
pwd = "";
shareNumber = 0;
sn = "<null>";
subStatus = "<null>";
username = "<null>";
}
);
};
error = "\U6210\U529f\Uff01";
}
Simple sample code
xxxxxxxxxx
[NetManager.sharedManager publicRequestWithActionPath:[NSString stringWithFormat:@"%@/%@",kGetDeviceListUrlPath,NetManager.sharedManager.m_strCompnySn] Parameter:nil withMethod:@"GET" callBack:^(id JSON) {
NSLog(@"json===%@",JSON);
P6SResult *r = (P6SResult *)JSON;
if (r.m_iCode == 200) {
NSDictionary *data = (NSDictionary *)r.m_strData;
NSLog(@"data===%@",data);
NSArray *entries = data[@"entries"];
if (entries.count != 0) {
NSDictionary *dict = entries[0];
if ([weakSelf isNullString:dict str:@"encrypt"]) {
[weakSelf authV2:dict[@"encrypt"]];
}else if ([weakSelf isNullString:dict str:@"attr1"]) {
[weakSelf authV2:dict[@"attr1"]];
}
}
}else {
[SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%d",r.m_iCode]];
[SVProgressHUD dismissWithDelay:1];
}
} failure:^(NSError *error) {
NSLog(@"error %@",error);
}];
xxxxxxxxxx
/**
@brief Set playback proxy
@param delegateCamera Proxy object
@param delegateCamera device
*/
-(void)setDelegateCamera:(NSString*)in_strDID withDelegateCamera:(id <DelegateCamera>) delegateCamera;
Function description
Set the playback agent to recall the decoded data to the upper layer
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Describe the context (dependent interfaces or interfaces used with))
The following proxy methods are usually used
xxxxxxxxxx
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid isPlayBack:(BOOL)isPlayBack codeRate:(int)codeRate
Parameter
Parameter | Explain |
---|---|
delegateCamera | The proxy object complies with the Delegatecamera agreement |
in_strDID | Device did |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setDelegateCamera:_did withDelegateCamera:self];
xxxxxxxxxx
/**
@brief Get the data of YUV after decoding
@param Pframeyuvdata decoded YUV data
@param width Width of video
@param height Video height
@param obj Not currently used
@param iChannel Device channel number
@param strDid Device did
*/
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid;
Function description
Video playback proxy method
Declaration class
xxxxxxxxxx
DelegateCamera.h
Describe the context (dependent interfaces or interfaces used with)
Parameter
Parameter | Explain |
---|---|
pFrameYUVData | Decoded YUV data |
width | Width of video |
height | Video height |
obj | Not currently used |
iChannel | Device channel number starts from 0 |
strDid | Device did number |
Return value
Simple sample code
xxxxxxxxxx
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid{
}
xxxxxxxxxx
- (void)copyYUV420pData:(void *)data width:(NSInteger)w height:(NSInteger)h;
Function description
Set the width and height of the playback video
Declaration class
xxxxxxxxxx
OpenGLView20.h
Describe the context (dependent interfaces or interfaces used with)
Parameter
Parameter | Explain |
---|---|
w | Width of video |
h | Video height |
data | Decoded YUV data (pFrameYUVData in the playback agent is passed here) |
Return value
Simple sample code
xxxxxxxxxx
[self.pbVideoView copyYUV420pData:pFrameYUVData width:width height:height];
[self.pbVideoView setVideoSize:width height:height];
[self.pbVideoView displayYUV420pData:nil width:width height:height];
xxxxxxxxxx
- (void)displayYUV420pData:(void *)data width:(NSInteger)w height:(NSInteger)h;
Function description
Display video data on the playback view
Declaration class
xxxxxxxxxx
OpenGLView20.h
Describe the context (dependent interfaces or interfaces used with)
Parameter
Parameter | Explain |
---|---|
data | Call the - (void) copyyuv420pdata: (void *) data width: (nsinteger) w height: (nsinteger) h method to copy the data, and then pass it here to nil |
w | Width of video |
h | Video height |
Return value
Simple sample code
xxxxxxxxxx
[self.pbVideoView copyYUV420pData:pFrameYUVData width:width height:height];
[self.pbVideoView setVideoSize:width height:height];
[self.pbVideoView displayYUV420pData:nil width:width height:height];
xxxxxxxxxx
/**
@brief End playback
@param in_strDID Device did
@param iChannel Device channel number
*/
- (int)sendCloseStream:(NSString*)in_strDID withChannel:(int)iChannel
Function description
End playback
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Describe the context (dependent interfaces or interfaces used with)
Parameter
Parameter | Explain |
---|---|
DID | DID DID of the device |
iChannel | Channel number, starting from 0 |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendCloseStream:did withChannel:channelNumber];
xxxxxxxxxx
/**
@brief Turn on/off the audio function, used in conjunction with setting the sound playback switch and audio decoding
@code
[[EchoP2PClient sharedP2PClient] sendCloseAudio:_did withChannel:_channelNumber];
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] sendOpenAudio:_did withChannel:_channelNumber];
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:YES];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:YES];
@endcode
*/
//turn on audio
-(void)sendOpenAudio:(NSString*)in_strDID withChannel:(int)iChannel
//turn off audio
-(void)sendCloseAudio:(NSString*)in_strDID withChannel:(int)iChannel
Function Description
Turn on/off the audio function
declaration class
xxxxxxxxxx
EchoP2PClient.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
iChannel | Channel number, starting from 0 |
Return value
Simple sample code
xxxxxxxxxx
//turn off audio
[[EchoP2PClient sharedP2PClient] sendCloseAudio:_did withChannel:_channelNumber];
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
//turn on audio
[[EchoP2PClient sharedP2PClient] sendOpenAudio:_did withChannel:_channelNumber];
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:YES];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:YES];
xxxxxxxxxx
/**
@brief Set the sound playback switch, generally turn on the sound first and then turn on the audio decoding
@param bIsValue YES Turn on the sound NO Turn off the sound
@code
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
@endcode
*/
-(void) setPlayAudioSwitch:(BOOL)bIsValue;
Function Function Explain
Set the sound playback switch, generally turn on the sound first and then turn on the audio decoding
declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
bIsValue | YES Turn on the sound NO Turn off the sound |
Return value
Simple sample code
xxxxxxxxxx
//turn off audio
[[EchoP2PClient sharedP2PClient] sendCloseAudio:_did withChannel:_channelNumber];
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
//turn on audio
[[EchoP2PClient sharedP2PClient] sendOpenAudio:_did withChannel:_channelNumber];
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:YES];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:YES];
xxxxxxxxxx
/**
@brief Whether to enable audio decoding
@param bIsValue YES Turn on the sound NO Turn off the sound
@discusstion Usually used with -(void) setPlayAudioSwitch:(BOOL)bIsValue
@code
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
@endcode
*/
-(void) setPlayStreamAudioSwitch:(BOOL)bIsValue;
Function Function Explain
Whether to enable audio decoding
declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
bIsValue | YES enable audio decoding NO disable audio decoding |
Return value
Simple sample code
xxxxxxxxxx
//turn off audio
[[EchoP2PClient sharedP2PClient] sendCloseAudio:_did withChannel:_channelNumber];
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
//turn on audio
[[EchoP2PClient sharedP2PClient] sendOpenAudio:_did withChannel:_channelNumber];
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:YES];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:YES];
xxxxxxxxxx
//acting
OpenGLViewDelegate
/**
@brief single channel device
@param image picture
*/
- (void)onScreenShotted:(UIImage*)image;
/**
@brief multi-channel device
@param image picture
@param iChannel channel number
*/
- (void)onScreenShotted:(UIImage *)image withChannel:(int)iChannel;
Function Function Explain
Whether to turn on audio decoding
declaration class
xxxxxxxxxx
OpenGLView20.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Return value
Simple sample code
xxxxxxxxxx
//Every time you take a screenshot, set the property isScreenShotting of the OpenGLView20 instance to YES
_gl_View.isScreenShotting = YES;
xxxxxxxxxx
//Turn on/off recording
-(void)recordSwitch:(BOOL)bIsRecod recordPath:(NSString *)path withDID:(NSString *)strDID withChannel:(int)iChannel;
Function Function Explain
Whether to turn on audio decoding
declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
bIsRecod | YES open recording NO close recording |
path | Video file storage path |
strDID | Device did |
iChannel | Device channel number, starting from 0 |
Return value
Simple sample code
xxxxxxxxxx
//turn off recording
[[EchoP2PClient sharedP2PClient] recordSwitch:NO recordPath:nil withDID:did withChannel:];
xxxxxxxxxx
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth|AVAudioSessionCategoryOptionAllowBluetoothA2DP|AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
Function Function Explain
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Return value
Simple sample code
xxxxxxxxxx
//direct copy use
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth|AVAudioSessionCategoryOptionAllowBluetoothA2DP|AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
xxxxxxxxxx
//Turn on the capture and capture audio function on the mobile phone
- (void)startRecordWithDID:(NSString*)strDid;
//Turn off the audio collection function on the mobile phone
-(void) stopRecord;
Function Function Explain
Turn on/off the audio collection function on the mobile phone
declaration class
xxxxxxxxxx
EchoAudioCOntrol.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
strDid | Device did |
Return value
Simple sample code
xxxxxxxxxx
//start intercom
[[EchoAudioControl sharedThread:NO] startRecordWithDID:_did];
[[EchoP2PClient sharedP2PClient] sendStartSpeak:_did channel:_channelNumber];
[[EchoP2PClient sharedP2PClient] sendControlSpeak:_did ISswitch:YES];
//close intercom
[[EchoAudioControl sharedThread:NO] stopRecord];
[[EchoP2PClient sharedP2PClient] sendControlSpeak:_did ISswitch:NO];
[[EchoP2PClient sharedP2PClient] sendStopSpeak:_did channel:_channelNumber];
xxxxxxxxxx
//start intercom
-(void)sendStartSpeak:(NSString *)in_strDID channel:(int)channel
Function Function Explain
start intercom
declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
channel | Device channel number, starting from 0 |
Return value
Simple sample code
xxxxxxxxxx
//start intercom
[[EchoAudioControl sharedThread:NO] startRecordWithDID:_did];
[[EchoP2PClient sharedP2PClient] sendStartSpeak:_did channel:_channelNumber];
[[EchoP2PClient sharedP2PClient] sendControlSpeak:_did ISswitch:YES];
//close intercom
[[EchoAudioControl sharedThread:NO] stopRecord];
[[EchoP2PClient sharedP2PClient] sendControlSpeak:_did ISswitch:NO];
[[EchoP2PClient sharedP2PClient] sendStopSpeak:_did channel:_channelNumber];
xxxxxxxxxx
//control intercom
-(void)sendControlSpeak:(NSString *)in_strDID ISswitch:(BOOL)isSwitch;
Function Function Explain
control intercom
declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
isSwitch | YES: Enabled NO: Disabled |
Return value
Simple sample code
xxxxxxxxxx
//start intercom
[[EchoAudioControl sharedThread:NO] startRecordWithDID:_did];
[[EchoP2PClient sharedP2PClient] sendStartSpeak:_did channel:_channelNumber];
[[EchoP2PClient sharedP2PClient] sendControlSpeak:_did ISswitch:YES];
//close intercom
[[EchoAudioControl sharedThread:NO] stopRecord];
[[EchoP2PClient sharedP2PClient] sendControlSpeak:_did ISswitch:NO];
[[EchoP2PClient sharedP2PClient] sendStopSpeak:_did channel:_channelNumber];
xxxxxxxxxx
//Get Video Quality
- (void)sendGetVideoQuality:(NSString*)in_strDID withChannel:(int)iChannel;
Function Function Explain
Get Video Quality
declaration class
xxxxxxxxxx
EchoP2PClient.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
iChannel | Device channel number, starting from 0 |
Return value(Notification return code:RET_GET_QUALITY)
Return value | Explain |
---|---|
result | prompt information |
data | Clarity data, need to be converted to ZWP2P_QUALITY structure for processing |
key | notification return code |
DID | Device did |
xxxxxxxxxx
//Return value example
{
"result" = ok,
"data" = {length = 552, bytes = 0x01000000 00000000 01000000 4e000000 ... 00000000 00000000 },
"key" = 204,
"DID" = IOTBBB-685146-HNDLB,
}
//data transfer structure
ZWP2P_QUALITY stQualityTmp;
memcpy(&stQualityTmp, [[Parameter valueForKey:@"data"] bytes], sizeof(stQualityTmp));
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendGetVideoQuality:did withChannel:channel];
xxxxxxxxxx
//set video quality
- (void)sendSetVideoQualityStruct:(NSString*)in_strDID withChannel:(int)iChannel withQuality:(ZWP2P_QUALITY)stDeviceQuality;
Function Function Explain
set video quality
declaration class
xxxxxxxxxx
EchoP2PClient.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
iChannel | Device channel number, starting from 0 |
stDeviceQuality | Clarity (uploaded as a structure) |
Return value
xxxxxxxxxx
//Return value example
{
"key" = 205,
"result" = ok,
"DID" = IOTBBB-685146-HNDLB,
}
Simple sample code
xxxxxxxxxx
ZWP2P_QUALITY stQualityI;
stQualityI.video_quality.quality = NVR_QUALITY_SD;
[[EchoP2PClient sharedP2PClient] sendSetVideoQualityStruct:did withChannel:channel withQuality:stQualityI];
The development of this function requires a certain understanding of device capabilities, PTZ capabilities, and some P2P commands, as well as a certain understanding of the meaning of the parameters returned by each interface.
xxxxxxxxxx
//Get PTZ capability
@"GET /System/PTZCap"
Function Function Explain
Get PTZ capability
declaration class
xxxxxxxxxx
EchoP2PClient.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
Return value
Return value | Explain |
---|---|
Focus | focus |
Support | true: focus is supported false: focus is not supported |
Return value | Explain |
---|---|
Track | track |
Support | true: Tracks are supported false: Tracks are not supported |
Count | Number of tracks |
Return value | Explain |
---|---|
AutoScan | auto scan |
Support | true: auto scan is supported false: auto scan is not supported |
Return value | Explain |
---|---|
Aperture | aperture |
Support | true: Aperture is supported false: Aperture is not supported |
Return value | Explain |
---|---|
Preset | Preset |
Support | true: support preset point false: not support preset point |
Count | The number of APP preset points (supporting setting point number 1-255, some devices 1-48) |
APPCount | Number of APP preset points (Advanced preset function only available when APPCount is 256) |
Return value | Explain |
---|---|
Zoom | Zoom |
Support | true: zooming is supported false: zooming is not supported |
AFTrack | Tracking zoom (Support, true: support tracking zoom false: not support tracking zoom) |
Return value | Explain |
---|---|
Guard | Watchman's position (watchman) |
Support | true: guard bit is supported false: guard bit is not supported |
Return value | Explain |
---|---|
AuxControl | Accessibility |
Support | true: Accessibility is supported false: Accessibility is not supported |
Menu | menu(Support, true: support menu false: not support menu) |
Light | Lighting (Support, true: supports lighting false: does not support lighting) |
Wipe | Wiper (Support, true: support wiper false: do not support wiper) |
Heat | Heater (Support, true: supports heater false: does not support heater) |
Fan | Fan (Support, true: support fan false: do not support fan) |
Power | Power switch (Support, true: support power switch false: do not support power switch) |
Return value | Explain |
---|---|
PanTile | direction |
Support | true: orientation is supported false: orientation is not supported |
UpDown | Up and down (Support, true: support up and down false: do not support up and down) |
LeftRight | Left and right (Support, true: support left and right false: do not support left and right) |
Extend | Upper left, lower left, upper right, lower right (eight directions) (Support, true: supports eight directions false: does not support eight directions) |
OneStep | Single-step control (Support, true: support single-step control false: do not support single-step control) |
Return value | Explain |
---|---|
Cruise | cruise |
Support | true: support watch cruise false: do not support watch cruise |
Count | Number of cruise lines |
xxxxxxxxxx
//Return value example
{
"Focus" = {
"Support" = true,
},
"Track" = {
"Support" = false,
"Count" = 10,
},
"AutoScan" = {
"Support" = false,
},
"Aperture" = {
"Support" = false,
},
"Preset" = {
"Support" = true,
"Count" = 6,
},
"Zoom" = {
"Support" = true,
"AFTrack" = {
"Support" = true,
},
},
"Support" = true,
"Guard" = {
"Support" = false,
},
"_ChannelID" = 0,
"__name" = Channel,
"AuxControl" = {
"Menu" = {
"Support" = false,
},
"Light" = {
"Support" = true,
},
"Wipe" = {
"Support" = false,
},
"Heat" = {
"Support" = false,
},
"Support" = true,
"Fan" = {
"Support" = false,
},
"Power" = {
"Support" = false,
},
},
"PanTile" = {
"Extend" = {
"Support" = false,
},
"UpDown" = {
"Support" = true,
},
"OneStep" = {
"Support" = true,
},
"LeftRight" = {
"Support" = true,
},
},
"Cruise" = {
"Support" = true,
"Count" = 16,
},
}
Simple sample code
xxxxxxxxxx
[EchoP2PClient.sharedP2PClient sendHTTP:cont.contactId Method:@"GET /System/PTZCap" param:nil];
xxxxxxxxxx
//Get device capabilities
@"GET /System/DeviceCap"
Function Function Explain
set video quality
declaration class
xxxxxxxxxx
EchoP2PClient.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
Return value(仅Explain对云台有效的字段)
Return value | Explain |
---|---|
PTZ_Advance_Cruise | Advanced cruise function |
PTZ_Advance_Watch | Advanced Overwatch Features |
ShakingHead | Whether it is a head-shaking machine (support, true: yes, false: no. The head-shaking machine removes the watch, cruise, optical zoom, and optical focus functions, and the preset point function adopts the scene memory mode) |
Motor | motor |
xxxxxxxxxx
//Return value example
{
"__name" = Device,
"FunctionList" = {
"AutoIP" = false,
"WiredAlarm" = false,
"SD" = true,
"FTP" = true,
"SubHistoryStreamSupport" = true,
"cloud_upgrade" = true,
"Snapshot" = false,
"TimeSnapshot" = true,
"ShakingHead" = true,
"P2PUpgrade" = true,
"Motor" = true,
"NoPtzAf" = false,
"CloudStorage" = {
"Support" = true,
},
"AudioAlarm" = true,
"ParamFixed" = true,
"AP" = true,
"WiredNetwork" = false,
"AudioAlarmAudioFormat" = {
"G711u" = true,
"AMR" = false,
},
"DisableIrLed" = true,
"VoiceCustom" = true,
"AppUI" = {
"AdvancedPeopleTrack" = true,
"StorageCapacity" = true,
"FlipSwitch" = true,
"EmailV2" = true,
},
"Email" = true,
"WIFI" = true,
"DeviceShareAndSelfUnbind" = true,
"Restore" = true,
"Wavelink" = false,
"DeviceShared" = true,
"PasswordModify" = true,
"TwoWayAudio" = true,
"SerialTransparent" = false,
"Smartlink" = false,
"RemoteReboot" = true,
},
"FunctionListAboutChannel" = {
"FunctionListSdCard" = {
"fast_playback" = true,
},
"ChannelList" = {
"Channel" = {
"Motion" = true,
"MotionSenstive" = {
"Middle" = true,
"Higher" = false,
"High" = true,
"Lowest" = false,
"Low" = true,
"Lower" = false,
"Highest" = false,
},
"multi_osd" = false,
"mosd_cord" = 16,
"LocalRecordFormat" = {
"PRV" = true,
"AVI" = false,
},
"IrCutMode" = {
"VariableWhite" = false,
"VariableInfrared" = false,
},
"PTZ_Advance_Watch" = false,
"SmartEvent" = {
"AiFace" = true,
"PeopleDetect" = true,
"PeopleTrack" = true,
"BehaviorAnalysis" = false,
"TalkingForward" = false,
"PIR" = false,
"Ai265Plus" = true,
"FaceSnap" = false,
"FaceBase" = false,
"FaceReco" = false,
},
"PTZ_Advance_Cruise" = false,
"mosd_cnt" = 16,
"RTMP" = false,
"IntelligentNight" = false,
"_ChannelID" = 0,
"ImageMode" = {
"_enable" = true,
"Normal" = true,
"LicensePlate" = true,
"FaceNoExposure" = true,
},
"Audio" = true,
"ColorNight" = false,
},
},
},
"AlarmOutCount" = 0,
"StreamCount" = 2,
"AlarmInCount" = 0,
}
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient]sendHTTP:cont.contactId Method:@"GET /System/DeviceCap" param:nil ];
xxxxxxxxxx
//PTZ controls the rotation of the PTZ of the device through action start or stop
-(void) sendNormalPTZ:(NSString*) in_strDID withSpeed:(int)nSpeed withLastTime:(int)nLastTime withChannel:(int)iChannel withDirection:(NSString *)direction withAction:(NSString *)action;
Function Function Explain
Set the camera to rotate up and down, left and right, zoom, focus
declaration class
xxxxxxxxxx
EchoP2PClient.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
nSpeed | Speed (support 0-9) |
nLastTime | Duration (this field is invalid, subject to action) |
iChannel | Channel number, starting from 0 |
direction | Adjustment type (zoomin: zoom out, zoomout: zoom in, focus_near: focus near, focus_far: focus far, up: turn up, left: turn left, down: turn down, right: turn right) |
action | PTZ controls the rotation of the PTZ of the device through action start or stop (after setting start to start rotation, stop must be set to stop rotation, and the two need to be used together) |
Return value
xxxxxxxxxx
//Return value example
{
DID = "IOTBEE-287139-CGKGT";
key = 301;
result = ok;
}
Simple sample code
xxxxxxxxxx
//start
[EchoP2PClient.sharedP2PClient sendNormalPTZ:did withSpeed:1 withLastTime:default_lasttime withChannel:channel withDirection:@"up" withAction:@"start"];
//stop
[EchoP2PClient.sharedP2PClient sendNormalPTZ:did withSpeed:1 withLastTime:default_lasttime withChannel:channel withDirection:@"up" withAction:@"stop"];
xxxxxxxxxx
//open watch
@"PUT /PTZ/1/Watch/StartWatch HTTP/1.1"
//close watch
@"PUT /PTZ/1/Watch/StopWatch HTTP/1.1"
Function Function Explain
Turn watch on/off
declaration class
xxxxxxxxxx
EchoP2PClient.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
param | @"Param1=1" (fixed writing method) |
Return value
xxxxxxxxxx
//Return value example
{
"__name" = ResponseStatus,
"_Version" = 1.0,
"statusCode" = 0,
"requestURL" = /PTZ/1/Watch/StartWatch,
}
Simple sample code
xxxxxxxxxx
//open watch
[[EchoP2PClient sharedP2PClient]sendHTTP:self.contact.contactId Method:@"PUT /PTZ/1/Watch/StartWatch HTTP/1.1" param:@"Param1=1"];
//close watch
[[EchoP2PClient sharedP2PClient]sendHTTP:self.contact.contactId Method:@"PUT /PTZ/1/Watch/StopWatch HTTP/1.1" param:@"Param1=1"];
xxxxxxxxxx
//set preset position
@"PUT /PTZ/ChannelID/Presets/Set"
//call preset
@"PUT /PTZ/ChannelID/Presets/Goto"
Function Function Explain
Set/recall preset position
declaration class
xxxxxxxxxx
EchoP2PClient.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
param | "Param1=%d" is the default number. The range of values is 0-127. |
ChannelID | Channel number, starting from 1 |
Return value
xxxxxxxxxx
//Return value example
{
"__name" = ResponseStatus,
"_Version" = 1.0,
"statusCode" = 0,
"requestURL" = /PTZ/1/Presets/Set,
}
Simple sample code
xxxxxxxxxx
// set up
NSString *postString = [NSString stringWithFormat:@"Param1=%d",(string.intValue-1)];
NSString *method= [NSString stringWithFormat:@"PUT /PTZ/%d/Presets/Set",mnFocusIndex + 1];
[[EchoP2PClient sharedP2PClient]sendHTTP:did Method:method param:postString];
// transfer
NSString *postString = [NSString stringWithFormat:@"Param1=%d",(string.intValue-1)];
NSString *method= [NSString stringWithFormat:@"PUT /PTZ/%d/Presets/Goto",mnFocusIndex + 1];
[[EchoP2PClient sharedP2PClient]sendHTTP:did Method:method param:postString];
xxxxxxxxxx
/**
Get monthly video information
@param in_strDID Device ID
@param strRecordType Video type (all: all types of video; time: regular timing video; motion: motion detection video; -Leonard: It's an alarm video.
@param strChannel Channels that require access to the video (all: all channels; If the videos of all channels are not obtained, the binary mode is used to indicate the videos of which channels are to be obtained. 1111000011110001 Each character indicates whether the current query is required,1 indicates yes, and 0 indicates no. Even 64 channel devices can support it. In this example,9 channels such as 1,2,3,4,9,10,11,12,16 need to be queried.)
@param iYear Year
@param iMonth month
*/
-(void) sendGetRecordinfoByMonth:(NSString*) in_strDID withRecordType:(NSString*)strRecordType withChannel:(NSString*)strChannel withYear:(int)iYear withMonth:(int)iMonth;
Function Description
Query the days of a month when the SD card/hard disk store video clips
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Specify the context (depending on or with which interfaces)
It's for the calendar. There's video footage of those days
Parameter
Parameter | instructions |
---|---|
in_strDID | Device did |
strRecordType | Video type (all: all types of video; time: regular timing video; motion: motion detection video; -Leonard: It's an alarm video. |
strChannel | Channels that require access to the video (all: all channels; If the videos of all channels are not obtained, the binary mode is used to indicate the videos of which channels are to be obtained. 1111000011110001 Each character indicates whether the current query is required,1 indicates yes, and 0 indicates no. Even 64 channel devices can support it. In this example,9 channels such as 1,2,3,4,9,10,11,12,16 need to be queried.) |
iYear | Year: @"2022", (20220401) query 2022 |
iMonth | Month: @"04", (20220401) queried video in April 2022 |
Return value
Return value | instructions |
---|---|
DID | Device did |
key | #define RET_GET_RECORD_INFO_BY_MONTH 400 // Get monthly video information |
query_result | 32位(00000000000001100000000000000000),0: there is no video recording. 1: indicates the day on which the video segment is available |
result | ok indicates that success is returned |
xxxxxxxxxx
Example return value
{
DID = "IOTBAA-249395-JGSMR";
key = 400;
"query_result" = 00000000000001100000000000000000;
result = ok;
}
Simple sample code
xxxxxxxxxx
///Query video clips of the current month
[[EchoP2PClient sharedP2PClient] sendGetRecordinfoByMonth:self.contact.contactId withRecordType:@"all" withChannel:@"1" withYear:(int)com.year withMonth:(int)com.month];
///Receive data
- (void)receiveRemoteMessage:(NSNotification *)notification
{
NSDictionary *Parameter = notification.userInfo;
int key = [Parameter[ZW_KEY] intValue];
//NSString *result = Parameter[ZW_RESULT];
wself(wself);
switch (key) {
case RET_GET_RECORD_INFO_BY_MONTH: {
//NSDictionary *dic = [UtilitySet httpApiDictionary:result];
self.videoString = Parameter[@"query_result"];
}
break;
default:break;
}
}
xxxxxxxxxx
/**
Obtain the video information of a certain day
@param in_strDID Device ID
@param strRecordType Video type (all: all types of video; time: regular timing video; motion: motion detection video; -Leonard: It's an alarm video.
@param strChannel Channels that require access to the video (all: all channels; If the videos of all channels are not obtained, the binary mode is used to indicate the videos of which channels are to be obtained. 1111000011110001 Each character indicates whether the current query is required,1 indicates yes, and 0 indicates no. Even 64 channel devices can support it. In this example,9 channels such as 1,2,3,4,9,10,11,12,16 need to be queried.)
@param iYear Year
@param iMonth month
@param iMonth Day
*/
-(void) sendGetRecordinfoByDay:(NSString*) in_strDID withRecordType:(NSString*)strRecordType withChannel:(NSString*)strChannel withYear:(int)iYear withMonth:(int)iMonth withDay:(int)iDay;
Function description
Query SD card/hard disk video clips of a specific date
Declaration class
xxxxxxxxxx
EchoP2PClient.h
State the context (depending on or with which interfaces)
Used as a calendar display that has video footage of the day
Parameter
Parameter | instructions |
---|---|
in_strDID | Device did |
strRecordType | Video type (all: all types of video; time: regular timing video; motion: motion detection video; -Leonard: It's an alarm video. |
strChannel | The channels to obtain the video are from (all: all channels; If the videos of all channels are not obtained, the binary mode is used to indicate the videos of which channels are to be obtained. 1111000011110001 Each character indicates whether the current query is required,1 indicates yes, and 0 indicates no. Even 64 channel devices can support it. In this example,9 channels such as 1,2,3,4,9,10,11,12,16 need to be queried.) |
iYear | Year: @"2022", (20220401) query 2022 |
iMonth | Month: @"04", (20220401) queried video in April 2022 |
iDay | Day: @"01", (20220401) query the day video on April 1, 2022 |
Return value
Return value | instructions |
---|---|
result | ok indicates that success is returned |
count | Total number of video clips per day |
record_list | An array of daily video fragments |
channel | The channel number of the video |
type | Daily video segments: normal: manual video recording, motion: motion detection video recording, ai: humanoid detection video recording, and time: scheduled video recording) |
start_time | Day start time of video segment |
end_time | End time of video segment |
xxxxxxxxxx
Example return value
{
"result" = ok,
"count" = 5,
"record_list" = (
{
"channel" = 0,
"type" = normal,
"start_time" = 20220415 00:00:00,
"end_time" = 20220415 03:37:21,
},
{
"channel" = 0,
"type" = motion,
"start_time" = 20220415 03:37:21,
"end_time" = 20220415 03:37:55,
},
{
"channel" = 0,
"type" = normal,
"start_time" = 20220415 03:37:55,
"end_time" = 20220415 06:00:00,
},
{
"channel" = 0,
"type" = motion,
"start_time" = 20220415 06:00:00,
"end_time" = 20220415 06:00:27,
},
{
"channel" = 0,
"type" = normal,
"start_time" = 20220415 06:00:27,
"end_time" = 20220415 07:58:01,
},
),
}
Simple sample code
xxxxxxxxxx
///Query the video footage of the day
[[EchoP2PClient sharedP2PClient] sendGetRecordinfoByDay:_did withRecordType:@"all" withChannel:@"1" withYear:(int)com.year withMonth:(int)com.month withDay:(int)com.day];
///Receive data
- (void)receiveRemoteMessage:(NSNotification *)notification
{
NSDictionary *Parameter = notification.userInfo;
int key = [Parameter[ZW_KEY] intValue];
//NSString *result = Parameter[ZW_RESULT];
wself(wself);
switch (key) {
case RET_GET_RECORD_INFO_BY_DAY: {
}
break;
default:break;
}
}
xxxxxxxxxx
/**
Start playing back
@param in_strDID Device ID
@param strRecordType Video type (all: all types of video; time: regular timing video; motion: motion detection video; -Leonard: It's an alarm video.
@param strChannel Channels that require access to the video (all: all channels; If the videos of all channels are not obtained, the binary mode is used to indicate the videos of which channels are to be obtained. 1111000011110001 Each character indicates whether the current query is required,1 indicates yes, and 0 indicates no. Even 64 channel devices can support it. In this example,9 channels such as 1,2,3,4,9,10,11,12,16 need to be queried) (for instruction sending)
@param strStartTime Playback start time
@param strEndTime Playback end time
@param iChannel Channel number to play back (used to select the decoder thread when opening the stream)
*/
-(void) sendPlayBackStart:(NSString*) in_strDID withRecordType:(NSString*)strRecordType withChannel:(NSString*)strChannel withStartTime:(NSString*)strStartTime withEndTime:(NSString*)strEndTime withChannel:(int)iChannel;
Function Description
From the specified time, play SD card/hard disk storage video
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
in_strDID | Device DID |
strRecordType | Video type (all: all types of video; time: regular timing video; motion: motion detection video; -Leonard: It's an alarm video. |
strChannel | Channels that require access to the video (all: all channels; If the videos of all channels are not obtained, the binary mode is used to indicate the videos of which channels are to be obtained. 1111000011110001 Each character indicates whether the current query is required,1 indicates yes, and 0 indicates no. Even 64 channel devices can support it. In this example,9 channels such as 1,2,3,4,9,10,11,12,16 need to be queried) (for instruction sending) |
strStartTime | Playback start time: @"20220415 00:00:00" |
strEndTime | Playback end Time: @"20220415 03:37:21" |
iChannel | Channel number to play back (used to select the decoder thread when opening the stream) |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendPlayBackStart:_did withRecordType:@"all" withChannel:@"1" withStartTime:@"20220415 00:00:00" withEndTime:@"20220415 03:37:21" withChannel:@"1"];
xxxxxxxxxx
/**
@brief sets the player-related proxy
@param in_strDID Device ID
@param delegateCamera proxy object
*/
-(void) setDelegateCamera:(NSString*) in_strDID withDelegateCamera:(id <DelegateCamera>) delegateCamera;
Function Description
Set the SD card/hard disk storage video playback agent, used to return the data after the mediation code to the upper layer
Declaration class
xxxxxxxxxx
DelegateCamera.h
Specify the context (depending on or with which interfaces)
The following proxy methods are typically used
xxxxxxxxxx
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid isPlayBack:(BOOL)isPlayBack codeRate:(int)codeRate
Parameter
Parameter | instructions |
---|---|
in_strDID | Device did |
delegateCamera | DelegateCamera (DelegATecamera) |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setDelegateCamera:did withDelegateCamera:self];
xxxxxxxxxx
/**
@brief gets the decoded YUV data
@param pFrameYUVData decoded YUV data
@param width Width of the video
@param height Height of the video
@param obj is not currently used
@param iChannel Indicates the device channel number
@param strDid Indicates the ID of the device
*/
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid;
Function Description
Video play agent method
Declaration class
xxxxxxxxxx
DelegateCamera.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
pFrameYUVData | Decoded YUV data |
width | Width of video |
height | Height of video |
obj | Not currently in use |
iChannel | The device channel number starts from 0 |
strDid | Device DID ID |
Return value
Simple sample code
xxxxxxxxxx
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid{
}
xxxxxxxxxx
/**
@brief gets the timestamp of the video being played
@param lDate is playing a timestamp of the video
@param iChannel Indicates the device channel number
@param strDid Indicates the ID of the device
*/
- (void) refreshFrameDate:(long)lDate withChannel:(int)iChannel withDid:(NSString*)strDid;
Function Description
The playback agent calls back the timestamp of the playing video to the upper layer
Declaration class
xxxxxxxxxx
DelegateCamera.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
lDate | The timestamp (in seconds) of the video being played |
iChannel | The device channel number starts from 0 |
strDid | Device DID ID |
Return value
Simple sample code
xxxxxxxxxx
- (void) refreshFrameDate:(long)lDate withChannel:(int)iChannel withDid:(NSString*)strDid
{
}
xxxxxxxxxx
- (void)copyYUV420pData:(void *)data width:(NSInteger)w height:(NSInteger)h;
Function Description
Copy YUV data to the playing view when the video is playing
Declaration class
xxxxxxxxxx
OpenGLView20.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
data | Decoded YUV video data |
w | Width of video |
h | Height of video |
Return value
Simple sample code
xxxxxxxxxx
[self.pbVideoView copyYUV420pData:pFrameYUVData width:width height:height];
[self.pbVideoView setVideoSize:width height:height];
[self.pbVideoView displayYUV420pData:nil width:width height:height];
xxxxxxxxxx
- (void)setVideoSize:(GLuint)width height:(GLuint)height;
Function Description
Set the width and height of the video
Declaration class
xxxxxxxxxx
OpenGLView20.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
width | Width of video |
height | Height of video |
Return value
Simple sample code
xxxxxxxxxx
[self.pbVideoView copyYUV420pData:pFrameYUVData width:width height:height];
[self.pbVideoView setVideoSize:width height:height];
[self.pbVideoView displayYUV420pData:nil width:width height:height];
xxxxxxxxxx
- (void)displayYUV420pData:(void *)data width:(NSInteger)w height:(NSInteger)h;
Function Description
Displays video data on the play view
Declaration class
xxxxxxxxxx
OpenGLView20.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
data | After we call - (void)copyYUV420pData:(void *)data width:(NSInteger)w height:(NSInteger)h to copy the data, we pass nil |
w | Width of video |
h | Height of video |
Return value
Simple sample code
xxxxxxxxxx
[self.pbVideoView copyYUV420pData:pFrameYUVData width:width height:height];
[self.pbVideoView setVideoSize:width height:height];
[self.pbVideoView displayYUV420pData:nil width:width height:height];
xxxxxxxxxx
/**
Turn off playback
@param in_strDID Device ID
*/
-(void) sendPlayBackClose:(NSString*) in_strDID;
Function Description
Ends playing the video stored on the SD card or hard disk
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
in_strDID | DID of the device |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendPlayBackClose:_did];
xxxxxxxxxx
/**
@brief sets the sound playing switch. Generally, the sound is enabled first and then the audio decoding is enabled
@param bIsValue YES Turn on sound NO Turn off sound
@code
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
@endcode
*/
-(void) setPlayAudioSwitch:(BOOL)bIsValue;
Function Description
Set the sound playing switch. Generally, the sound is turned on first and then the audio decoding is turned on
Declaration class
xxxxxxxxxx
DevicesManage.h
Specify the context (depending on or with which interfaces)
Set the sound playing switch. Generally, the sound is turned on first and then the audio decoding is turned on
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
Parameter
Parameter | instructions |
---|---|
bIsValue | YES Turn on the sound. NO Turn off the sound |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
xxxxxxxxxx
/**
@brief Whether to enable audio decoding
@param bIsValue YES Turn on sound NO Turn off sound
@discusstion is usually used with -(void) setPlayAudioSwitch:(BOOL)bIsValue
@code
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
@endcode
*/
-(void) setPlayStreamAudioSwitch:(BOOL)bIsValue;
Function Description
Whether to turn on audio decoding
Declaration class
xxxxxxxxxx
DevicesManage.h
Specify the context (depending on or with which interfaces)
is usually used with -(void) setPlayAudioSwitch:(BOOL)bIsValue
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
Parameter
Parameter | instructions |
---|---|
bIsValue | YES Enables audio decoding. NO Disables audio decoding |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
xxxxxxxxxx
/**
Positioning playback
@param in_strDID Device ID
@param strTime Playback start time
*/
-(void) sendPlaybackSetPosition:(NSString*) in_strDID withTime:(NSString*)strTime;
Function Description
When the SD card/hard disk is playing, drag the timeline to specify a time to play the video
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
strTime | The format of playback time is "yyyyMMdd HH:mm:ss". |
in_strDID | Device did |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] sendPlaybackSetPosition:did withTime:@"20220415 14:58:57"];
xxxxxxxxxx
/**
Setting the Playback Speed
@param in_strDID Device ID
@param strSpeed Playback speed (1/16; 1/8; A quarter; 1/2; 1 constant speed; 2 times speed; 4, 4 times the speed; 8 8 times the speed; 16 16 times speed)
*/
-(void) sendPlayBackSpeed:(NSString*) in_strDID withSpeed:(NSString*)strSpeed;
Function Description
The speed at which the SD card/hard disk stores the video is being played changes
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
in_strDID | Device did |
strSpeed | Playback speed (1/16; 1/8; A quarter; 1/2; 1 constant speed; 2 times the speed; 4, 4 times the speed; 8 8 times the speed; 16 16 times speed) |
Return value
Simple sample code
xxxxxxxxxx
[EchoP2PClient.sharedP2PClient sendPlayBackSpeed:self.contact.contactId withSpeed:@"8"];
xxxxxxxxxx
-(void)onScreenShotted:(UIImage*)image
Function Description
OpenGLView20 proxy method that sends the screenshots of OpenGLView20 back to the upper layer
Declaration class
xxxxxxxxxx
OpenGLView20.h
Specify the context (depending on or with which interfaces)
Set the proxy method of OpenGLView20 to play view first
Then setting the property isScreenShotting to YES will screen the image once and have the image returned to the top by the -(void) onscreenshotting method :(UIImage*)image
xxxxxxxxxx
self.glView = [[OpenGLView20 alloc] init];
self.glView.delegate = self;
self.glView.isScreenShotting = YES;
Parameter
Parameter | instructions |
---|---|
image | Screenshot of the picture |
Screenshot of the picture
Simple sample code
xxxxxxxxxx
self.glView = [[OpenGLView20 alloc] init];
self.glView.delegate = self;
self.glView.isScreenShotting = YES;
xxxxxxxxxx
/**
@brief starts and ends SD card/hard disk recording
@param bIsRecod YES Start recording NO end recording
@param path Path for saving the video
@param strDID DID of the device
@param iChannel Indicates the channel number of the device
*/
-(void) recordSwitch:(BOOL)bIsRecod recordPath:(NSString *)path withDID:(NSString *)strDID withChannel:(int)iChannel;
Function Description
Record the playing SD card/hard disk storage video
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
bIsRecod | YES Start recording. NO End recording. When recording is closed, path sends nil |
path | Path to save the video Absolute path file name NGLSPE-368863-SBXNE*MOV_20220407_144005_CH01_368863.prv, use the suffix.prv |
strDID | DID of the device |
iChannel | The channel number of the device starts from 0 |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedManager] recordSwitch:YES recordPath:filePath withDID:self.contact.contactId withChannel:[self.detailMutableArray[0] intValue]];
xxxxxxxxxx
/**
The video recording starts to download
@param in_strDID Device ID
@param filePath File path on the device
@param fileType File saving type
@param savePath File saving path
*/
-(void)sendVideoStartDownload:(NSString *)in_strDID filePath:(NSString *)filePath fileType:(NSString *)fileType savePath:(NSString *)savePath;
Function Description
Download video clips stored on SD card/hard disk. Only single video clips can be downloaded
Declaration class
xxxxxxxxxx
EchoP2PClient.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | instructions |
---|---|
in_strDID | did of the device |
filePath | Download file object, file path on the device |
fileType | File saving type |
savePath | File saving path |
Return value
Simple sample code
xxxxxxxxxx
NSString *fullFilePath=nil;
NSString *tmpString = @"";
if ([[dict[@"FileName"] uppercaseString] containsString:@"AVI"]) {
tmpString = @"AVI";
}else if([[dict[@"FileName"] uppercaseString] containsString:@"MP4"]){
tmpString = @"MP4";
}else{
tmpString = @"PRV";
}
fullFilePath=[self CreateP6SRecordFileWith:tmpString];
NSString *recordPath = [self.directoryPath stringByAppendingPathComponent:@"Record"];
[[NSFileManager defaultManager] createDirectoryAtPath:recordPath withIntermediateDirectories:YES attributes:nil error:nil];
fullFilePath = [[self.directoryPath stringByAppendingPathComponent:@"Record"] stringByAppendingPathComponent:fullFilePath];
[[EchoP2PClient sharedP2PClient] sendVideoStartDownload:did filePath:filePath fileType:@"video" savePath:fullFilePath];
xxxxxxxxxx
ObsManager.h
xxxxxxxxxx
Initialize the domestic cloud storage singleton object
+ (instancetype)sharedManager;
Function Function Explain
Initialize the domestic cloud storage singleton object
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Return value
Return value | Explain |
---|---|
ObsManager instantiation object | ObsManager singleton object |
Simple sample code
xxxxxxxxxx
[ObsManager sharedManager]
xxxxxxxxxx
/**
@brief Cloud storage login, you must log in before using cloud storage related functions
*/
- (void)OBS_Auth;
Function Function Explain
Cloud storage login interface
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Return value
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] OBS_Auth];
xxxxxxxxxx
/**
@brief Query the cloud storage video clips of the current month
@param month Need to query the month of video "2022-3"
@param deviceId Device ID of the device, obtained when cloud storage is activated
@param channel channel number
@param recordType Recording type ALL
@param streamType Code stream type stream=ALL all stream=0,1 multiple
@param utc Time zone NSString *timeZoneStr=[[NSTimeZone systemTimeZone] name];
@param success Callback for getting data
@param failure Callback for request failure
*/
- (void)OBS_GetRecordByMonth:(NSString *)month
deviceId:(NSString *)deviceId
channel:(NSInteger)channel
recordType:(NSString *)recordType
streamType:(NSInteger)streamType
utc:(NSString *)utc
success:(void (^)(id response))success
failure:(void (^)(NSError *error))failure;
Function Function Explain
Query which days of a certain month there are video clips stored in the cloud
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Used as a display on the calendar, there are video clips in those days
Parameter
Parameter | Explain |
---|---|
month | Need to query the month of video "2022-3" |
deviceId | Device ID of the device, obtained when cloud storage is activated |
channel | channel number |
recordType | Recording type ALL |
streamType | Code stream type stream=ALL all stream=0,1 multiple |
utc | Time zone NSString *timeZoneStr=[[NSTimeZone systemTimeZone] name]; |
success | Callback for getting data |
failure | Callback for request failure |
Return value
Return value | Explain |
---|---|
code | return code 200 means success |
data | return data dictionary structure |
cloudId: cloud disk Id | |
storeType: type routine: cloud storage disk: cloud disk | |
time: Indicates which day there is a video clip date such as "2022-04-06" | |
type: recording type (manual recording 01; planned recording 02; alarm input recording 03; motion detection recording 04; PIR recording 05; human shape detection recording 06; face detection recording 07; face recognition 08;) | |
message | prompt information |
properties | reserve |
token | token |
xxxxxxxxxx
Return value example
{
code = 200;
data = {
entries = (
{
cloudId = (
);
storeType = routine;
time = "2022-04-06";
type = (
6
);
},
{
cloudId = (
);
storeType = routine;
time = "2022-04-07";
type = (
6
);
},
{
cloudId = (
);
storeType = routine;
time = "2022-04-04";
type = (
6
);
},
{
cloudId = (
);
storeType = routine;
time = "2022-04-05";
type = (
6
);
}
);
};
message = "success!";
properties = "<null>";
token = "153827-9vokzgENmp4SUs639Z_1649297314036";
}
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] OBS_GetRecordByMonth:monthStr deviceId:deviceID channel:1 recordType:@"" streamType:0 utc:timeZoneStr success:^(id response) {
} failure:^(NSError *error) {
}];
xxxxxxxxxx
/**
@brief Query the cloud storage video clips of a certain day
@param userId The user's ID is obtained after successful login
@param beginTime Starting time
@param endTime End Time
@param deviceId Device ID of the device, obtained when cloud storage is activated
@param channel channel number
@param recordType Recording type ALL
@param streamType Code stream type stream=ALL all stream=0,1 multiple
@param offsetTime (put into the beginTime of the last file) paging offset, // start from null by default
@param limit The number of pages, //int starts from offsetTime and then limits data
@param success Callback for getting data
@param failure Callback for request failure
*/
- (void)OBS_GetRecordByDayWithUserId:(long)userId beginTime:(NSString *)beginTime endTime:(NSString *)endTime deviceId:(NSString *)deviceId channel:(NSInteger)channel recordType:(NSString *)recordType streamType:(NSInteger)streamType offsetTime:(NSInteger)offsetTime limit:(NSInteger)limit success:(void (^)(id response))success failure:(void (^)(NSError *error))failure;
Function Function Explain
Query all video time segments of a certain day
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
userId | Obtained after the user's ID account is successfully logged in |
beginTime | Start time "2019-11-29 00:00:00" |
endTime | End time "2019-11-29 23:59:59" |
deviceId | Device ID of the device, obtained when cloud storage is activated |
channel | channel number |
recordType | Recording type ALL |
streamType | Code stream type stream=ALL all stream=0,1 multiple |
offsetTime | (put into the beginTime of the last file) paging offset, // start from null by default |
limit | The number of pages, //int starts from offsetTime and then limits data |
success | Callback for getting data |
failure | Callback for request failure |
Return value
Return value | Explain |
---|---|
code | return code 200 means success |
data | Return video clip data |
duration file duration | |
indexes file path | |
pos pos value | |
endtime file end time | |
i I frame time | |
fileUrl file path | |
beginTime file start time | |
time file start time | |
dueTime Expiration | |
type Type (Manual Recording 01; Planned Recording 02; Alarm Input Recording 03; Motion Detection Recording 04; PIR Recording 05; Human Shape Detection Recording 06; Face Detection Recording 07; Face Recognition 08;) | |
message | 提示信息prompt information |
xxxxxxxxxx
Return value example
{
"code" = 200,
"data" = {
"entries" = (
{
"stream" = 0,
"beginTime" = 1649286592000,
"size" = 2103468,
"duration" = 48000,
"fileUrl" = ZW/UNKNOWN/153827/b86364cfb50c4915805afb2e65d5668d/1/20220406/0/230952.prv,
"endtime" = 1649286640000,
"type" = 6,
},
{
"stream" = 0,
"beginTime" = 1649286961000,
"size" = 2135921,
"duration" = 54000,
"fileUrl" = ZW/UNKNOWN/153827/b86364cfb50c4915805afb2e65d5668d/1/20220406/0/231601.prv,
"endtime" = 1649287015000,
"type" = 6,
},
{
"stream" = 0,
"beginTime" = 1649294364000,
"size" = 2536538,
"duration" = 59933,
"fileUrl" = ZW/UNKNOWN/153827/b86364cfb50c4915805afb2e65d5668d/1/20220407/0/011924.prv,
"endtime" = 1649294423933,
"type" = 6,
},
),
},
"message" = 成功!,
"properties" = <null>,
"token" = 153827-pd1MZjVE6lk0d4ZgS2_1649300711608,
}
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] OBS_GetRecordByDayWithUserId:[[UDManager getLoginInfo].contactId integerValue] beginTime:[NSString stringWithFormat:@"%@ 00:00:00",self.detailMutableArray[1]] endTime:[NSString stringWithFormat:@"%@ 23:59:59",self.detailMutableArray[1]] deviceId:self.contact.deviceID channel: ([self.detailMutableArray[0] integerValue]+1) recordType:@"0" streamType:0 offsetTime:0 limit:0 success:^(id response){
}failure:^(NSError *error) {
}];
xxxxxxxxxx
/**
@brief Start playing cloud recording
@param DID Device did
@param iChannel device channel number
@param startTime Cloud recording start time
*/
- (void)OBS_StartPlayBackWithDID:(NSString *)DID WithChannel:(NSInteger)iChannel WithStartTime:(NSString *)startTime;
Function Function Explain
Play the cloud storage recording from the specified time
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
DID | Device did |
iChannel | Device channel number starts from 0 |
startTime | Cloud recording start time ''2022-04-07 10:55:11'' |
Return value
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] OBS_StartPlayBackWithDID:self.contact.contactId WithChannel:[self.detailMutableArray[0] integerValue] WithStartTime:[NSString stringWithFormat:@"%@ %@",self.detailMutableArray[1],self.detailMutableArray[2]]];
xxxxxxxxxx
/**
@brief Set cloud storage playback proxy
@param delegateCamera proxy object
*/
- (void)OBS_SetDelegate:(id <DelegateCamera>) delegateCamera;
Function Function Explain
Set the proxy for cloud storage video playback, which is used to call back the decoded data to the upper layer
declaration class
xxxxxxxxxx
DelegateCamera.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Typically the following proxy methods are used
xxxxxxxxxx
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid isPlayBack:(BOOL)isPlayBack codeRate:(int)codeRate
Parameter
Parameter | Explain |
---|---|
delegateCamera | Proxy object, complying with the DelegateCamera protocol |
Return value
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] OBS_SetDelegate:self];
xxxxxxxxxx
/**
@brief Get the decoded YUV data
@param pFrameYUVData decoded YUV data
@param width video width
@param height video high
@param obj currently unused
@param iChannel device channel number
@param strDid Device did number
*/
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid;
Function Function Explain
Video playback proxy method
declaration class
xxxxxxxxxx
DelegateCamera.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
pFrameYUVData | Decoded YUV data |
width | video width |
height | video high |
obj | currently unused |
iChannel | Device channel number starts from 0 |
strDid | Device did number |
Return value
Simple sample code
xxxxxxxxxx
- (void) refreshFrame:(uint8_t *)pFrameYUVData withVideoWidth:(NSInteger)width videoHeight:(NSInteger)height withObj:(NSObject *)obj withChannel:(int)iChannel withDid:(NSString*)strDid{
}
xxxxxxxxxx
/**
@brief Get the timestamp of the video being played
@param lDate Timestamp of the video being played
@param iChannel device channel number
@param strDid Device did number
*/
- (void) refreshFrameDate:(long)lDate withChannel:(int)iChannel withDid:(NSString*)strDid;
Function Function Explain
Play agent, call back the timestamp of the video being played to the upper layer
declaration class
xxxxxxxxxx
DelegateCamera.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
lDate | Timestamp of the video being played (in seconds) |
iChannel | Device channel number starts from 0 |
strDid | Device did number |
Return value
Simple sample code
xxxxxxxxxx
- (void) refreshFrameDate:(long)lDate withChannel:(int)iChannel withDid:(NSString*)strDid
{
}
xxxxxxxxxx
- (void)copyYUV420pData:(void *)data width:(NSInteger)w height:(NSInteger)h;
Function Function Explain
When the video is playing, copy the YUV data to the playback view
declaration class
xxxxxxxxxx
OpenGLView20.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
data | Decoded YUV video data |
w | video width |
h | video high |
Return value
Simple sample code
xxxxxxxxxx
[self.pbVideoView copyYUV420pData:pFrameYUVData width:width height:height];
[self.pbVideoView setVideoSize:width height:height];
[self.pbVideoView displayYUV420pData:nil width:width height:height];
xxxxxxxxxx
- (void)setVideoSize:(GLuint)width height:(GLuint)height;
Function Function Explain
Set the playback video width and height
declaration class
xxxxxxxxxx
OpenGLView20.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
width | video width |
height | video high |
Return value
Simple sample code
xxxxxxxxxx
[self.pbVideoView copyYUV420pData:pFrameYUVData width:width height:height];
[self.pbVideoView setVideoSize:width height:height];
[self.pbVideoView displayYUV420pData:nil width:width height:height];
xxxxxxxxxx
- (void)displayYUV420pData:(void *)data width:(NSInteger)w height:(NSInteger)h;
Function Function Explain
Display video data on playback view
declaration class
xxxxxxxxxx
OpenGLView20.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
data | After calling - (void)copyYUV420pData:(void *)data width:(NSInteger)w height:(NSInteger)h method to copy the data, pass nil here |
w | video width |
h | video high |
Return value
Simple sample code
xxxxxxxxxx
[self.pbVideoView copyYUV420pData:pFrameYUVData width:width height:height];
[self.pbVideoView setVideoSize:width height:height];
[self.pbVideoView displayYUV420pData:nil width:width height:height];
xxxxxxxxxx
/**
@brief End playback cloud recording
@param DID Device did
@param iChannel device channel number
*/
- (void)OBS_StopPlayBackWithDID:(NSString *)DID WithChannel:(NSInteger)iChannel;
Function Function Explain
End playback of cloud storage recordings
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
DID | device did |
iChannel | channel number, starting from 0 |
Return value
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] OBS_StopPlayBackWithDID:self.contact.contactId WithChannel:[self.detailMutableArray[0] integerValue]];
xxxxxxxxxx
/**
@brief Set the sound playback switch, generally turn on the sound first and then turn on the audio decoding
@param bIsValue YES Turn on the sound NO Turn off the sound
@code
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
@endcode
*/
-(void) setPlayAudioSwitch:(BOOL)bIsValue;
Function Function Explain
Set the sound playback switch, generally turn on the sound first and then turn on the audio decoding
declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Set the sound playback switch, generally turn on the sound first and then turn on the audio decoding
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
Parameter
Parameter | Explain |
---|---|
bIsValue | YES Turn on the sound NO Turn off the sound |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
xxxxxxxxxx
/**
@brief Whether to turn on audio decoding
@param bIsValue YES Turn on the sound NO Turn off the sound
@discusstion Usually used with -(void) setPlayAudioSwitch:(BOOL)bIsValue
@code
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
@endcode
*/
-(void) setPlayStreamAudioSwitch:(BOOL)bIsValue;
Function Function Explain
Whether to turn on audio decoding
declaration class
xxxxxxxxxx
DevicesManage.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Usually used with -(void) setPlayAudioSwitch:(BOOL)bIsValue
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
Parameter
Parameter | Explain |
---|---|
bIsValue | YES turn on audio decoding NO turn off audio decoding |
Return value
Simple sample code
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] setPlayAudioSwitch:NO];
[[EchoP2PClient sharedP2PClient] setPlayStreamAudioSwitch:NO];
xxxxxxxxxx
/**
@brief Cloud video playback location
@param seektime positioning time
@param success success
@param failure fail
*/
- (void)OBS_seekWithTime:(NSString *)seektime success:(void (^)(id response))success failure:(void (^)(NSError *error))failure;
Function Function Explain
When the cloud storage recording is playing, drag the time axis to specify a certain time to play the recording
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
seektime | Specify the playing time, start playing from this time Time format "yyyy-MM-dd HH:mm:ss" |
success | successful callback |
failure | failed callback |
Return value
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] OBS_seekWithTime:dateString success:^(id response) {
} failure:^(NSError *error) {
}];
xxxxxxxxxx
-(void)onScreenShotted:(UIImage*)image
Function Function Explain
The proxy method of OpenGLView20, which calls back the screenshot of OpenGLView20 to the upper layer
declaration class
xxxxxxxxxx
OpenGLView20.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
First set the proxy method of OpenGLView20 to play the view
Then set the property isScreenShotting to YES to take a screenshot, and call back the image to the upper layer through the -(void)onScreenShotted:(UIImage*)image method
xxxxxxxxxx
self.glView = [[OpenGLView20 alloc] init];
self.glView.delegate = self;
self.glView.isScreenShotting = YES;
Parameter
Parameter | Explain |
---|---|
image | screenshot image |
Return value
Simple sample code
xxxxxxxxxx
self.glView = [[OpenGLView20 alloc] init];
self.glView.delegate = self;
self.glView.isScreenShotting = YES;
xxxxxxxxxx
/**
@brief Start, end cloud storage recording
@param bIsRecod YES start recording NO end recording
@param path The path to save the recording
@param strDID device did
@param iChannel The channel number of the device
*/
-(void) recordSwitch:(BOOL)bIsRecod recordPath:(NSString *)path withDID:(NSString *)strDID withChannel:(int)iChannel;
Function Function Explain
Record a cloud storage recording that is playing
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
bIsRecod | YES start recording NO end recording When the recording is closed, path passes nil |
path | The absolute path of the path to save the video file name NGLSPE-368863-SBXNE*MOV_20220407_144005_CH01_368863.prv, use the suffix of .prv |
strDID | device did |
iChannel | The channel number of the device starts from 0 |
Return value
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] recordSwitch:YES recordPath:filePath withDID:self.contact.contactId withChannel:[self.detailMutableArray[0] intValue]];
xxxxxxxxxx
/**
@brief Download cloud storage recordings
@param DID device did
@param iChannel The channel number of the device
@param downloadFile Download file object
@param progressBlock Download progress callback
@param completionHandler error callback
*/
- (void)OBS_StartDownloadFileWithDID:(NSString *)DID WithChannel:(NSInteger)iChannel WithFilePath:(OBS_File *)downloadFile withProgressBlock:(void (^) (int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))progressBlock completionHandler:(void (^)(NSError * error))completionHandler;
Function Function Explain
Download video clips stored in the cloud, only a single video clip can be downloaded
declaration class
xxxxxxxxxx
ObsManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
DID | device did |
iChannel | The channel number of the device starts from 0 |
downloadFile | Download file object |
progressBlock | Download progress callback totalBytesWritten The current total download size totalBytesExpectedToWrite The total file size |
completionHandler | error callback |
Return value
Simple sample code
xxxxxxxxxx
[[ObsManager sharedManager] OBS_StartDownloadFileWithDID:wself.contact.contactId WithChannel:([wself.recordArray[0] integerValue]) WithFilePath:file withProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
} completionHandler:^(NSError * error) {
}];
Connect to the WiFi of the router. 5g WiFi of the router is not supported. Enter the WiFi password
Generate a QR code according to the rules and let the device recognize it. If the recognition is successful, you will hear a "Ding" sound from the device
QR code generation rules
Get the SSID, password, mobile IP address of the router, generate a random port number, generate a 5-digit random code, and time zone information
Generate the string s=ssid&p=pwd&t=timestring&k=key&a=ipaddress+ipport through the following rules
The name of SSID router needs to be Base64 encoded
The password of PWD router needs to be Base64 encoded
Timestring time zone, which is converted into minutes, with "+" in the East and "-" in the West
English random string with key length of 5
IPAddress hexadecimal mobile phone IP address eg. 192.168.250.199 to C7FAA8C0
Ipport hexadecimal mobile phone idle port Eg. 39531 to 6B9A
xxxxxxxxxx
/// Generate rule code
[NSString stringWithFormat:@"S=%@&P=%@&T=%@&K=%@&A=%@+%@", ssid.base64EncodedString, pwd.base64EncodedString, timestring, randomKey, IP, port];
/// Return result print string
S=QXBw&P=YXBwMTIzNDU2cXdlcg==&T=480&K=3dWfg&A=7901A8C0+F121
ipport needs to use the key:@ "port" of nsuserdefaults to facilitate the use of subsequent UDP ports
xxxxxxxxxx
int port=(int)(from + (arc4random() % (to - from + 1)));
[NSUserDefaults.standardUserDefaults setObject:@(port) forKey:@"port"];
App starts UDP monitoring, receives the status of devices after network distribution, and then adds devices
xxxxxxxxxx
/// Set proxy object
@property (nonatomic,weak)id <UDPDelegate> delegate;
/// Enable UDP unicast listening
-(void)initSocketWithPort:(int)port;
/// Turn off UDP unicast listening
-(void)stopUDPSocket;
/// Proxy callback method of udptool
- (void)UDPTool:(UDPTool *)updtool receiveData:(NSData *)receiveData;
Function description
Initialize UDP monitoring class
Declaration class
xxxxxxxxxx
UDPTool.h
Describe the context (dependent interfaces or interfaces used with)
Parameter
Parameter | Explain |
---|---|
port | Port number randomly used by QR code rules:[[NSUserDefaults.standardUserDefaults objectForKey:@"port"] intValue] |
m_delegateShake | Set proxy object |
Initialization code example
xxxxxxxxxx
/// Initialize UDP monitoring class and start UDP monitoring
_tool = [[UDPTool alloc] init];
_tool.delegate = self;
[_tool initSocketWithPort:[[NSUserDefaults.standardUserDefaults objectForKey:@"port"] intValue]];
Return value
Return value | Explain |
---|---|
receiveData | Intercept the following receivedata from the 0 bit of receivedata The length-1 bit is data to string. 。 Example after converting to string:[P2P]S=AChKO&DID=IOTBAA-123456-JGSMR |
Receiving method
xxxxxxxxxx
/// Receive return result function
- (void)UDPTool:(UDPTool *)updtool receiveData:(NSData *)receiveData {
if (receiveData) {
NSData *data=[receiveData subdataWithRange:NSMakeRange(0, receiveData.length-1)];
NSString *receiveString=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
[_tool stopUDPSocket];
}
}
Connect to the WiFi of the router. 5g WiFi of the router is not supported. Enter the WiFi password
Connect the device's WiFi to ZW_ At the beginning, the input device password is generally 01234567 by default
App starts UDP monitoring, receives the status of devices after network distribution, and then adds devices
xxxxxxxxxx
/**
@brief Initialize LAN detection singleton
@param isRelease destroy single instance NO create single instance
@return LAN detection single example
*/
+(ShakeThread *)sharedThread:(BOOL)isRelease;
/**
@param m_delegateShake Set proxy object
*/
@property(nonatomic, retain) id<DelegateShake> m_delegateShake;
/**
@brief End LAN detection
*/
-(void)kill;
/**
@brief Start LAN detection
*/
-(void)start;
/**
@brief Set network Parameters of LAN detection
@param strDestIP Target IP 255.255.255.255
@param data
SHAKE_DATA stShakeData;
stShakeData.dwVersion = 0x00;
stShakeData.wLen = 0x00;
stShakeData.byteMainCmd = 0x02;
stShakeData.byteAssistCmd = 0x5B;
NSData* temp_aSendData = [NSData dataWithBytes:&stShakeData length:sizeof(stShakeData)];
@param iDestPort Target port 5555
@param iReceivePort Receive port 5556
*/
-(void) setSendUdpData:(NSString*)strDestIP withData:(NSData*)data withDestPort:(int)iDestPort withReceivePort:(int)iReceivePort;
/// Receive return result function
- (void)receive:(NSData *)data{
}
Function description
Initialize UDP monitoring class
Declaration class
xxxxxxxxxx
ShakeThread.h
Describe the context (dependent interfaces or interfaces used with)
Parameter
Parameter | Explain |
---|---|
isRelease | YES destroy single instance NO create single instance |
m_delegateShake | Set proxy object |
strDestIP | Target IP 255.255.255.255 |
data | structural morphology, SHAKE_DATA stShakeData = { 0x00, 0x00, 0x02, 0x5B }; |
iDestPort | Target port 5555 |
iReceivePort | Receive port 5556 |
Initialization code example
xxxxxxxxxx
/// Initialize UDP monitoring class and start UDP monitoring
_shakeThread = [ShakeThread sharedThread:NO];
_shakeThread.m_delegateShake = self;
SHAKE_DATA stShakeData = {
0x00,
0x00,
0x02,
0x5B
};
_shakeThread.m_delegateShake = self;
[_shakeThread setSendUdpData:@"255.255.255.255" withData:[NSData dataWithBytes:&stShakeData length:sizeof(stShakeData)] withDestPort:5555 withReceivePort:5556];
[_shakeThread start];
Return value
Return value | Explain |
---|---|
data | The next 5 bits intercepted from 462 bits of data are sessionid The next 32 bits intercepted from 138 bits of data are adidandcheck The next 19 bits intercepted from 0 bits of adidandcheck are did |
Receiving method
xxxxxxxxxx
/// Receive return result function
- (void)receive:(NSData *)data{
NSData *sessionId = [data subdataWithRange:NSMakeRange(462, 5)];
NSString *sessionIdString = [[NSString alloc] initWithData:sessionId encoding:NSUTF8StringEncoding];
NSData *aDIDAndCheck = [data subdataWithRange:NSMakeRange(138, 32)];
NSData *aDID = [aDIDAndCheck subdataWithRange:NSMakeRange(0, 19)];
NSString *did = [[NSString alloc] initWithData:aDID encoding:NSUTF8StringEncoding];
[_shakeThread kill];
}
If the password starts with ZW_, the default password is 01234567
App enables UDP monitoring, receives the status of devices after network configuration, and then adds devices
xxxxxxxxxx
/**
@brief initializes the LAN probe singleton
@param isRelease YES Destroy singleton NO Create singleton
@return Indicates the single instance of LAN probe
*/
+(ShakeThread *)sharedThread:(BOOL)isRelease;
/**
@param m_delegateShake sets the proxy object
*/
@property(nonatomic, retain) id<DelegateShake> m_delegateShake;
/**
@brief ends the LAN probe
*/
-(void)kill;
/**
@brief starts the LAN probe
*/
-(void)start;
/**
@brief Sets the network Parameters for the LAN probe
@param strDestIP The target IP address is 255.255.255.255
@param data
SHAKE_DATA stShakeData;
stShakeData.dwVersion = 0x00;
stShakeData.wLen = 0x00;
stShakeData.byteMainCmd = 0x02;
stShakeData.byteAssistCmd = 0x5B;
NSData* temp_aSendData = [NSData dataWithBytes:&stShakeData length:sizeof(stShakeData)];
@param iDestPort Destination port 5555
@param iReceivePort Receiving port 5556
*/
-(void) setSendUdpData:(NSString*)strDestIP withData:(NSData*)data withDestPort:(int)iDestPort withReceivePort:(int)iReceivePort;
///Receive the return result function
- (void)receive:(NSData *)data{
}
Function Description
Initializes the UDP monitoring class
Declaration class
xxxxxxxxxx
ShakeThread.h
Specify the context (depending on or with which interfaces)
Parameter
Parameter | Explain |
---|---|
isRelease | YES destroys singletons. NO Creates singletons |
m_delegateShake | Setting proxy Objects |
strDestIP | The targetIP 255.255.255.255 |
data | Body of structure, SHAKE_DATA stShakeData = { 0x00, 0x00, 0x02, 0x5B }; |
iDestPort | Destination port 5555 |
iReceivePort | Receiving port 5556 |
Initialize the code sample
xxxxxxxxxx
/// Initialize the UDP monitoring class to start UDP monitoring
_shakeThread = [ShakeThread sharedThread:NO];
_shakeThread.m_delegateShake = self;
SHAKE_DATA stShakeData = {
0x00,
0x00,
0x02,
0x5B
};
_shakeThread.m_delegateShake = self;
[_shakeThread setSendUdpData:@"255.255.255.255" withData:[NSData dataWithBytes:&stShakeData length:sizeof(stShakeData)] withDestPort:5555 withReceivePort:5556];
[_shakeThread start];
Return value
Return value | instructions |
---|---|
data | Intercepting the last 5 bits from the 462 bit of data is sessionId Intercepting the last 32 bits from the 138 bit of data is aDIDAndCheck Intercepting the last 19 bits from the 0 bit of aDIDAndCheck is did |
Method of receiving
xxxxxxxxxx
/// Receive the return result function
- (void)receive:(NSData *)data{
NSData *sessionId = [data subdataWithRange:NSMakeRange(462, 5)];
NSString *sessionIdString = [[NSString alloc] initWithData:sessionId encoding:NSUTF8StringEncoding];
NSData *aDIDAndCheck = [data subdataWithRange:NSMakeRange(138, 32)];
NSData *aDID = [aDIDAndCheck subdataWithRange:NSMakeRange(0, 19)];
NSString *did = [[NSString alloc] initWithData:aDID encoding:NSUTF8StringEncoding];
[_shakeThread kill];
}
xxxxxxxxxx
Acquire equipment capability
/**
* @param in_strDID Device ID
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description Function Description
Acquire equipment capability
Declare class Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | Device ID |
Method | Method Name |
3.Return value
The return value xml is the following document
Equipment Capability Definition Document
xxxxxxxxxx
4.Simple sample code
//Acquire equipment capability
[EchoP2PClient.sharedP2PClient sendHTTP:_did Method:@"GET /System/DeviceCap" param:nil];
xxxxxxxxxx
// Obtain the image
/ * *
* @param in_strDID Device ID
* @param channel The channel is 0
* @return
* /
-(void)sendGetMirrorMode:(NSString*) in_strDID withChannel:(int)channel;
1.Function Description
Get Video Flip Settings
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
channel | Channel Number |
3.Return value
Return value | Explain |
---|---|
"disable" | No mirror settings |
"left-right" | Left and right mirror image |
"up-down" | Up and down mirror image |
"center" | Central Mirror image |
xxxxxxxxxx
4.Example of channel number return value code
-(void)getModel:(NSNotification *)info{
NSDictionary *Parameter = [info userInfo];
int key = [[Parameter valueForKey:@"key"] intValue];
NSString *result = [Parameter valueForKey:@"result"];
//获取model
if (key == RET_GET_MIRROR_MODE) {
if ([Parameter objectForKey:@"mode"]) {
//字典包含有model
NSString *model = [Parameter objectForKey:@"mode"];
if ([model isEqualToString:@"disable"]) {
}else if ([model isEqualToString:@"left-right"]){
}else if ([model isEqualToString:@"up-down"]){
}else if ([model isEqualToString:@"center"]){
}
}
}
xxxxxxxxxx
5.Simple sample code
[[EchoP2PClient sharedP2PClient] sendGetMirrorMode:self.contact.contactId withChannel:0];
xxxxxxxxxx
Mirror image Settings
/**
* @param in_strDID Device ID
* @param channel Pass 0
* @param mode disable(no Mirror image Settings) up-down(Up and down mirror image) left-right(Left and right mirror image) center(Central Mirror image)
* @return
*/
-(void)sendSetMirrorMode:(NSString*) in_strDID withChannel:(int)channel withMode:(NSString*)mode;
1.Function Description
Mirror image Settings
Declare class :
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | device did |
channel | Channel Number |
mode | Mirror image mode |
3.Return value
Return value | Explain |
---|---|
result | Ok means success, others are failures |
xxxxxxxxxx
4.Example of channel number return value code
-(void)getModel:(NSNotification *)info{
NSDictionary *Parameter = [info userInfo];
int key = [[Parameter valueForKey:@"key"] intValue];
NSString *result = [Parameter valueForKey:@"result"];
if (key == RET_SET_MIRROR_MODE){
//发送model
dispatch_async(dispatch_get_main_queue(), ^{
if([result isEqualToString:@"ok"]){
[[iToast makeText: LocalizedString(@"modify_suc", @"")]show];
}else{
[[iToast makeText: LocalizedString(@"modify_fail", @"")]show];
}
});
}
xxxxxxxxxx
5.Simple sample code
[[EchoP2PClient sharedP2PClient] sendSetMirrorMode:self.contact.contactId withChannel:0 withMode:model];
xxxxxxxxxx
/*
* @param in_strDID Device ID
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description
GET /System/Time Get device time
GET /System/NTP Get system NTP configuration
GET /System/DST Get Daylight Saving Time
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | device did |
Method | method name |
param | send nil |
3.Return value
Return value | Explain |
---|---|
@"__name" | Return "NTP" or "Time" or "DST" |
xxxxxxxxxx
4.Example of channel number return value code
GET /System/Time xml
<?xml version="1.0" encoding="utf-8"?> <Time> <DateTimeFormat> <!--req,string,YYYYMMDDWhhmmss,YYYYMMDDhhmmss,MMDDYYYYWhhmmss,MMD DYYYYhhmmss,DDMMYYYYWhhmmss,DDMMYYYYhhmmss--> </DateTimeFormat> <TimeFormat><!--req,xs:string,12hour,24hour--></TimeFormat> <SystemTime><!--req,xs:datetime,” 20040503T173008+08”--></SystemTime> </Time>
GET /System/NTP xml
<?xml version="1.0" encoding="utf-8"?> <NTP> <Enable><!—req,xs:boolean--></Enable> <ServerName><!—req,xs:string,”example: time.windows.com”--></ServerName> <TimeZone><!--req, xs:string, POSIX time zone string,”CST-09:00:00”--></TimeZone> <TimeSyncInterval><!—req,xs:integer--></TimeSyncInterval> </NTP>
GET /System/DST xml
当<Mode>为“date”时,<DateModeStart>和<DateModeStop>有效,当<Mode>为“week”
时,<WeekModeStart>和<WeekModeStop>有效 <TimeDifference>单位为秒,例如:3600 为 3600 秒 <DateModeStart>和<DateModeStop>:接受并返回 ISO 8601 日期/时间字符串。 <WeekModeStart>和<WeekModeStop>:“3-1-1-2-3-6”的第一个数字是 3 月,第二个是 第一个星期的第一个星期,第三个是第一个星期一,第四个星期一 是 2 小时,第五是 3 分 钟,第六是 6 秒
<?xml version="1.0" encoding="UTF-8" ?> <DST Version="1.0" xmlns="http://www.zwcloud.wang/ver10/XMLSchema"> <Enable><!—req,xs:boolean--></Enable> <Mode><!—req,xs:string,”date,week”--></Mode> <TimeDifference>req,xs:string, </TimeDifference> <DateModeStart><!--req,xs:datetime,” 20040503T173008+08”--></DateModeStart> <DateModeStop><!--req,xs:datetime,” 20040503T173008+08”--></DateModeStop> <WeekModeStart><!--req,xs:string,” 3-1-1-2-3-6”--></WeekModeStart> <WeekModeStop><!--req,xs:string,” 2-4-5-7-8-8”--></WeekModeStop> </DST>
xxxxxxxxxx
5.Simple sample code
//Get device time
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"GET /System/Time" param:nil];
// Get system NTP configuration
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"GET /System/NTP" param:nil];
// Get Daylight Saving Time
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"GET /System/DST" param:nil];
xxxxxxxxxx
/*
* @param in_strDID Device ID
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description
Edit Equipment Time
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | device did |
Method | method name |
3.Return value :
Return value | Explain |
---|---|
ResponseStatus | Response status code |
xxxxxxxxxx
4.Example of channel number return value code
-(void)getData:(NSNotification *)info{
NSDictionary *Parameter = [info userInfo];
int key = [[Parameter valueForKey:@"key"] intValue];
NSString *result = [Parameter valueForKey:@"result"];
if ( key == RET_HTTP_API){//902
//字符串的截取
NSRange range = [result rangeOfString:@"<?"];
if (range.length > 0) {
NSString *xml = [result substringFromIndex:range.location];
//解析XML
NSDictionary *dic = [NSDictionary dictionaryWithXMLString:xml ];
// put请求返回数据
if ([dic[@"__name"] isEqualToString:@"ResponseStatus"]) {
if ([dic[@"requestURL"] isEqualToString:@"/System/NTP"] ||
[dic[@"requestURL"]isEqualToString:@"/System/Time"] ||
[dic[@"requestURL"]isEqualToString:@"/System/DST"]) {
dispatch_async(dispatch_get_main_queue(), ^{
if([dic[@"statusCode"] isEqualToString:@"0"]){
[[iToast makeText:LocalizedString(@"modify_success", @"")]show];
}else{
[[iToast makeText:LocalizedString(@"modify_error", @"")]show];
}
});
}else{
}
}
xxxxxxxxxx
5.Simple sample code
//Edit Equipment Time
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"PUT /System/DST" param:string];
// Modify NTP
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"PUT /System/NTP" param:param];
// Modify Daylight Saving Time
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"PUT /System/Time" param:postTimeString];
xxxxxxxxxx
/*
* @param in_strDID device did
* @return
*/
//Get basic device information
-(void) sendDeviceInfo:(NSString*) in_strDID;
1.Function Description
Get basic device information
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | device did |
3.Return value:
xxxxxxxxxx
4.Example of channel number return value code
//获得数据
-(void)getData:(NSNotification *)info{
NSDictionary *Parameter = [info userInfo];
int key = [[Parameter valueForKey:@"key"] intValue];
NSDictionary *resultDic = [Parameter valueForKey:@"resultDic"];
if (key == RET_GET_DEVICEINFO){
//获取设备信息
if ([Parameter[@"dwSrcID"]isEqualToString:self.contact.contactId]) {
dispatch_async(dispatch_get_main_queue(), ^{
});
}
}
xxxxxxxxxx
5.Simple sample code
[[EchoP2PClient sharedP2PClient] sendDeviceInfo:self.contact.contactId];
xxxxxxxxxx
/*
* @param in_strDID device did
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description
Mobile Detection Configuration
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
Method | Method Name |
channelID | Channel Number |
3.Response data
GET /Pictures/channel ID/Motion Response Parameter | Explain |
---|---|
ResponseStatus or Motion | Get all mobile detection related configurations |
PUT /Pictures/channel ID/Motion Response Parameter | Explain |
---|---|
ResponseStatus | Response after configuration modification |
xxxxxxxxxx
4.Example of channel number return value code
- (void)receiveRemoteMessage:(NSNotification *)notification {
NSDictionary *Parameter = notification.userInfo;
int key = [Parameter[ZW_KEY] intValue];
NSString *result = Parameter[ZW_RESULT];
NSString *did = Parameter[ZW_DID];
if (![did isEqualToString:_did]) return;
switch (key) {
case RET_HTTP_API: {
//902
NSString *xml = [result componentsSeparatedByString:@"\r\n\r\n"].lastObject;
NSDictionary *dic = [UtilitySet httpApiDictionary:result];
if ([dic[@"__name"] isEqualToString:@"Motion"]) {
self.motionDetectXml = xml;
self.motionDetectModel = [ZoneArmingModel yy_modelWithJSON:dic];
NSLog(@"老 移动侦测 Motion = > %@", dic);
dispatch_main_async_safe(^{
[self configUIData];
});
}
Motion xml
<?xml version="1.0" encoding="utf-8"?> <Motion> <Enable><!--req,xs:boolean--></Enable> <Senstive><!--req,xs:string,”lowest,lower,low,middle,high,higher,highest”,--></Senstive> <Trigger><!--opt--> <Schedule><!--opt--> <MotionRegionList><!--opt--> </Motion>
xxxxxxxxxx
5.Simple sample code
// Get the configuration related to mobile detection
[EchoP2PClient.sharedP2PClient sendHTTP:_did Method:[NSString stringWithFormat:@"GET /Pictures/channel ID/Motion"] param:nil];
//Modify the configuration related to mobile detection
[EchoP2PClient.sharedP2PClient sendHTTP:_did Method:[NSString stringWithFormat:@"PUT /Pictures/channel ID/Motion"] param:nil];
xxxxxxxxxx
/*
* @param in_strDID Device did
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description
OSD Settions
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
Method | Method Name |
channelID | Channel Number |
3.Response data
GET /Pictures/channelID/OSD Response Parameter | Explain |
---|---|
ResponseStatus or OSD | Get all OSD related configurations |
PUT /Pictures/channelID/OSD Response Parameter | Explain |
---|---|
ResponseStatus | Response after configuration modification |
xxxxxxxxxx
4.Example of channel number return value code
- (void)receiveRemoteMessage:(NSNotification *)notification{
NSDictionary *Parameter = notification.userInfo;
int key = [Parameter[@"key"] intValue];
NSString *result = Parameter[@"result"];
NSString *did = Parameter[@"DID"];
if (![did isEqualToString:**self**.contact.contactId]) { return; }
if (key == RET_HTTP_API) {
//902
NSString *xml = [result componentsSeparatedByString:@"\r\n\r\n"].lastObject;
NSDictionary *dic = [UtilitySet httpApiDictionary:result];
NSLog(@"%@", dic);
if ([dic[@"__name"]isEqualToString:@"OSD"]) {
[self hiddenDismissHud];
self.oSDxml = xml;
self.oSDModel = [OSDModel yy_modelWithJSON:dic];
dispatch_main_async_safe(^{
[self refreshUI];
});
}
OSD xml
<?xml version="1.0" encoding="utf-8"?> <OSD><DisplayTime><!--req--> <Enable><!--req,xs:boolean--></Enable> <PosX><!--req,xs:integer,0-703--></PosX> <PosY><!--req,xs:integer,0-575--></PosY></DisplayTime> <DisplayName><!--req--> <Enable><!--req,xs:boolean--></Enable> <PosX><!--req,xs:integer,0-703--></PosX> <PosY><!--req,xs:integer,0-575--></PosY> <Name><!--req,xs:string,”in Unicode”--></Name> </DisplayName> </OSD>
xxxxxxxxxx
5.Simple sample code
//Get OSD settings
[EchoP2PClient.sharedP2PClient sendHTTP:self.contact.contactId Method:[NSString stringWithFormat:@"GET /Pictures/channelID/OSD"] param:nil];
//Modify OSD settings
[EchoP2PClient.sharedP2PClient sendHTTP:self.contact.contactId Method:[NSString stringWithFormat:@"PUT /Pictures/channelID/OSD"] param:nil]
xxxxxxxxxx
/*
* @param in_strDID Device did
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description
Memory card Settings
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
Method | Method Name |
3.Return value
GET /Disk Response Parameter | Explain |
---|---|
ResponseStatus or DiskList | Get all Disk related configurations |
PUT /Disk Response Parameter | Explain |
---|---|
ResponseStatus | Response after configuration modification |
xxxxxxxxxx
4.Return value data
Disk xml
<?xml version="1.0" encoding="utf-8"?>
<DiskList>
<Disk>
<DiskID><!—ro,req,xs:integer,”0,1,2….”--></DiskID>
<TotalCapacity><!—ro,req,xs:integer,the unit is MB--></TotalCapacity>
<AvailableCapacity><!—ro,req,xs:integer,the unit is MB--></AvailableCapacity>
<DiskStorageType><!—ro,req,xs:string,”SD,samba”--></DiskStorageType>
<DiskStorageAttribute><!—ro,req,xs:string,”idle,writting,reading,diskexception,diskerror,re
adonly,readwrite,nodisk,exceptionneedformat,exceptionneedChangeDisk,formatfailedneed
reboot” --></DiskStorageAttribute>
<PictureCapacityPercent><!—rw,req,xs:integer--></PictureCapacityPercent>
<RecordCapacityPercent><!—rw,req,xs:integer--></RecordCapacityPercent>
<DiskFormatStatus><!—ro,req,xs:string,”unformatted,formatting,formatted,format
failure,umount failure,device is busy”--></DiskFormatStatus>
</Disk>
</DiskList>
xxxxxxxxxx
5.Simple sample code
// Get memory card settings
[[EchoP2PClient sharedP2PClient]sendHTTP:self.contact.contactId Method:@"GET /Disk" param:nil];
//Modify memory card information
[[EchoP2PClient sharedP2PClient]sendHTTP:self.contact.contactId Method:@"PUT /Disk" param:nil];
xxxxxxxxxx
/*
* @param in_strDID Device did
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description
Recording Settings
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
Method | Method Name |
3.Return value: None
xxxxxxxxxx
4.Simple sample code
// Get Recording Configuration
[[EchoP2PClient sharedP2PClient]sendHTTP:self.contact.contactId Method:@"GET /Record" param:nil];
//Modify recording configuration
[[EchoP2PClient sharedP2PClient]sendHTTP:self.contact.contactId Method:@"PUT /Record" param:nil];
xxxxxxxxxx
/*
* @param in_strDID Device did
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description
self.deviceCapModel.FunctionListAboutChannel.ChannelList.Channel.HumanSensitivity.Support.isTrue Judge whether it is supported Human shape detection Settings
support Human shape detection Settings call [[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"GET /Pictures/1/PeopleDetectV1" param:nil]
not support Human shape detection Settings call [[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"GET /Pictures/1/PeopleDetect" param:nil]
Declare class:
EchoP2PClient.h
2.Parameter
Parameter | Explain |
---|---|
in_strDID | Device did |
Method | Method Name |
3.Example of channel number return value code
xxxxxxxxxx
{
"AIFace" = true,
"MainStreamOverlay" = false,
"PeopleDetectRegionList" = {
"_Version" = 1.0,
"Region" = {
"ID" = 1,
"_Version" = 1.0,
"TopLeftX" = 0,
"BottomRightX" = 703,
"BottomRightY" = 575,
"TopLeftY" = 0,
},
},
"Trigger" = {
"NotifyAMS" = {
"_Version" = 1.0,
"Enable" = false,
},
"Mail" = {
"_Version" = 1.0,
"Enable" = false,
},
"Push" = {
"_Version" = 1.0,
"Enable" = true,
},
"AlarmOut" = {
"_Version" = 1.0,
"Enable" = true,
"AlarmOutMask" = 1,
},
"Snapshot" = {
"_Version" = 1.0,
"Enable" = true,
"SnapshotMask" = 1,
},
"FullScreen" = {
"_Version" = 1.0,
"Enable" = false,
},
"_Version" = 1.0,
"FaceMask" = {
"_Version" = 1.0,
"Enable" = false,
},
"PTZ" = {
"_Version" = 1.0,
"Enable" = false,
"PTZActionList" = {
"_Version" = 1.0,
"PTZAction" = {
"ChannelID" = 1,
"_Version" = 1.0,
"ActionNum" = 0,
"ActionName" = none,
},
},
},
"BeepAlert" = {
"_Version" = 1.0,
"Enable" = false,
},
"Ftp" = {
"_Version" = 1.0,
"Enable" = false,
},
"Record" = {
"_Version" = 1.0,
"Enable" = true,
"RecordMask" = 1,
},
},
"IsPushPeopleImage" = false,
"AIH265Plus" = true,
"_Version" = 1.0,
"__name" = PeopleDetect,
"Enable" = true,
"Senstive" = middle,
"Schedule" = {
"_Version" = 1.0,
"AllDay" = true,
"TimeBlockList" = {
"TimeBlock_4" = 111111111111111111111111111111111111111111111111,
"TimeBlock_1" = 111111111111111111111111111111111111111111111111,
"TimeBlock_6" = 111111111111111111111111111111111111111111111111,
"_Version" = 1.0,
"TimeBlock_3" = 111111111111111111111111111111111111111111111111,
"TimeBlock_0" = 111111111111111111111111111111111111111111111111,
"TimeBlock_5" = 111111111111111111111111111111111111111111111111,
"TimeBlock_2" = 111111111111111111111111111111111111111111111111,
},
},
"SubStreamOverlay" = false,
}
<?xml version="1.0" encoding="UTF-8" ?>
<P2PList Version="1.0">
<P2P Version="1.0">
<ID>1</ID>
<Enable>true</Enable>
<P2PProtocolName>tutk</P2PProtocolName>
<UUID>IOTBDD-633624-RZHER,JCDPLG#FLIWHI</UUID>
<SubKey>75720994F0E30420</SubKey>
<AndroidAppDownload>http://www.yucvision.com/p6slite.htm</AndroidAppDownload>
<IphoneAppDownload>http://www.yucvision.com/p6slite.htm</IphoneAppDownload>
<Status>internet-ready</Status>
</P2P>
<P2P Version="1.0">
<ID>2</ID>
<Enable>false</Enable>
<P2PProtocolName>ulk</P2PProtocolName>
<UUID />
<SubKey />
<AndroidAppDownload>http://www.zwcloud.wang/p2p_direct_anyan.html</AndroidAppDownload>
<IphoneAppDownload>http://www.zwcloud.wang/p2p_direct_anyan.html</IphoneAppDownload>
<Status>offline</Status>
</P2P>
</P2PList>
xxxxxxxxxx
4.Simple sample code
//Get Human shape detection Settings
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"GET /Pictures/1/PeopleDetectV1" param:nil]
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"GET /Pictures/1/PeopleDetect" param:nil]
//Modify Human shape detection Settings
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"PUT /Pictures/1/PeopleDetectV1" param:nil]
[[EchoP2PClient sharedP2PClient] sendHTTP:self.contact.contactId Method:@"PUT /Pictures/1/PeopleDetect" param:nil]
xxxxxxxxxx
/*
* @param in_strDID Device did
* param Method Name
* @return
*/
-(int)sendHTTP:(NSString *)in_strDID Method:(NSString *)Method param:(NSString *)param;
1.Function Description
Get Human tracking Settings
Declare class: EchoP2PClient.h
Context description or other interfaces :
[EchoP2PClient.sharedP2PClient sendHTTP:self.contact.contactId Method:@"GET /System/PTZCap" param:nil];
和 [EchoP2PClient.sharedP2PClient sendHTTP:self.contact.contactId Method:@"GET /System/DeviceCap" param:nil];
These two interfaces acquire device capabilities
2.ParameterExplain
Parameter | Explain |
---|---|
in_strDID | Device did |
Method | Method Name |
3.Return value: None
xxxxxxxxxx
4.Example of channel number return value code
- (void)receiveRemoteMessage:(NSNotification *)notification {
NSDictionary *Parameter = notification.userInfo;
int key = [Parameter[ZW_KEY] intValue];
NSString *result = Parameter[ZW_RESULT];
NSString *did = Parameter[ZW_DID];
if (![self.contact.contactId isEqualToString:did]) **return**;
switch (key) {
case RET_HTTP_API: {
NSString *xml = [result componentsSeparatedByString:@"\r\n\r\n"].lastObject;
NSDictionary *dic = [UtilitySet httpApiDictionary:result];
if ([dic[@"__name"] isEqualToString:@"Device"]) {
NSLog(@"Device = > %@", dic);
self.deviceCapModel = [DeviceCapModel yy_modelWithJSON:dic];
[self loadData];
}
if ([dic[@"__name"] isEqualToString:@"Channel"]) { // 新灯板能力 与 PTZ 能力
if (dic[@"PanTile"]) { // ptz 能力
NSLog(@"PTZCap = > %@", dic);
self.pTZCapModel = [PTZCapModel yy_modelWithJSON:dic];
}
}
if ([dic[@"__name"] isEqualToString:@"PeopleDetect"] || [dic[@"__name"] isEqualToString:@"PeopleDetectV1"]) {
[self hiddenDismissHud];
NSLog(@"peopleDetectXml = > %@", dic);
self.peopleDetectXml = xml;
self.peopleDetectZoneArmingModel = [ZoneArmingModel yy_modelWithJSON:dic];
dispatch_main_async_safe(^{
[self refreshUI];
});
}
if ([dic[@"__name"] isEqualToString:@"ResponseStatus"]) {
[self hiddenDismissHud];
if ([dic[@"statusCode"] isEqualToString:@"0"]) {
ShowMessage(LocalizedString(@"modify_success", **nil**));
dispatch_main_async_safe(^{
[self.navigationController popViewControllerAnimated:**YES**];
});
} else {
}
}
break;
}
default:break;
}
}
xxxxxxxxxx
/**
@brief Initialize network tool class
@return Network Tools Object
*/
+(NetManager*)sharedManager;
Function Description
Initialize Network Tools Object
Declare class
xxxxxxxxxx
NetManager.h
Context description or other interfaces
Parameter
Return value
Return value | Explain |
---|---|
NetManager* | Network Tools Object |
Simple sample code
xxxxxxxxxx
[NetManager sharedManager];
xxxxxxxxxx
/**
@brief Select local servers
@param RegionType Server regions (Chinese servers, international servers, European servers, American servers)
@param isDebug YES test suit NO formal suit
*/
- (void)selectedServerRegion:(RegionType)RegionType isDebug:(BOOL) isDebug;
Function Description
Select local servers
Declare class
xxxxxxxxxx
NetManager.h
Context description or other interfaces
Parameter
Parameter | Explain |
---|---|
RegionType | Server regions(Chinese servers RegionTypeChina, international servers RegionTypeInternational, European servers RegionTypeEurope, American servers RegionTypeNorthAmerica) |
isDebug | isDebug YES test suit NO formal suit |
Return value
Simple sample code
xxxxxxxxxx
//Set up the server
[NetManager.sharedManager selectedServerRegion:RegionTypeChina isDebug:NO];
xxxxxxxxxx
/**
@brief Save token to local
@param token
*/
- (void)saveWithToken:(NSString *)token;
Function Description
Save token to local
Declare class
xxxxxxxxxx
NetManager.h
Context description or other interfaces
Parameter
Parameter | Explain |
---|---|
token | Token value obtained after successful login |
Return value
Simple sample code
xxxxxxxxxx
//1.Log in to the account first
//2.Then save the obtained token to the local
__weak typeof(self) weakSelf = self;
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:@{
@"account": username,
@"pwd": password,
@"mid": resultString,
@"sn": [NetManager sharedManager].m_strCompnySn,
@"source":@"2"}];
[NetManager.sharedManager publicRequestWithActionPath:kLoginUrlPath Parameter:dic withMethod:@"POST" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
if (r.m_iCode == 200) {
NSDictionary *data = (NSDictionary *)r.m_strData;
//保存token
[NetManager.sharedManager saveWithToken:data[@"token"]];
}else {
}
}];
xxxxxxxxxx
/**
@brief Common interface for network access
@param actionPath Address of network request
@param method Request Method GET PUT POST DELETE
@param callBack Request to return data
@param failure Failure Data
*/
-(void) publicRequestWithActionPath:(NSString)actionPath Parameter:(NSMutableDictionary)Parameter withMethod:(NSString *)method callBack:(void (^)(id JSON))callBack failure:(void (^)(NSError *error))failure;
Function Function Explain
Common interface for network access
declaration class
xxxxxxxxxx
NetManager.h
Explain the context relationship (depending on the interface or which interfaces are used with it)
Parameter
Parameter | Explain |
---|---|
actionPath | Address of network request for example:"safe/get-device-list" Can be viewed on the background YAPI |
method | Network request mode support GET PUT POST DELETE for example @"GET" |
callBack | The request successfully returns JSON as P6SResult object |
failure | Failure Data |
Return value
Simple sample code
xxxxxxxxxx
//GET 请求
[NetManager.sharedManager publicRequestWithActionPath:[NSString stringWithFormat:@"%@/%@",kGetDeviceListUrlPath,NetManager.sharedManager.m_strCompnySn] Parameter:nil withMethod:@"GET" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
if (r.m_iCode == 200) {
}else {
}
} failure:^(NSError *error) {
NSLog(@"error %@",error);
}];
//DELETE 请求
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:@{@"id":[NSString stringWithFormat:@"%@",dict[@"id"]],@"sn":NetManager.sharedManager.m_strCompnySn}];
[NetManager.sharedManager publicRequestWithActionPath:kUnbindAndDeleteUrlPath Parameter:dic withMethod:@"DELETE" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
if (r.m_iCode == 200) {
}
} failure:^(NSError *error) {
NSLog(@"error %@",error);
}];
//POST 请求
__weak typeof(self) weakSelf = self;
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{@"alias":@"test",@"did":_did,@"sn":NetManager.sharedManager.m_strCompnySn}];
[NetManager.sharedManager publicRequestWithActionPath:kAddDeviceUrlPath Parameter:dict withMethod:@"POST" callBack:^(id JSON) {
P6SResult *r = (P6SResult *)JSON;
NSLog(@"xxxxxxxxxx===%@===%d",r.m_strData,weakSelf.deviceType);
if (r.m_iCode == 200) {
}else {
}
} failure:^(NSError *error) {
NSLog(@"error %@",error);
}];
QR Code Setup
Generate a QR code to connect to Wi-Fi, allowing the device to scan the following QR code content:
S=ssid&P=pwd&T=timeString&K=key&A=ipAddress+ipPort
The ssid
and pwd
need to be encrypted with base64.
timeString
: represents the minute difference (time zone * 60). If it's a positive time zone, it should include a '+' sign, for example, +480.
key
: a random 5-character English string.
ipAddress
: The hexadecimal format of the phone's IP address.
For instance, 192.168.250.199 converts to C7FAA8C0.
ipPort
: The hexadecimal format of the phone's idle port.
For example, 39531 converts to 6B9A."
Obtain the device's DID using UDPTool (UDPTool.h)
Firstly initialize, using the port number randomly generated in the QR code.
_tool=[[UDPTool alloc] init];
_tool.delegate=self;
int port=[[[NSUserDefaults standardUserDefaults] objectForKey:@"port"]
intValue];
[_tool initSocketWithPort:port];
Then, within the delegate, retrieve the device's DID number:
- (void)UDPTool:(UDPTool *)updtool receiveData:(NSData *)receiveData;
The content of receiveData is: [P2P]S=9Ad55&DID=NGLSPN-906457-XJVGD
Here, 'S' represents the previously randomly generated key, and 'DID' indicates the device's identification number.
Finally, after obtaining the DID number, it's possible to add the device. Once the DID is acquired, stop receiving data:
[_tool stopUDPSocket]
x
/**
@brief Setting Low-Power Device Prefix
@param array eg: @[@"IOTGAA",@"IOTGBB"]
@return none
*/
- (void)setLowpower4GArray:(NSArray *)array;
Function Description
Sets the DID prefix for low-power devices. These prefixes determine which devices are classified as low-power devices.
Class Declaration:
xxxxxxxxxx
DevicesManage.h
Context and Dependencies
Parameters
Parameter | Description |
---|---|
array | An array of DID prefixes, e.g., @[@"IOTGAA", @"IOTGBB"] |
Return Value
Return Value | Description |
---|---|
None | N/A |
Usage Example
xxxxxxxxxx
[EchoP2PClient.sharedP2PClient setLowpower4GArray:@[@"IOTGAA",@"IOTGBB"]];
x
/**
@brief Query Online Status for Low-Power Devices on Wake Server
@param in_strDID The DID of the device to be queried.
@param callback A completion handler with the query result
@return none
*/
- (void)LPQueryOnlineStatusWithDID:(NSString *)in_strDID callback:(void(^)(int queryResult, const char* DID, int lastLoginSec))callback;
Function Description
Queries the online status of a low-power device through the wake server.
Class Declaration:
xxxxxxxxxx
DevicesManage.h
Context and Dependencies
To determine the status of a low-power device, the process involves two steps:
x
- (void)getDeviceLastTimeWithDID:(NSString *)in_strDID callback:(void(^)(int lastTime, NSString *DID))lastTimeCallback;
• If the last login time (lastTime) is between 0 and 70 seconds, the device is considered online.
• If lastTime exceeds 70 seconds, call the wake server query interface to determine the online status.
2. Use LPQueryOnlineStatusWithDID:callback::
• Check the queryResult:
• 0: The device may be online; further check if lastLoginSec is between 0 and 70 seconds to confirm.
• Non-zero: The device is considered offline.
Parameters
Parameters | Description |
---|---|
in_strDID | The DID of the device to be queried. |
callback | A completion handler with the query result |
- queryResult: 0 means the device may be online, additional checks with lastLoginSec are needed. Other values indicate the device is offline. | |
- DID: The device’s DID. | |
- lastLoginSec: The time (in seconds) since the device last logged in to the wake server. Values between 0–70 indicate the device is online. |
Return Value
Return Value | Description |
---|---|
None | N/A |
Usage Example
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] LPQueryOnlineStatusWithDID:DIDString callback:^(int queryResult, const char *DID, int lastLoginSec) {
NSLog(@"##### ---------- start query camera status - %@---queryResult:%d,lastLoginSec:%d",DIDString,queryResult,lastLoginSec);
int devState = EN_DEVICE_STATUS_UNLINE;
switch (queryResult) {
case 0:
{
if (lastLoginSec >= 0 && lastLoginSec <= 70) {
devState = EN_DEVICE_STATUS_ONLINE;
}else{
devState = EN_DEVICE_STATUS_UNLINE;
}
}
break;
case -1:
devState = EN_DEVICE_STATUS_WAIT;
break;
case -2:
devState = EN_DEVICE_STATUS_NO_RESP;
break;
case -100:
devState = EN_DEVICE_STATUS_UNLINE;
break;
default:
devState = EN_DEVICE_STATUS_UNLINE;
break;
}
}];
x
/**
@brief Query Last Login Time on P2P Server
@param in_strDID The DID of the device to be queried.
@param callback A callback that returns the query result:
@return none
*/
- (void)getDeviceLastTimeWithDID:(NSString *)in_strDID callback:(void(^)(int lastTime, NSString *DID))lastTimeCallback;
Function Description
Queries the last time a device logged into the P2P server.
Class Declaration:
xxxxxxxxxx
DevicesManage.h
Context and Dependencies
The online status of low-power devices is determined by checking their last login time on the P2P server:
• If the last login time (lastTime) is within 0 to 70 seconds, the device is considered online.
• If lastTime exceeds 70 seconds, the wake server should be queried for the last login time using the following method:
xxxxxxxxxx
- (void)LPQueryOnlineStatusWithDID:(NSString *)in_strDID callback:(void(^)(int queryResult, const char* DID, int lastLoginSec))callback;
This ensures an accurate determination of the device’s online status.
Parameter
Parameter | Description |
---|---|
in_strDID | The DID of the device to be queried. |
lastTimeCallback | A callback that returns the query result: |
- lastTime: The number of seconds since the device last logged into the P2P server. | |
- DID: The DID of the device. |
Return Value
Return Value | Description |
---|---|
None | N/A |
Usage Example
x
[[EchoP2PClient sharedP2PClient] getDeviceLastTimeWithDID:DIDString callback:^(int lastTime, NSString *DID) {
NSLog(@"##### ---------- Device %@ last logged in %d seconds ago", DID, lastTime);
if (lastTime >= 0 && lastTime <= 70) {
NSLog(@"Device %@ is ONLINE", DID);
} else {
NSLog(@"Device %@ is OFFLINE, checking wake server...", DID);
[[EchoP2PClient sharedP2PClient] LPQueryOnlineStatusWithDID:DID callback:^(int queryResult, const char *DID, int lastLoginSec) {
if (queryResult == 0 && lastLoginSec >= 0 && lastLoginSec <= 70) {
NSLog(@"Device %@ is ONLINE based on wake server", @(DID));
} else {
NSLog(@"Device %@ is OFFLINE based on wake server", @(DID));
}
}];
}
}];
x
/**
@brief Connect to Low-Power Device
@param DID The DID of the device to connect to.
@param callback A callback function that provides the result of the P2P connection:
@return void
*/
- (void)LPConnectDeviceWithDID:(NSString *)DID callback:(void (^)(NSString *DID, int session))callback;
Function Description
Establishes a P2P connection with a low-power device and wakes it up if necessary.
Class Declaration:
xxxxxxxxxx
DevicesManage.h
Context and Dependencies
This function is used to connect to low-power devices. In addition to establishing the P2P connection, it also wakes up the device. After a successful connection, device authentication is typically performed, similar to regular powered devices.
Parameters
Parameters | Description |
---|---|
DID | The DID of the device to connect to. |
callback | A callback function that provides the result of the P2P connection: |
- DID: The DID of the connected device. | |
- session: A value greater than or equal to 0 indicates success. Negative values indicate failure. |
Return Value
Return Value | Description |
---|---|
None | N/A |
Usage Example
xxxxxxxxxx
[[EchoP2PClient sharedP2PClient] LPConnectDeviceWithDID:contact.contactId callback:^(NSString *DID, int session) {
}];
x
/**
@brief Disconnect Low-Power Device
@param in_strDID The DID of the device to disconnect.
@return void
*/
- (void)LPLogoutWithDID:(NSString *)in_strDID;
Function Description
Disconnects the P2P connection with a low-power device. After disconnection, the device enters sleep mode.
Class Declaration:
xxxxxxxxxx
DevicesManage.h
Context and Dependencies
This function is used to terminate the P2P connection with a low-power device. Once disconnected, the device transitions into a sleep state to conserve energy. It is typically used after completing operations requiring the device to be active.
Parameters
Parameters | Description |
---|---|
in_strDID | The DID of the device to disconnect. |
Return Value
Return Value | Description |
---|---|
None | N/A |
Usage Example
xxxxxxxxxx
[EchoP2PClient.sharedP2PClient LPLogoutWithDID:in_strDID];
x
/**
@brief Monitor P2P Disconnection Status
@param in_strDID The DID of the device to monitor.
@param iChannel The channel number associated with the connection.
@return void
*/
- (void)getReceiveP2PStateWithDID:(NSString *)in_strDID WithChannel:(int)iChannel Success:(void(^)(int ret, NSString *DID))success;
Function Description
Monitors and retrieves the P2P disconnection status for a specific device. It provides a callback when the P2P connection is disrupted.
Class Declaration:
xxxxxxxxxx
DevicesManage.h
Context and Dependencies
This function is used to listen for the disconnection state of P2P devices. The callback is triggered when the connection is lost, enabling appropriate handling, such as retrying the connection or notifying the user.
Parameter
Parameter | Description |
---|---|
in_strDID | The DID of the device to monitor. |
iChannel | The channel number associated with the connection. |
success | A callback triggered on connection state change: |
- ret: A non-zero value indicates a disconnection. | |
- -3: Indicates a timeout. | |
- DID: The DID of the device associated with the disconnection. |
Return Value
Return Value | Description |
---|---|
None | N/A |
Usage Example
xxxxxxxxxx
[EchoP2PClient.sharedP2PClient getReceiveP2PStateWithDID:DID WithChannel:channel Success:^(int ret, NSString *DID) {
if (ret != 0) {
if (ret == -3) {
NSLog(@"Device %@: P2P connection timed out on channel %d", DID, channel);
} else {
NSLog(@"Device %@: P2P connection lost on channel %d, error code: %d", DID, channel, ret);
}
// Handle reconnection or notify user
} else {
NSLog(@"Device %@: P2P connection is active", DID);
}
}];
xxxxxxxxxx
/**
@brief Set AOV Device Flag
@param in_strDID The DID of the device to be marked.
@param flag A boolean indicating the AOV status:- YES: The device is an AOV device.- NO: The device is not an AOV device.
@return void
*/
- (void)tagAOVDevice:(NSString *)in_strDID WithFlag:(BOOL)flag;
Function Description
Marks whether a device is an AOV device. This designation is primarily used during playback to process AOV recordings with fast-forward functionality.
Class Declaration:
xxxxxxxxxx
DevicesManage.h
Context and Dependencies
This function identifies AOV devices to enable specific handling during playback:
• AOV recordings: Played back in fast-forward mode.
• Event recordings: Played back at normal speed.
Parameters
Parameter | Description |
---|---|
in_strDID | The DID of the device to be marked. |
flag | A boolean indicating the AOV status: |
- YES: The device is an AOV device. | |
- NO: The device is not an AOV device. |
Return Value
Return Value | Description |
---|---|
None | N/A |
Usage Example
xxxxxxxxxx
[EchoP2PClient.sharedP2PClient tagAOVDevice:self.contact.contactId WithFlag:YES];