Last Updated on : 2023-09-19 03:00:53download

A list of devices can be obtained based on homes. An IP camera (IPC) can be determined by device type. Then, an IPC object can be created with the information provided by ThingSmartDeviceModel.

Determine an IPC

The ThingSmartDeviceModel+IPCSDK class can be used to check whether a device is an IPC.

API description

Determines whether IPC capabilities are supported. This API method cannot be used to determine a product category.

For certain device categories for multiple purposes, for example, smart video locks, they can support IPC capabilities besides basic features.

- (BOOL)isIPCDevice;


Objective C:

[[ThingSmartHomeManager new] getHomeListWithSuccess:^(NSArray<ThingSmartHomeModel *> *homes) {
        [homes enumerateObjectsUsingBlock:^(ThingSmartHomeModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                ThingSmartHome *home = [ThingSmartHome homeWithHomeId:obj.homeId];
                [home getHomeDetailWithSuccess:^(ThingSmartHomeModel *homeModel) {
                        [home.deviceList enumerateObjectsUsingBlock:^(ThingSmartDeviceModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                    if ([obj isIPCDevice]) {
                        NSLog(@"%@ is an IPC", obj.name);
        } failure:^(NSError *error) {

} failure:^(NSError *error) {



let homeManager = ThingSmartHomeManager()
homeManager.getHomeList(success: { homeList in
    homeList?.forEach({ homeModel in
        let home = ThingSmartHome(homeId: homeModel.homeId)
        home?.getDetailWithSuccess({ _ in
            home?.deviceList.forEach({ deviceModel in
                if deviceModel.isIPCDevice() {
                    print(deviceModel.name! , "is an IPC")
        }, failure: { error in

}) { error in


This example only shows the simplest process of a device that supports IPC capabilities. In the actual development, you must display and manage devices based on the specific logic of UI interaction.

Create an IPC instance

Classes (Protocols)

Class name (protocol name) Description
ThingSmartCameraFactory The utility class to create IPC configurations and objects.
ThingSmartCameraConfig The IPC configuration class. You can leave it as it is.
ThingSmartCameraType The IPC API protocol. The implementation varies depending on different IPC firmware types.
ThingSmartCameraDelegate The IPC delegate that provides the callback that returns the result of an IPC method.

ThingSmartCameraFactory provides the factory method to create an IPC control object.

API description

Creates an IPC instance object.

+ (id<ThingSmartCameraType>)cameraWithP2PType:(id)type deviceId:(NSString *)devId delegate:(id<ThingSmartCameraDelegate>)delegate;


Parameter Description
type The peer-to-peer (P2P) type. It is set to a value of Number type.
devId The device ID.
delegate The delegate object.

Return value

Type Description
id The implementation object of the IPC API.

Get the P2P type

The IPC SDK initializes different IPC implementation objects based on the P2P type. You can use ThingSmartDeviceModel+IPCSDK to get the specific P2P type. IPCs support three P2P channel implementation solutions.

API description

Returns the P2P type.

- (NSInteger)p2pType;


Objective C:

// `deviceModel` is the data model of the listed IPCs.
id<ThingSmartCameraType> camera = [ThingSmartCameraFactory cameraWithP2PType:@(deviceModel.p2pType) deviceId:deviceModel.devId delegate:self];


let camera = ThingSmartCameraFactory.camera(withP2PType: deviceModel.p2pType(), deviceId: deviceModel.devId, delegate: self)

In this example, delegate is set to self and ThingSmartCameraDelegate must be implemented.