node.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /******************************************************************
  2. *
  3. * uEcho for C
  4. *
  5. * Copyright (C) Satoshi Konno 2015
  6. *
  7. * This is licensed under BSD-style license, see file COPYING.
  8. *
  9. ******************************************************************/
  10. #ifndef _UECHO_NODE_H_
  11. #define _UECHO_NODE_H_
  12. #include <uecho/class.h>
  13. #include <uecho/object.h>
  14. #include <uecho/typedef.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /****************************************
  19. * Constant
  20. ****************************************/
  21. typedef enum _uEchoNodeStatus {
  22. uEchoNodeStatusAdded = 0,
  23. uEchoNodeStatusUpdated,
  24. uEchoNodeStatusAnnounced,
  25. uEchoNodeStatusResponded,
  26. } uEchoNodeStatus;
  27. /****************************************
  28. * Data Type
  29. ****************************************/
  30. #if !defined(_UECHO_NODE_INTERNAL_H_)
  31. typedef void uEchoNode;
  32. #endif
  33. typedef void (*uEchoNodeMessageListener)(uEchoNode*, uEchoMessage*);
  34. /****************************************
  35. * Function
  36. ****************************************/
  37. uEchoNode* uecho_node_new(void);
  38. bool uecho_node_delete(uEchoNode* node);
  39. bool uecho_node_clear(uEchoNode* node);
  40. uEchoNode* uecho_node_next(uEchoNode* node);
  41. void uecho_node_setaddress(uEchoNode* node, const char* addr);
  42. const char* uecho_node_getaddress(uEchoNode* node);
  43. bool uecho_node_isaddress(uEchoNode* node, const char* addr);
  44. uEchoClass* uecho_node_getclasses(uEchoNode* node);
  45. uEchoClass* uecho_node_getclassbycode(uEchoNode* node, uEchoClassCode code);
  46. bool uecho_node_hasclassbycode(uEchoNode* node, uEchoClassCode code);
  47. size_t uecho_node_getclasscount(uEchoNode* node);
  48. uEchoObject* uecho_node_getobjects(uEchoNode* node);
  49. uEchoObject* uecho_node_getobjectbycode(uEchoNode* node, uEchoObjectCode code);
  50. bool uecho_node_hasobjectbycode(uEchoNode* node, uEchoObjectCode code);
  51. size_t uecho_node_getobjectcount(uEchoNode* node);
  52. bool uecho_node_addobject(uEchoNode* node, uEchoObject* obj);
  53. bool uecho_node_setobject(uEchoNode* node, uEchoObjectCode code);
  54. bool uecho_node_start(uEchoNode* node);
  55. bool uecho_node_stop(uEchoNode* node);
  56. bool uecho_node_isrunning(uEchoNode* node);
  57. bool uecho_node_setmanufacturercode(uEchoNode* node, uEchoManufactureCode code);
  58. bool uecho_node_announcemessage(uEchoNode* node, uEchoMessage* msg);
  59. bool uecho_node_announcemessagebytes(uEchoNode* node, byte* msg, size_t msg_len);
  60. bool uecho_node_sendmessage(uEchoNode* node, uEchoNode* dst_node, uEchoMessage* msg);
  61. bool uecho_node_sendmessagebytes(uEchoNode* node, const char* addr, byte* msg, size_t msg_len);
  62. void uecho_node_setmessagelistener(uEchoNode* node, uEchoNodeMessageListener listener);
  63. /****************************************
  64. * Macro
  65. ****************************************/
  66. #define uecho_node_getnodeprofileclassobject(node) uecho_node_getobjectbycode(node, uEchoNodeProfileObject)
  67. /****************************************
  68. * Function (Object)
  69. ****************************************/
  70. uEchoNode* uecho_object_getparentnode(uEchoObject* obj);
  71. #ifdef __cplusplus
  72. } /* extern C */
  73. #endif
  74. #endif /* _UECHO_NODE_H_ */