Last Updated on : 2024-04-03 10:00:06download
This topic describes how to manage a project.
A project is an independent unit that is associated with an account. An area and device must be assigned to a project before it becomes available.
Each user can manage one or more projects. The number of projects that can be created depends on the subscribed plan. By default, new users do not have projects after registration and login. They must create projects to perform project-specific operations.
Mesh network mode specifies the type of Bluetooth mesh network a project uses. Two mesh network modes are available:
Get the configuration for an indoor, outdoor, or parking lot project.
Send the configuration for the supported project type based on the subscription plan the current account is on. You can create a project of the type returned by the method. An error will occur if you attempt to create a project of an unsupported type.
API description
void getProjectConfigList(IThingResultCallback<List<LightingProjectConfigsBean>> callback);
LightingProjectConfigsBean
Project configuration class
Parameter | Type | Description |
---|---|---|
projectType | int | The project type. Valid values:
|
projectTypeName | String | The name of the project type. |
projectIconUrl | String | The icon of the project type. |
spaceAttributes | List |
The list of area hierarchy. |
AreaConfig
Area hierarchy class
Parameter | Type | Description |
---|---|---|
id | int | The ID of the area hierarchy. |
name | String | The name of the area hierarchy, for example, zone-building-floor-room. |
iconUrl | String | The icon of the area hierarchy. |
Example
ThingCommercialLightingProject.getLightingProjectManager().getProjectConfigList(new IThingResultCallback<List<LightingProjectConfigsBean>>() {
@Override
public void onSuccess(List<LightingProjectConfigsBean> result) {
if (null != result) {
iProjectIndexView.getProjectConfigListSuccess(result);
}
}
@Override
public void onError(String errorCode, String errorMessage) {
Log.e(TAG, "getProjectConfigList onError: errorCode=" + errorMessage);
iProjectIndexView.getProjectConfigListError();
}
});
API description
Create a project, which can be an indoor project or an outdoor project.
void createProject(
int projectType,
String name,
String leaderName,
String leaderMobile,
String detail,
String regionLocationId,
int networkType,
IThingHomeResultCallback callback);
Parameter description
Parameter | Description | Required |
---|---|---|
projectType | The project type. Valid values:
|
Yes |
name | The name of the project. | Yes |
leaderName | The owner of the project. | Yes |
leaderMobile | The contact information. | Yes |
detail | The address details. This parameter is required for an indoor project or parking lot project to specify the address details. This parameter is required for an outdoor project to specify the location. It is recommended to concatenate the selected area, for example, California, USA. |
Yes |
regionLocationId | The area ID, with multiple IDs separated by a comma (, ).This parameter is required for an outdoor project to specify the location. China: first-level administrative division. Other countries: Country + first-level administrative division. Example: The ID of the Zhejiang province. The ID of the USA,the ID of California Set this field to an empty string for an indoor project or parking lot project. |
No |
networkType | Mesh network mode:
|
Yes |
Example
ThingCommercialLightingProject.getLightingProjectManager().createProject(projectType, projectName, leaderName, leaderMobile, detailAddress, regionId, networkType, new IThingHomeResultCallback() {
@Override
public void onSuccess(HomeBean homeBean) {
if (null == mProjectAddView) {
return;
}
mProjectAddView.doSaveSuccess();
}
@Override
public void onError(String s, String s1) {
if (null == mProjectAddView) {
return;
}
mProjectAddView.doSaveFailed(s1);
}
});
API description
Edit the project information.
void updateProjectInfo(
String name,
String regionLocationId,
String detail,
String leaderName,
String leaderMobile,
IResultCallback callback);
Parameter description
Parameter | Description | Required |
---|---|---|
projectId | The project ID. | Yes |
name | The name of the project. | Yes |
regionLocationId | The area ID, with multiple IDs separated by a comma (, ).This parameter is required for an outdoor project to specify the location. China: first-level administrative division. Other countries: Country + first-level administrative division. Example: The ID of the Zhejiang province. The ID of the USA,the ID of California Set this field to an empty string for an indoor project or parking lot project. |
No |
detail | The address details. This parameter is required for an indoor project or parking lot project to specify the address details. This parameter is required for an outdoor project to specify the location. It is recommended to concatenate the selected area, for example, California, USA. |
Yes |
leaderName | The owner of the project. | Yes |
leaderMobile | The contact information. | Yes |
Example
ThingCommercialLightingProject.newProjectInstance(projectId).updateProjectInfo(mHomeBean.getHomeId(), mHomeBean.getName(),mHomeBean.getLeaderName(), mHomeBean.getLeaderMobile(), regionId, content, new IResultCallback() {
@Override
public void onError(String code, String error) {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.showToast(error);
}
@Override
public void onSuccess() {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.updateAddressDetail(content);
}
});
API description
Delete a project. Once a project is deleted, all its data will be erased, and the associated device will be unbound and reset.
Users will be prompted to enter their password to confirm the action and prevent accidental deletion. The project deletion method will process password verification. Entering the correct password will immediately initiate the project deletion. A warning pop-up window should appear before users input their password.
void deleteProjectWithPassword(String password, IResultCallback callback);
Parameter description
Parameter | Description |
---|---|
projectId | The ID of the target project. |
key | The key obtained through the password (user system: getKeyFromPassword ). |
password | The password for the account. |
Example
ThingCommercialLightingProject.newProjectInstance(projectId).deleteProjectWithPassword(mIProjectInfoView.getProjectId(), password, new IResultCallback() {
@Override
public void onError(String s, String s1) {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.showToast(s1);
}
@Override
public void onSuccess() {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.doRemoveView(true);
}
});
API description
Get the list of created projects.
void getProjectList(IThingGetHomeListCallback callback);
Example
ThingCommercialLightingProject.getLightingProjectManager().getProjectList(new IThingGetHomeListCallback() {
@Override
public void onSuccess(List<HomeBean> list) {
Log.i(TAG, "queryProjectList onSuccess: " + JSON.toJSONString(list));
if (null == iProjectIndexView.getContext()) {
return;
}
if (CollectionUtils.isEmpty(list)) {
iProjectIndexView.showProjectEmptyView();
} else {
iProjectIndexView.setProjectList(list);
}
}
@Override
public void onError(String s, String s1) {
Log.e(TAG, "queryProjectList onError: errorCode=" + s);
}
});
API description
Get the details of the specified project.
void getProjectDetail(IThingHomeResultCallback callback);
Parameter description
Parameter | Description |
---|---|
projectId | The project ID. The method get project list returns projectId . |
Example
ThingCommercialLightingProject.newProjectInstance(long projectId).getProjectDetail(mIProjectInfoView.getProjectId(), new IThingHomeResultCallback() {
@Override
public void onSuccess(HomeBean homeBean) {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.setProjectData(homeBean);
}
@Override
public void onError(String s, String s1) {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.showToast(s1);
}
});
API description
Get the list of countries based on the data center associated with the account. Currently, six countries are supported across three data centers: China Data Center (China), America Data Center (United States, Japan, and Hong Kong, China), and Europe Data Center (Australia). The country supported by a data center can be added dynamically, which is subject to the return value. To add country support, contact your product manager.
void getRegionList(IThingResultCallback<List<LightingRegionListBean>> listener);
LightingRegionListBean
Field | Type | Description |
---|---|---|
locationId | String | The ID of the area. |
name | String | The name of the area, which can be in multiple languages. |
pinyinInitials | String | The initial of the area name. Chinese: The initial of the Pinyin. Other languages: The initial of the first word. This field is used for custom sort or index. |
children | List |
The sub-area of the current area. For example: the first-level administrative division of a country. |
Example
ThingCommercialLightingRegion.getRegionManager().getRegionList(new IThingResultCallback<List<LightingRegionListBean>>() {
@Override
public void onSuccess(List<LightingRegionListBean> result) {
if (result != null) {
mRegionListView.getRegionListSuccess(result);
}
}
@Override
public void onError(String errorCode, String errorMessage) {
mRegionListView.getRegionListError(errorMessage);
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback