-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lib): add module shared functions
- Loading branch information
1 parent
2c22d8b
commit 610fdb5
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @file module.h | ||
* @author Tomás Sánchez <tosanchez@frba.utn.edu.ar> | ||
* @brief | ||
* @version 0.1 | ||
* @date 04-29-2022 | ||
* | ||
* @copyright Copyright (c) 2022 | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "conexion.h" | ||
|
||
/** | ||
* @brief Forces a module connection | ||
* | ||
* @param connection to connect | ||
* @param offline_mode wether the module is working offline or not. | ||
* @return exit status code | ||
*/ | ||
int on_module_connect(void *connection, bool offline_mode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @file module.c | ||
* @author Tomás Sánchez <tosanchez@frba.utn.edu.ar> | ||
* @brief | ||
* @version 0.1 | ||
* @date 04-29-2022 | ||
* | ||
* @copyright Copyright (c) 2022 | ||
* | ||
*/ | ||
|
||
#include "module.h" | ||
#include "log.h" | ||
#include "lib.h" | ||
|
||
int on_module_connect(void *connection, bool offline_mode) | ||
{ | ||
if (offline_mode) | ||
{ | ||
LOG_WARNING("Module working in offline mode."); | ||
return ERROR; | ||
} | ||
|
||
while (!conexion_esta_conectada(*(conexion_t *)connection)) | ||
{ | ||
LOG_TRACE("Connecting..."); | ||
|
||
if (conexion_conectar((conexion_t *)connection) EQ ERROR) | ||
{ | ||
LOG_ERROR("Could not connect."); | ||
sleep(TIEMPO_ESPERA); | ||
} | ||
} | ||
|
||
return SUCCESS; | ||
} |