summaryrefslogtreecommitdiffstats
path: root/ucs2-afb/ucs_binding.c
diff options
context:
space:
mode:
authorTobias Jahnke <tobias.jahnke@microchip.com>2017-11-09 23:32:03 +0100
committerTobias Jahnke <tobias.jahnke@microchip.com>2017-11-11 22:14:57 +0100
commit825ce525d20ac99cd590d40fc06237c1e363cd7e (patch)
treefa2dcd2684a1c8f98d6c8fd7c9bc3b36f1fe5ad4 /ucs2-afb/ucs_binding.c
parent509cfbb9de09c04402f722220b45f95abbe9c0f9 (diff)
adds init function and getter for default cfg path
Change-Id: I620d485bb935f984efcfeaf29399d184d3261e7d Signed-off-by: Tobias Jahnke <tobias.jahnke@microchip.com>
Diffstat (limited to 'ucs2-afb/ucs_binding.c')
-rw-r--r--ucs2-afb/ucs_binding.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c
index e1451a0..a234410 100644
--- a/ucs2-afb/ucs_binding.c
+++ b/ucs2-afb/ucs_binding.c
@@ -42,6 +42,8 @@
#define MAX_FILENAME_LEN (100)
#define RX_BUFFER (64)
+#define XML_CONFIG_FOLDER "/data/"
+#define XML_CONFIG_FILE "config_multichannel_audio_kit.xml"
/** Internal structure, enabling multiple instances of this component.
* \note Do not access any of this variables.
@@ -286,6 +288,33 @@ int onReadCB (sd_event_source* src, int fileFd, uint32_t revents, void* pTag) {
return 0;
}
+
+STATIC char* GetDefaultConfig(void) {
+
+ char const *data_path = getenv("AFM_APP_INSTALL_DIR");
+
+ if (!data_path) {
+ AFB_ERROR("AFM_APP_INSTALL_DIR is not defined");
+ }
+ else {
+ size_t size;
+ char * config_path;
+
+ AFB_NOTICE("AFM_APP_INSTALL_DIR is: %s", data_path);
+ size = strlen(data_path) + strlen(XML_CONFIG_FOLDER) + strlen(XML_CONFIG_FILE) + 2;
+ config_path = malloc(size);
+ if (config_path != NULL) {
+ snprintf(config_path, size, "%s%s%s", data_path, XML_CONFIG_FOLDER, XML_CONFIG_FILE);
+ if(access(config_path, R_OK ) == 0) {
+ AFB_NOTICE("Default configuration: %s", config_path);
+ return config_path;
+ }
+ }
+ }
+
+ return NULL;
+}
+
STATIC UcsXmlVal_t* ParseFile(struct afb_req request) {
char *xmlBuffer;
ssize_t readSize;
@@ -366,7 +395,7 @@ PUBLIC void ucs2_initialise (struct afb_req request) {
afb_req_fail_f (request, "UNICENS-init", "Fail to initialize UNICENS");
goto OnErrorExit;
}
-
+
afb_req_success(request,NULL,"UNICENS-active");
OnErrorExit:
@@ -593,3 +622,13 @@ PUBLIC void ucs2_writei2c (struct afb_req request) {
OnErrorExit:
return;
}
+
+PUBLIC int ucs2_initbinding(void) {
+ char *config_file = GetDefaultConfig();
+ if (config_file != NULL) {
+
+ free(config_file);
+ }
+
+ return 0;
+}