gxPL  1.0
Tools, Application and Framework for xPL
device.h
1 
9 #ifndef _GXPL_SERVICE_HEADER_
10 #define _GXPL_SERVICE_HEADER_
11 
12 #include <gxPL/defs.h>
13 __BEGIN_C_DECLS
14 /* ========================================================================== */
15 
28 /* types ==================================================================== */
29 
35 typedef void (* gxPLDeviceListener) (gxPLDevice *, gxPLMessage *, void *);
36 
41 /* internal public functions ================================================ */
59 gxPLMessage * gxPLDeviceMessageNew (gxPLDevice * device, gxPLMessageType type);
60 
70 int gxPLDeviceMessageSend (gxPLDevice * device, gxPLMessage * message);
71 
80 gxPLSetting * gxPLDeviceSetting (gxPLDevice * device);
81 
108 int gxPLDeviceListenerAdd (gxPLDevice * device,
109  gxPLDeviceListener listener,
110  gxPLMessageType type,
111  char * schema_class, char * schema_type,
112  void * udata);
113 
120 int gxPLDeviceListenerRemove (gxPLDevice * device,
121  gxPLDeviceListener listener);
122 
129 gxPLApplication * gxPLDeviceParent (gxPLDevice * device);
130 
136 const gxPLId * gxPLDeviceId (const gxPLDevice * device);
137 
143 const char * gxPLDeviceVendorId (const gxPLDevice * device);
144 
150 const char * gxPLDeviceDeviceId (const gxPLDevice * device);
151 
157 const char * gxPLDeviceInstanceId (const gxPLDevice * device);
158 
164 int gxPLDeviceIsEnabled (const gxPLDevice * device);
165 
172 int gxPLDeviceHeartbeatInterval (const gxPLDevice * device);
173 
184 long gxPLDeviceHeartbeatLast (const gxPLDevice * device);
185 
193 const char * gxPLDeviceVersion (const gxPLDevice * device);
194 
200 int gxPLDeviceIsRespondToBroadcast (const gxPLDevice * device);
201 
207 int gxPLDeviceIsReportOwnMessages (const gxPLDevice * device);
208 
214 int gxPLDeviceIsHubConfirmed (const gxPLDevice * device);
215 
221 int gxPLDeviceIsConfigurale (const gxPLDevice * device);
222 
228 int gxPLDeviceIsConfigured (const gxPLDevice * device);
229 
236 int gxPLDeviceIdSet (gxPLDevice * device, const gxPLId * id);
237 
244 int gxPLDeviceVendorIdSet (gxPLDevice * device, const char * vendor_id);
245 
252 int gxPLDeviceDeviceIdSet (gxPLDevice * device, const char * device_id);
253 
260 int gxPLDeviceInstanceIdSet (gxPLDevice * device, const char * instance_id);
261 
268 int gxPLDeviceVersionSet (gxPLDevice * device, const char * version);
269 
276 int gxPLDeviceEnable (gxPLDevice * device, bool enabled);
277 
284 int gxPLDeviceHeartbeatIntervalSet (gxPLDevice * device, int interval);
285 
292 int gxPLDeviceRespondToBroadcastSet (gxPLDevice * device, bool respond);
293 
300 int gxPLDeviceReportOwnMessagesSet (gxPLDevice * device, bool isreportownmsg);
301 
320 int gxPLDeviceGroupAdd (gxPLDevice * device, const char * group_name);
321 
329 int gxPLDeviceGroupAddFromString (gxPLDevice * device, const char * str);
330 
337 int gxPLDeviceGroupCount (const gxPLDevice * device);
338 
346 const char * gxPLDeviceGroupGet (const gxPLDevice * device, int index);
347 
354 int gxPLDeviceGroupClearAll (gxPLDevice * device);
355 
362 int gxPLDeviceGroupHave (const gxPLDevice * device);
363 
386 int gxPLDeviceFilterAdd (gxPLDevice * device, gxPLMessageType type,
387  const gxPLId * source, const gxPLSchema * schema);
388 
408 int gxPLDeviceFilterAddFromStr (gxPLDevice * device, char * filter);
409 
416 int gxPLDeviceFilterCount (const gxPLDevice * device);
417 
425 const char * gxPLDeviceFilterGet (const gxPLDevice * device, int index);
426 
433 int gxPLDeviceFilterHave (const gxPLDevice * device);
434 
441 int gxPLDeviceFilterClearAll (gxPLDevice * device);
442 
450 const char * gxPLDeviceFilterToString (const gxPLFilter * filter);
451 
472 /* types ==================================================================== */
473 
479 typedef void (* gxPLDeviceConfigListener) (gxPLDevice *, void *);
480 
481 /* structures =============================================================== */
485 typedef struct _gxPLDeviceConfigItem {
486 
487  char * name;
489  uint8_t values_max;
490  xVector values;
492 
493 /* internal public functions ================================================ */
494 
495 
504 int gxPLDeviceConfigListenerAdd (gxPLDevice * device,
505  gxPLDeviceConfigListener listener,
506  void * udata) ;
507 
515 int gxPLDeviceConfigListenerRemove (gxPLDevice * device,
516  gxPLDeviceConfigListener listener);
517 
528 int gxPLDeviceConfigItemAdd (gxPLDevice * device, const char * name,
529  gxPLConfigurableType type, int max_values);
530 
538 int gxPLDeviceConfigItemRemove (gxPLDevice * device, const char * name);
539 
546 int gxPLDeviceConfigItemRemoveAll (gxPLDevice * device);
547 
555 int gxPLDeviceConfigItemClearAll (gxPLDevice * device);
556 
564 gxPLDeviceConfigItem * gxPLDeviceConfigItemFind (const gxPLDevice * device,
565  const char * name);
566 
574 int gxPLDeviceConfigValueCount (const gxPLDevice * device, const char * name);
575 
585 int gxPLDeviceConfigValueAdd (gxPLDevice * device,
586  const char * name, const char * value);
587 
588 
597 int gxPLDeviceConfigValueSet (gxPLDevice * device,
598  const char * name, const char * value);
599 
611 int gxPLDeviceConfigValueSetAt (gxPLDevice * device, const char * name,
612  int index, const char * value);
613 
621 int gxPLDeviceConfigValueClearAll (gxPLDevice * device, const char * name);
622 
630 const char * gxPLDeviceConfigValueGet (gxPLDevice * device, const char * name);
631 
640 const char * gxPLDeviceConfigValueGetAt (gxPLDevice * device, const char * name, int index);
641 
649 const char * gxPLDeviceConfigFilenameGet (const gxPLDevice * device);
650 
656 int gxPLDeviceConfigSave (const gxPLDevice * device);
657 
666 # ifdef __DOXYGEN__
667 // -----------------------------------------------------------------------------
668 
669 #else
670 // -----------------------------------------------------------------------------
671 /*
672  * @brief Return the installed config file, if any
673  * the file name can not be changed if the device is not configured yet.
674  * @param device pointer on the configurable device
675  * @return 0, -1 if an error occurs
676  */
677 int gxPLDeviceConfigFilenameSet (gxPLDevice * device, const char * filename);
678 
679 
680 // -----------------------------------------------------------------------------
681 # endif /* __DOXYGEN__ not defined */
682 
683 /* ========================================================================== */
684 __END_C_DECLS
685 #endif /* _GXPL_SERVICE_HEADER_ defined */
int gxPLDeviceInstanceIdSet(gxPLDevice *device, const char *instance_id)
Sets the instance identifier.
gxPLConfigurableType
xPL Configurable Type
Definition: defs.h:202
const char * gxPLDeviceConfigValueGet(gxPLDevice *device, const char *name)
Return the value of the first/only index for an item.
struct _gxPLDeviceConfigItem gxPLDeviceConfigItem
Describe a element of configuration.
int gxPLDeviceConfigItemAdd(gxPLDevice *device, const char *name, gxPLConfigurableType type, int max_values)
Add a new configurable.
gxPLApplication * gxPLDeviceParent(gxPLDevice *device)
Gets the parent gxPLApplication object.
int gxPLDeviceVendorIdSet(gxPLDevice *device, const char *vendor_id)
Sets the vendor identifier.
int gxPLDeviceGroupHave(const gxPLDevice *device)
Indicates whether the device has groups.
int gxPLDeviceGroupAdd(gxPLDevice *device, const char *group_name)
Adds a group to the device.
int gxPLDeviceConfigItemClearAll(gxPLDevice *device)
Clear all configurable values out.
int gxPLDeviceHeartbeatInterval(const gxPLDevice *device)
Gets the heartbeat interval.
int gxPLDeviceIsRespondToBroadcast(const gxPLDevice *device)
Indicates whether the device will respond to broadcast messages.
int gxPLDeviceConfigValueSet(gxPLDevice *device, const char *name, const char *value)
Simple form to set first/only value in an item.
int gxPLDeviceEnable(gxPLDevice *device, bool enabled)
Enabled or not a device.
uint8_t values_max
Definition: device.h:489
int gxPLDeviceConfigValueClearAll(gxPLDevice *device, const char *name)
Clear values for a given configurable.
gxPLMessageType
Possible xPL message types.
Definition: defs.h:136
Describe a element of configuration.
Definition: device.h:485
int gxPLDeviceReportOwnMessagesSet(gxPLDevice *device, bool isreportownmsg)
Process own messages.
Describe a source or destination xPL identifier.
Definition: defs.h:279
const char * gxPLDeviceVendorId(const gxPLDevice *device)
Gets the vendor identifier.
long gxPLDeviceHeartbeatLast(const gxPLDevice *device)
Gets the time of the last heartbeat sent.
int gxPLDeviceIsHubConfirmed(const gxPLDevice *device)
Indicates whether the device has detected a hub.
int gxPLDeviceIsEnabled(const gxPLDevice *device)
Indicates whether the device is enabled.
int gxPLDeviceConfigItemRemoveAll(gxPLDevice *device)
Remove all configurables.
int gxPLDeviceFilterHave(const gxPLDevice *device)
Indicates whether the device has filters.
int gxPLDeviceFilterAddFromStr(gxPLDevice *device, char *filter)
Adds a filter to the device from a string.
int gxPLDeviceConfigItemRemove(gxPLDevice *device, const char *name)
Remove a configurable.
const char * gxPLDeviceDeviceId(const gxPLDevice *device)
Gets the device identifier.
int gxPLDeviceConfigSave(const gxPLDevice *device)
Save out the current configuration.
Describe a gxPLApplication configuration.
Definition: defs.h:238
int gxPLDeviceConfigValueSetAt(gxPLDevice *device, const char *name, int index, const char *value)
Set a item value at a given index.
int gxPLDeviceGroupAddFromString(gxPLDevice *device, const char *str)
Adds a group to the device form a string.
int gxPLDeviceIdSet(gxPLDevice *device, const gxPLId *id)
Sets the identifier.
const char * gxPLDeviceFilterToString(const gxPLFilter *filter)
Convert a filter to a string For display purposes.
const gxPLId * gxPLDeviceId(const gxPLDevice *device)
Gets the identifier.
int gxPLDeviceVersionSet(gxPLDevice *device, const char *version)
Sets the version.
int gxPLDeviceConfigListenerAdd(gxPLDevice *device, gxPLDeviceConfigListener listener, void *udata)
Add a device config changed listener.
int gxPLDeviceMessageSend(gxPLDevice *device, gxPLMessage *message)
Send a message out from this device.
int gxPLDeviceIsConfigured(const gxPLDevice *device)
Indicates whether the device is configured.
int gxPLDeviceFilterCount(const gxPLDevice *device)
Number of filters.
const char * gxPLDeviceVersion(const gxPLDevice *device)
Gets the version string.
const char * gxPLDeviceFilterGet(const gxPLDevice *device, int index)
Gets a filter.
int gxPLDeviceListenerAdd(gxPLDevice *device, gxPLDeviceListener listener, gxPLMessageType type, char *schema_class, char *schema_type, void *udata)
Add a listener for the device.
Describe a xPL schema.
Definition: defs.h:288
int gxPLDeviceListenerRemove(gxPLDevice *device, gxPLDeviceListener listener)
Remove a device listener.
int gxPLDeviceIsReportOwnMessages(const gxPLDevice *device)
Indicates whether the device will transmit its own messages to the listeners.
gxPLConfigurableType type
Definition: device.h:488
Describe a xPL filter.
Definition: defs.h:296
gxPLMessage * gxPLDeviceMessageNew(gxPLDevice *device, gxPLMessageType type)
Create a message for the device.
int gxPLDeviceRespondToBroadcastSet(gxPLDevice *device, bool respond)
Enable the response to broadcast messages.
int gxPLDeviceFilterClearAll(gxPLDevice *device)
Erases all filters.
gxPLDeviceConfigItem * gxPLDeviceConfigItemFind(const gxPLDevice *device, const char *name)
Search for a configurable.
int gxPLDeviceDeviceIdSet(gxPLDevice *device, const char *device_id)
Sets the device identifier.
const char * gxPLDeviceGroupGet(const gxPLDevice *device, int index)
Gets a group.
int gxPLDeviceGroupClearAll(gxPLDevice *device)
Erases all groups.
void(* gxPLDeviceListener)(gxPLDevice *, gxPLMessage *, void *)
Listener for a device The end-user can add listener functions that will be called each time the devic...
Definition: device.h:35
int gxPLDeviceFilterAdd(gxPLDevice *device, gxPLMessageType type, const gxPLId *source, const gxPLSchema *schema)
Adds a filter to the device.
const char * gxPLDeviceConfigFilenameGet(const gxPLDevice *device)
Return the installed config file, if any.
int gxPLDeviceHeartbeatIntervalSet(gxPLDevice *device, int interval)
Sets the heartbeat interval.
int gxPLDeviceIsConfigurale(const gxPLDevice *device)
Indicates whether the device is configurable.
const char * gxPLDeviceConfigValueGetAt(gxPLDevice *device, const char *name, int index)
Return the value at the given index.
int gxPLDeviceConfigValueCount(const gxPLDevice *device, const char *name)
Return the number of values for a given configurable.
gxPLSetting * gxPLDeviceSetting(gxPLDevice *device)
Returns device setting.
const char * gxPLDeviceInstanceId(const gxPLDevice *device)
Gets the instance identifier.
int gxPLDeviceConfigValueAdd(gxPLDevice *device, const char *name, const char *value)
Add a device item value.
int gxPLDeviceConfigListenerRemove(gxPLDevice *device, gxPLDeviceConfigListener listener)
Remove a config changed listener.
void(* gxPLDeviceConfigListener)(gxPLDevice *, void *)
Device configuration changed listener The end-user can add listener functions that will be called eac...
Definition: device.h:479
int gxPLDeviceGroupCount(const gxPLDevice *device)
Number of groups.