Last Updated on : 2024-04-01 07:35:50download
This topic describes how to manage a mesh network.
The mesh network mentioned in the Commercial Lighting App SDK documentation refers to Bluetooth SIG’s mesh network technology. The SDK currently does not support any private mesh protocols.
It is recommended to limit the number of Bluetooth mesh devices in a single mesh network to 300, with no restrictions on the number of non-Bluetooth mesh devices.
Single mesh network mode
Multi-mesh network mode
Device pairing is not supported at the project root node. Pair a device under the target area node. The homeId
passed into the API during pairing should be the gid
of the current area.
The Commercial Lighting App SDK v2.8.1 or later supports creating a project in single mesh network mode or multi-mesh network mode. Operations such as pairing, grouping, and scene should be performed in the specific area node.
Get information about the mesh network associated with the area.
Sample code
ThingLightingArea *area = [ThingLightingArea areaWithAreaId:areaId projectId:projectId];
long long meshId = area.areaModel.meshId;
In a project, only one mesh network will automatically be generated and bound with all area nodes within the project.
Initializes a Bluetooth mesh network and registers a listener for status changes from the cloud. This API method is called when users switch between or initialize Bluetooth mesh networks.
API description
+ (ThingSmartSIGMeshManager * _Nullable)initSIGMeshManager:(ThingSmartBleMeshModel *)meshModel
ttl:(NSInteger)ttl
nodeIds:(NSArray<NSData *> * _Nullable)nodeIds;
Sample code
ThingSmartBleMeshModel *meshModel = [[ThingLightingCacheService sharedInstance] getMeshModelWithId:meshId];
ThingSmartSIGMeshManager *manager = [ThingSmartBleMesh initSIGMeshManager:meshModel ttl:0 nodeIds:@[]];
ThingSmartSIGMeshManager
provides API methods to start a connection, close a connection, start scanning, and stop scanning.
Sample code
Scan for and connect to a Bluetooth mesh sub-device.
ThingSmartBleMeshModel *meshModel = [[ThingLightingCacheService sharedInstance] getMeshModelWithId:meshId];
ThingSmartSIGMeshManager *manager = [ThingSmartBleMesh initSIGMeshManager:meshModel ttl:0 nodeIds:@[]];
[manager startSearch];
Disconnect from the Bluetooth mesh sub-device and stop scanning.
ThingSmartBleMeshModel *meshModel = [[ThingLightingCacheService sharedInstance] getMeshModelWithId:meshId];
ThingSmartSIGMeshManager *manager = [ThingSmartBleMesh initSIGMeshManager:meshModel ttl:0 nodeIds:@[]];
[manager offlineSIGMeshNetwork];
[manager stopSerachDevice];
The background scanning will consume resources. You can start and stop scanning to control the background scanning.
startSearch
: After a connection is started, the app will continuously scan for devices in the background until it successfully connects to one.startSearch
and stopSerachDevice
will not work.A project can have one or more mesh networks. A single mesh network can be bound with one or more areas simultaneously.
Create a mesh network and specify its name.
API description
- (void)createMeshWithName:(NSString *)name
success:(nullable ThingSuccessID)success
failure:(nullable void(^)(NSError *error))failure;
Sample code
ThingLightingProject *project = [ThingLightingProject projectWithProjectId:projectId];
[project createMeshWithName:self.meshNameTextField.text success:^(id result) {
} failure:^(NSError * _Nonnull error) {
}];
A mesh network can be deleted only when it has no associated Bluetooth mesh device and area.
API description
- (void)deleteMeshWithMeshId:(NSString *)meshId
success:(nullable ThingSuccessID)success
failure:(nullable void(^)(NSError *error))failure;
Sample code
[currentProject deleteMeshWithMeshId:self.meshModel.meshId success:^(id result) {
} failure:^(NSError * _Nonnull error) {
}];
Bind one or more areas with one mesh network.
API description
- (void)bindMeshAndAreaWithMeshId:(NSString *)meshId
areaId:(long long)areaId
success:(nullable ThingSuccessID)success
failure:(nullable void(^)(NSError *error))failure
Sample code
[currentProject bindMeshAndAreaWithMeshId:self.meshModel.meshId
areaId:areaModel.areaId
success:^(id result) {
} failure:^(NSError * _Nonnull error) {
}];
Unbind one or more areas from a mesh network.
API description
- (void)unbindMeshAndAreaWithMeshId:(NSString *)meshId
areaId:(long long)areaId
success:(nullable ThingSuccessID)success
failure:(nullable void(^)(NSError *error))failure;
Sample code
[currentProject unbindMeshAndAreaWithMeshId:self.meshModel.meshId
areaId:areaModel.areaId
success:^(id result) {
} failure:^(NSError * _Nonnull error) {
}];
Initialize a specified Bluetooth mesh network.
API description
+ (ThingSmartSIGMeshManager * _Nullable)initSIGMeshManager:(ThingSmartBleMeshModel *)meshModel
ttl:(NSInteger)ttl
nodeIds:(NSArray<NSData *> * _Nullable)nodeIds;
Sample code
ThingSmartBleMeshModel *meshModel = [[ThingLightingCacheService sharedInstance] getMeshModelWithId:meshId];
ThingSmartSIGMeshManager *manager = [ThingSmartBleMesh initSIGMeshManager:meshModel ttl:0 nodeIds:@[]];
No more than three mesh networks can be connected at the same time.
API description
- (void)startSearch;
Sample code
ThingSmartBleMeshModel *meshModel = [[ThingLightingCacheService sharedInstance] getMeshModelWithId:meshId];
ThingSmartSIGMeshManager *manager = [ThingSmartBleMesh initSIGMeshManager:meshModel ttl:0 nodeIds:@[]];
[manager startSearch];
Disconnect from a specified mesh network.
API description
- (void)offlineSIGMeshNetwork;
Sample code
ThingSmartSIGMeshManager *manager = [[impl getCurrentProject] currentSigMeshManager];
[manager offlineSIGMeshNetwork];
Based on meshId
, get a list of all areas associated with this mesh network.
API description
- (void)fetchMeshBindAreasWithMeshId:(NSString *)meshId
includeStatic:(BOOL)includeStatic
success:(nullable void(^)(NSArray<ThingLightingAreaModel *> *areaList))success
failure:(nullable void(^)(NSError *error))failure
Sample code
[currentProject fetchMeshBindAreasWithMeshId:self.meshModel.meshId
includeStatic:NO
success:^(NSArray<ThingLightingAreaModel *> * _Nonnull areaList) {
} failure:^(NSError * _Nonnull error) {
}];
Due to the Bluetooth performance of mobile phones, one mobile phone can currently connect to three mesh networks simultaneously. This method can be used to determine whether a mesh network is connected.
API description
@property (nonatomic, assign, readonly) BOOL isLogin;
Sample code
ThingSmartBleMeshModel *meshModel = [[ThingLightingCacheService sharedInstance] getMeshModelWithId:meshId];
ThingSmartSIGMeshManager *manager = [ThingSmartBleMesh initSIGMeshManager:meshModel ttl:0 nodeIds:@[]];
BOOL isLogin = [manager isLogin];
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback