svghmi/svghmi.c
branchsvghmi
changeset 2798 ddb2c4668a6b
parent 2789 ba0dd2ec6dc4
child 2799 f5da343b9b63
equal deleted inserted replaced
2797:c5ba1e77f054 2798:ddb2c4668a6b
   240 }
   240 }
   241 
   241 
   242 typedef enum {
   242 typedef enum {
   243     setval = 0,
   243     setval = 0,
   244     reset = 1,
   244     reset = 1,
   245     subscribe = 2,
   245     subscribe = 2
   246     unsubscribe = 3
       
   247 } cmd_from_JS;
   246 } cmd_from_JS;
   248 
   247 
   249 int svghmi_recv_dispatch(uint32_t size, const uint8_t *ptr){
   248 int svghmi_recv_dispatch(uint32_t size, const uint8_t *ptr){
   250     const uint8_t* cursor = ptr + HMI_HASH_SIZE;
   249     const uint8_t* cursor = ptr + HMI_HASH_SIZE;
   251     const uint8_t* end = ptr + size;
   250     const uint8_t* end = ptr + size;
   318                 progress = sizeof(uint32_t) /* index */ + 
   317                 progress = sizeof(uint32_t) /* index */ + 
   319                            sizeof(uint16_t) /* refresh period */;
   318                            sizeof(uint16_t) /* refresh period */;
   320             }
   319             }
   321             break;
   320             break;
   322 
   321 
   323             case unsubscribe:
       
   324             {
       
   325                 uint32_t index = *(uint32_t*)(cursor);
       
   326 
       
   327                 if(index < HMI_ITEM_COUNT)
       
   328                 {
       
   329                     hmi_tree_item_t *dsc = &hmi_tree_item[index];
       
   330                     reset_iterator(index, dsc);
       
   331                 }
       
   332                 else return -EINVAL;
       
   333 
       
   334                 progress = sizeof(uint32_t) /* index */;
       
   335             }
       
   336             break;
       
   337         }
   322         }
   338         cursor += progress;
   323         cursor += progress;
   339     }
   324     }
   340     return 0;
   325     return 0;
   341 }
   326 }