data_config.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*-----------------data config start -------------------*/
  2. #define TOTAL_PROPERTY_COUNT 4
  3. static sDataPoint sg_DataTemplate[TOTAL_PROPERTY_COUNT];
  4. typedef struct _ProductDataDefine {
  5. TYPE_DEF_TEMPLATE_BOOL m_power_switch;
  6. TYPE_DEF_TEMPLATE_ENUM m_color;
  7. TYPE_DEF_TEMPLATE_INT m_brightness;
  8. TYPE_DEF_TEMPLATE_STRING m_name[64 + 1];
  9. } ProductDataDefine;
  10. static ProductDataDefine sg_ProductData;
  11. static void _init_data_template(void)
  12. {
  13. sg_ProductData.m_power_switch = 0;
  14. sg_DataTemplate[0].data_property.data = &sg_ProductData.m_power_switch;
  15. sg_DataTemplate[0].data_property.key = "power_switch";
  16. sg_DataTemplate[0].data_property.type = TYPE_TEMPLATE_BOOL;
  17. sg_ProductData.m_color = 0;
  18. sg_DataTemplate[1].data_property.data = &sg_ProductData.m_color;
  19. sg_DataTemplate[1].data_property.key = "color";
  20. sg_DataTemplate[1].data_property.type = TYPE_TEMPLATE_ENUM;
  21. sg_ProductData.m_brightness = 1;
  22. sg_DataTemplate[2].data_property.data = &sg_ProductData.m_brightness;
  23. sg_DataTemplate[2].data_property.key = "brightness";
  24. sg_DataTemplate[2].data_property.type = TYPE_TEMPLATE_INT;
  25. sg_ProductData.m_name[0] = '\0';
  26. sg_DataTemplate[3].data_property.data = sg_ProductData.m_name;
  27. sg_DataTemplate[3].data_property.data_buff_len = sizeof(sg_ProductData.m_name) / sizeof(sg_ProductData.m_name[3]);
  28. sg_DataTemplate[3].data_property.key = "name";
  29. sg_DataTemplate[3].data_property.type = TYPE_TEMPLATE_STRING;
  30. };