freemaster_client.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2024 NXP
  3. * NXP Proprietary. This software is owned or controlled by NXP and may only be used strictly in
  4. * accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
  5. * activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
  6. * comply with and are bound by, such license terms. If you do not agree to be bound by the applicable license
  7. * terms, then you may not retain, install, activate or otherwise use the software.
  8. */
  9. #ifndef FREEMASTER_CLIENT_H
  10. #define FREEMASTER_CLIENT_H
  11. #include <stdlib.h>
  12. #include <float.h>
  13. #include <math.h>
  14. #include <jansson.h>
  15. #include "connect_utils.h"
  16. #include "lvgl.h"
  17. #include "gg_external_data.h"
  18. #include <pthread.h>
  19. typedef struct {
  20. char * varName;
  21. char * varType;
  22. } fm_var;
  23. typedef struct {
  24. lv_obj_t * needle_obj;
  25. int32_t needle_length;
  26. } meter_needle;
  27. typedef struct {
  28. lv_obj_t *screen;
  29. lv_obj_t *parentObj;
  30. fm_var * varArray;
  31. void ** childObjArray;
  32. int arrayLen;
  33. int widget_type;
  34. char *apiName;
  35. } readVariableParm;
  36. /*
  37. * FreeMaster JSONRPC response data example :
  38. * {"jsonrpc": "2.0", "id": "1", "result": {"success": true, "xtra": {"retval": true}, "data": 14}}
  39. */
  40. /*
  41. * for connect the websocket server.
  42. */
  43. void connect_init();
  44. /*
  45. * Disconnect the websocket server.
  46. */
  47. void freemaster_disconnect();
  48. /*
  49. * @param {json_t*} params eg: [ "counter", 1].
  50. * @param {char} method_name FreeMaster JSONRPC api name.
  51. * @returns {api_result* } the pointer of the type ap_result.
  52. */
  53. json_t * callAPI(json_t* params, char* method_name);
  54. void freeMasterParse(void *params);
  55. /*
  56. * Show the freeMaster except info based on the LVGL label widget.
  57. * @param {char*} params For show the message box info.
  58. */
  59. void prompt_display(char *message);
  60. /*
  61. * @param {char **} variable_name the binding variable name array.
  62. * @param int arrary length of the binding variable name array.
  63. * @returns {char **} Array of data, In case of success,
  64. * the result array will contain data property of type string representing the read formatted value.
  65. */
  66. char** read_variable(fm_var *varArray, int arrayLen);
  67. /*
  68. * @param {char} variable_name the binding variable name.
  69. * @param {int} value Value to be written.
  70. */
  71. void write_variable(char *varName, int value);
  72. #endif