ApplicationBasicManager.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. *
  3. * Copyright (c) 2021 Project CHIP Authors
  4. * All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #pragma once
  19. #include <app/clusters/application-basic-server/application-basic-server.h>
  20. using chip::CharSpan;
  21. using chip::app::AttributeValueEncoder;
  22. using chip::Platform::CopyString;
  23. using ApplicationBasicDelegate = chip::app::Clusters::ApplicationBasic::Delegate;
  24. class ApplicationBasicManager : public ApplicationBasicDelegate
  25. {
  26. public:
  27. ApplicationBasicManager() :
  28. ApplicationBasicManager(123, "applicationId", "exampleVendorName1", 1, "exampleName1", 1, "exampleVersion"){};
  29. ApplicationBasicManager(uint16_t szCatalogVendorId, const char * szApplicationId, const char * szVendorName, uint16_t vendorId,
  30. const char * szApplicationName, uint16_t productId, const char * szApplicationVersion) :
  31. ApplicationBasicDelegate(szCatalogVendorId, szApplicationId)
  32. {
  33. ChipLogProgress(DeviceLayer, "ApplicationBasic[%s]: Application Name=\"%s\"", szApplicationId, szApplicationName);
  34. CopyString(mApplicationName, sizeof(mApplicationName), szApplicationName);
  35. CopyString(mVendorName, sizeof(mVendorName), szVendorName);
  36. mVendorId = vendorId;
  37. CopyString(mApplicationVersion, sizeof(mApplicationVersion), szApplicationVersion);
  38. mProductId = productId;
  39. static const uint16_t kTestVendorId = 456; // CI test cases require this vendor id
  40. mAllowedVendorList.push_back(vendorId);
  41. mAllowedVendorList.push_back(kTestVendorId);
  42. };
  43. virtual ~ApplicationBasicManager(){};
  44. CHIP_ERROR HandleGetVendorName(AttributeValueEncoder & aEncoder) override;
  45. uint16_t HandleGetVendorId() override;
  46. CHIP_ERROR HandleGetApplicationName(AttributeValueEncoder & aEncoder) override;
  47. uint16_t HandleGetProductId() override;
  48. CHIP_ERROR HandleGetApplicationVersion(AttributeValueEncoder & aEncoder) override;
  49. CHIP_ERROR HandleGetAllowedVendorList(AttributeValueEncoder & aEncoder) override;
  50. std::list<uint16_t> GetAllowedVendorList() override { return mAllowedVendorList; };
  51. protected:
  52. static const int kVendorNameSize = 32;
  53. static const int kApplicationNameSize = 32;
  54. static const int kApplicationVersionSize = 32;
  55. char mVendorName[kVendorNameSize];
  56. uint16_t mVendorId;
  57. char mApplicationName[kApplicationNameSize];
  58. uint16_t mProductId;
  59. char mApplicationVersion[kApplicationVersionSize];
  60. std::list<uint16_t> mAllowedVendorList = {};
  61. };