Allow commands to carry user-defined data
This commit is contained in:
parent
b83ab8c414
commit
af6a5ef514
@ -34,6 +34,7 @@ struct _GSMCommand
|
|||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
GSMError error;
|
GSMError error;
|
||||||
GSMCommandCallback callback;
|
GSMCommandCallback callback;
|
||||||
|
void * data;
|
||||||
GSMMode mode;
|
GSMMode mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ GSMCommand * gsm_command_new(char const * command)
|
|||||||
gsmc->timeout = 2000;
|
gsmc->timeout = 2000;
|
||||||
gsmc->error = GSM_ERROR_UNKNOWN;
|
gsmc->error = GSM_ERROR_UNKNOWN;
|
||||||
gsmc->callback = NULL;
|
gsmc->callback = NULL;
|
||||||
|
gsmc->data = NULL;
|
||||||
gsmc->mode = GSM_MODE_COMMAND;
|
gsmc->mode = GSM_MODE_COMMAND;
|
||||||
/* check errors */
|
/* check errors */
|
||||||
if(gsmc->command == NULL)
|
if(gsmc->command == NULL)
|
||||||
@ -92,6 +94,13 @@ char const * gsm_command_get_command(GSMCommand * gsmc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* gsm_command_get_data */
|
||||||
|
void * gsm_command_get_data(GSMCommand * gsmc)
|
||||||
|
{
|
||||||
|
return gsmc->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* gsm_command_get_error */
|
/* gsm_command_get_error */
|
||||||
GSMError gsm_command_get_error(GSMCommand * gsmc)
|
GSMError gsm_command_get_error(GSMCommand * gsmc)
|
||||||
{
|
{
|
||||||
@ -128,6 +137,13 @@ void gsm_command_set_callback(GSMCommand * gsmc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* gsm_command_set_data */
|
||||||
|
void gsm_command_set_data(GSMCommand * gsmc, void * data)
|
||||||
|
{
|
||||||
|
gsmc->data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* gsm_command_set_error */
|
/* gsm_command_set_error */
|
||||||
void gsm_command_set_error(GSMCommand * gsmc, GSMError error)
|
void gsm_command_set_error(GSMCommand * gsmc, GSMError error)
|
||||||
{
|
{
|
||||||
|
@ -31,12 +31,14 @@ void gsm_command_delete(GSMCommand * gsmc);
|
|||||||
/* accessors */
|
/* accessors */
|
||||||
GSMCommandCallback gsm_command_get_callback(GSMCommand * gsmc);
|
GSMCommandCallback gsm_command_get_callback(GSMCommand * gsmc);
|
||||||
char const * gsm_command_get_command(GSMCommand * gsmc);
|
char const * gsm_command_get_command(GSMCommand * gsmc);
|
||||||
|
void * gsm_command_get_data(GSMCommand * gsmc);
|
||||||
GSMError gsm_command_get_error(GSMCommand * gsmc);
|
GSMError gsm_command_get_error(GSMCommand * gsmc);
|
||||||
GSMMode gsm_command_get_mode(GSMCommand * gsmc);
|
GSMMode gsm_command_get_mode(GSMCommand * gsmc);
|
||||||
GSMPriority gsm_command_get_priority(GSMCommand * gsmc);
|
GSMPriority gsm_command_get_priority(GSMCommand * gsmc);
|
||||||
unsigned int gsm_command_get_timeout(GSMCommand * gsmc);
|
unsigned int gsm_command_get_timeout(GSMCommand * gsmc);
|
||||||
|
|
||||||
void gsm_command_set_callback(GSMCommand * gsmc, GSMCommandCallback callback);
|
void gsm_command_set_callback(GSMCommand * gsmc, GSMCommandCallback callback);
|
||||||
|
void gsm_command_set_data(GSMCommand * gsmc, void * data);
|
||||||
void gsm_command_set_error(GSMCommand * gsmc, GSMError error);
|
void gsm_command_set_error(GSMCommand * gsmc, GSMError error);
|
||||||
void gsm_command_set_mode(GSMCommand * gsmc, GSMMode mode);
|
void gsm_command_set_mode(GSMCommand * gsmc, GSMMode mode);
|
||||||
void gsm_command_set_priority(GSMCommand * gsmc, GSMPriority priority);
|
void gsm_command_set_priority(GSMCommand * gsmc, GSMPriority priority);
|
||||||
|
Loading…
Reference in New Issue
Block a user