aboutsummaryrefslogtreecommitdiffstats
path: root/ucs2-afb/ucs_binding.c
diff options
context:
space:
mode:
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;
+}