diff options
author | Frederic Marec <frederic.marec@iot.bzh> | 2019-05-10 10:54:58 +0200 |
---|---|---|
committer | Frederic Marec <frederic.marec@iot.bzh> | 2019-05-14 09:51:57 +0200 |
commit | 88211e8b9cb19ecec8c28c1de19e0d42dadcb916 (patch) | |
tree | 2c06a6f5db06211dc2894efc01f249c8aa247dd0 /plugin | |
parent | 9228c9da5b85f0fdd6b01f0309e57b846618be63 (diff) |
Git submodule migration to separated librariesicefish_8.99.5icefish_8.99.4icefish_8.99.3icefish_8.99.2icefish_8.99.1icefish/8.99.5icefish/8.99.4icefish/8.99.3icefish/8.99.2icefish/8.99.1halibut_8.0.6halibut_8.0.5halibut_8.0.4halibut_8.0.3halibut_8.0.2halibut_8.0.1halibut_8.0.0halibut_7.99.3halibut_7.99.2halibut_7.99.1halibut/8.0.6halibut/8.0.5halibut/8.0.4halibut/8.0.3halibut/8.0.2halibut/8.0.1halibut/8.0.0halibut/7.99.3halibut/7.99.2halibut/7.99.18.99.58.99.48.99.38.99.28.99.18.0.68.0.58.0.48.0.38.0.28.0.18.0.07.99.37.99.27.99.1halibut
Bug-AGL: SPEC-2139
Change-Id: I6f1227f7b293b6a3dc8d527e18cd482955783021
Signed-off-by: Frederic Marec <frederic.marec@iot.bzh>
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/unicens-input/CMakeLists.txt | 13 | ||||
-rw-r--r-- | plugin/unicens-output/CMakeLists.txt | 9 | ||||
-rw-r--r-- | plugin/unicens-output/most_unicens.c | 30 | ||||
-rw-r--r-- | plugin/unicens-output/wrap_unicens.c | 42 | ||||
-rw-r--r-- | plugin/unicens-output/wrap_unicens.h | 6 | ||||
-rw-r--r-- | plugin/unicens-output/wrap_volume.c | 18 | ||||
-rw-r--r-- | plugin/unicens-output/wrap_volume.h | 6 |
7 files changed, 52 insertions, 72 deletions
diff --git a/plugin/unicens-input/CMakeLists.txt b/plugin/unicens-input/CMakeLists.txt index 57ed7af..972188c 100644 --- a/plugin/unicens-input/CMakeLists.txt +++ b/plugin/unicens-input/CMakeLists.txt @@ -30,15 +30,4 @@ PROJECT_TARGET_ADD(hal-unicens-md-input) PREFIX "" SUFFIX ".ctlso" OUTPUT_NAME ${TARGET_NAME} - ) - - # Library dependencies (include updates automatically) - TARGET_LINK_LIBRARIES(${TARGET_NAME} - afb-helpers - ctl-utilities - ${link_libraries} - ) - - target_include_directories(${TARGET_NAME} - PRIVATE "${CMAKE_SOURCE_DIR}/app-controller/ctl-lib" - ) + )
\ No newline at end of file diff --git a/plugin/unicens-output/CMakeLists.txt b/plugin/unicens-output/CMakeLists.txt index b6e9977..4a9b736 100644 --- a/plugin/unicens-output/CMakeLists.txt +++ b/plugin/unicens-output/CMakeLists.txt @@ -35,16 +35,7 @@ PROJECT_TARGET_ADD(hal-unicens-output) OUTPUT_NAME ${TARGET_NAME} ) - # Library dependencies (include updates automatically) - TARGET_LINK_LIBRARIES(${TARGET_NAME} - afb-helpers - ctl-utilities - ucs2-volume - ${link_libraries} - ) - target_include_directories(${TARGET_NAME} - PRIVATE "${CMAKE_SOURCE_DIR}/app-controller/ctl-lib" #PRIVATE "${CMAKE_SOURCE_DIR}/4a-hal/4a-hal-controllers" #PRIVATE "${CMAKE_SOURCE_DIR}/4a-hal/4a-hal-manager" #PRIVATE "${CMAKE_SOURCE_DIR}/4a-hal/4a-hal-utilities" diff --git a/plugin/unicens-output/most_unicens.c b/plugin/unicens-output/most_unicens.c index a0d040b..848a09b 100644 --- a/plugin/unicens-output/most_unicens.c +++ b/plugin/unicens-output/most_unicens.c @@ -37,7 +37,7 @@ CTLP_CAPI_REGISTER(UCS_PLUGIN_NAME) -AFB_ApiT unicensHalApiHandle; +afb_api_t unicensHalApiHandle; static uint8_t initialized = 0; @@ -46,7 +46,7 @@ static uint8_t initialized = 0; CTLP_ONLOAD(plugin, callbacks) { unicensHalApiHandle = plugin->api; - AFB_ApiNotice(unicensHalApiHandle, "4A-HAL-UNICENS: Plugin Register: uid='%s' 'info='%s'", plugin->uid, plugin->info); + AFB_API_NOTICE(unicensHalApiHandle, "4A-HAL-UNICENS: Plugin Register: uid='%s' 'info='%s'", plugin->uid, plugin->info); return 0; } @@ -57,15 +57,15 @@ CTLP_CAPI(Init, source, argsJ, queryJ) int err = 0; int pcm_volume[PCM_MAX_CHANNELS] = { 100, 100, 100, 100, 100, 100 }; - AFB_ApiNotice(source->api, "4A-HAL-UNICENS: Initializing 4a plugin"); + AFB_API_NOTICE(source->api, "4A-HAL-UNICENS: Initializing 4a plugin"); if((err = wrap_volume_init())) { - AFB_ApiError(source->api, "Failed to initialize wrapper for volume library"); + AFB_API_ERROR(source->api, "Failed to initialize wrapper for volume library"); goto Abort_Exit; } if((err = wrap_ucs_subscribe_sync(source->api))) { - AFB_ApiError(source->api, "Failed to subscribe to UNICENS binding"); + AFB_API_ERROR(source->api, "Failed to subscribe to UNICENS binding"); goto Abort_Exit; } @@ -76,7 +76,7 @@ CTLP_CAPI(Init, source, argsJ, queryJ) initialized = 1; Abort_Exit: - AFB_ApiNotice(source->api, "4A-HAL-UNICENS: Initializing plugin done, err=%d", err); + AFB_API_NOTICE(source->api, "4A-HAL-UNICENS: Initializing plugin done, err=%d", err); err = 0; /* avoid returning non-zero value, to force loading the plugin */ return err; } @@ -89,22 +89,22 @@ CTLP_CAPI(MasterVol, source, argsJ, queryJ) json_object *valueJ; int err = 0; - AFB_ApiNotice(source->api, "4A-HAL-UNICENS: MasterVolume=%s", json_object_to_json_string(queryJ)); + AFB_API_NOTICE(source->api, "4A-HAL-UNICENS: MasterVolume=%s", json_object_to_json_string(queryJ)); if(! initialized) { - AFB_ApiWarning(source->api, "%s: Link to unicens binder is not initialized, can't set master volume, value=%s", __func__, json_object_get_string(queryJ)); + AFB_API_WARNING(source->api, "%s: Link to unicens binder is not initialized, can't set master volume, value=%s", __func__, json_object_get_string(queryJ)); err = -1; goto Abort_Exit; } if(! json_object_is_type(queryJ, json_type_array) || json_object_array_length(queryJ) <= 0) { - AFB_ApiError(source->api, "%s: invalid json (should be a non empty json array) value=%s", __func__, json_object_get_string(queryJ)); + AFB_API_ERROR(source->api, "%s: invalid json (should be a non empty json array) value=%s", __func__, json_object_get_string(queryJ)); err = -2; goto Abort_Exit; } valueJ = json_object_array_get_idx(queryJ, 0); if(! json_object_is_type(valueJ, json_type_int)) { - AFB_ApiError(source->api, "%s: invalid json (should be an array of int) value=%s", __func__, json_object_get_string(queryJ)); + AFB_API_ERROR(source->api, "%s: invalid json (should be an array of int) value=%s", __func__, json_object_get_string(queryJ)); err = -3; goto Abort_Exit; } @@ -121,7 +121,7 @@ Abort_Exit: /* not used at the moment, disabled in JSON configuration */ CTLP_CAPI(PCMVol, source, argsJ, queryJ) { - AFB_ApiNotice(source->api, "4A-HAL-UNICENS: PCMVolume=%s", json_object_to_json_string(queryJ)); + AFB_API_NOTICE(source->api, "4A-HAL-UNICENS: PCMVolume=%s", json_object_to_json_string(queryJ)); return 0; } @@ -134,10 +134,10 @@ CTLP_CAPI(Events, source, argsJ, queryJ) int err = 0; json_object *j_tmp = NULL; - AFB_ApiError(source->api, "4A-HAL-UNICENS: receiving event query=%s", json_object_to_json_string(queryJ)); + AFB_API_ERROR(source->api, "4A-HAL-UNICENS: receiving event query=%s", json_object_to_json_string(queryJ)); if (initialized == 0) { - AFB_ApiError(source->api, "4A-HAL-UNICENS: Not initialized while receiving event query=%s", json_object_to_json_string(queryJ)); + AFB_API_ERROR(source->api, "4A-HAL-UNICENS: Not initialized while receiving event query=%s", json_object_to_json_string(queryJ)); err = 0; goto Abort_Exit; } @@ -157,11 +157,11 @@ CTLP_CAPI(Events, source, argsJ, queryJ) } if(err == 0) { - AFB_ApiNotice(source->api, "4A-HAL-UNICENS: Node-Availability: node=0x%03X, available=%d", node, available); + AFB_API_NOTICE(source->api, "4A-HAL-UNICENS: Node-Availability: node=0x%03X, available=%d", node, available); wrap_volume_node_avail(source->api, node, available); } else { - AFB_ApiError(source->api, "4A-HAL-UNICENS: Failed to parse events query=%s", json_object_to_json_string(queryJ)); + AFB_API_ERROR(source->api, "4A-HAL-UNICENS: Failed to parse events query=%s", json_object_to_json_string(queryJ)); } Abort_Exit: diff --git a/plugin/unicens-output/wrap_unicens.c b/plugin/unicens-output/wrap_unicens.c index 382eea7..1c16a08 100644 --- a/plugin/unicens-output/wrap_unicens.c +++ b/plugin/unicens-output/wrap_unicens.c @@ -44,7 +44,7 @@ typedef struct parse_result_ { * Subscribes to unicens2-binding events. * \return Returns 0 if successful, otherwise != 0". */ -extern int wrap_ucs_subscribe_sync(AFB_ApiT apiHandle) +extern int wrap_ucs_subscribe_sync(afb_api_t apiHandle) { int err; @@ -52,16 +52,16 @@ extern int wrap_ucs_subscribe_sync(AFB_ApiT apiHandle) /* Build an empty JSON object */ if((err = wrap_json_pack(&j_query, "{}"))) { - AFB_ApiError(apiHandle, "Failed to create subscribe json object"); + AFB_API_ERROR(apiHandle, "Failed to create subscribe json object"); return err; } - if((err = AFB_ServiceSync(apiHandle, "UNICENS", "subscribe", j_query, &j_response))) { - AFB_ApiError(apiHandle, "Fail subscribing to UNICENS events"); + if((err = afb_api_call_sync_legacy(apiHandle, "UNICENS", "subscribe", j_query, &j_response))) { + AFB_API_ERROR(apiHandle, "Fail subscribing to UNICENS events"); return err; } else { - AFB_ApiNotice(apiHandle, "Subscribed to UNICENS events, res=%s", json_object_to_json_string(j_response)); + AFB_API_NOTICE(apiHandle, "Subscribed to UNICENS events, res=%s", json_object_to_json_string(j_response)); json_object_put(j_response); } @@ -75,7 +75,7 @@ extern int wrap_ucs_subscribe_sync(AFB_ApiT apiHandle) * \param data_sz Size of the command data. Valid values: 1..32. * \return Returns 0 if successful, otherwise != 0". */ -extern int wrap_ucs_i2cwrite_sync(AFB_ApiT apiHandle, uint16_t node, uint8_t *data_ptr, uint8_t data_sz) +extern int wrap_ucs_i2cwrite_sync(afb_api_t apiHandle, uint16_t node, uint8_t *data_ptr, uint8_t data_sz) { int err; uint8_t cnt; @@ -86,7 +86,7 @@ extern int wrap_ucs_i2cwrite_sync(AFB_ApiT apiHandle, uint16_t node, uint8_t *da j_array = json_object_new_array(); if(! j_query || ! j_array) { - AFB_ApiError(apiHandle, "Failed to create writei2c json objects"); + AFB_API_ERROR(apiHandle, "Failed to create writei2c json objects"); return -1; } @@ -96,12 +96,12 @@ extern int wrap_ucs_i2cwrite_sync(AFB_ApiT apiHandle, uint16_t node, uint8_t *da json_object_object_add(j_query, "node", json_object_new_int(node)); json_object_object_add(j_query, "data", j_array); - if((err = AFB_ServiceSync(apiHandle, "UNICENS", "writei2c", j_query, &j_response))) { - AFB_ApiError(apiHandle, "Failed to call writei2c_sync"); + if((err = afb_api_call_sync_legacy(apiHandle, "UNICENS", "writei2c", j_query, &j_response))) { + AFB_API_ERROR(apiHandle, "Failed to call writei2c_sync"); return err; } else { - AFB_ApiInfo(apiHandle, "Called writei2c_sync, res=%s", json_object_to_json_string(j_response)); + AFB_API_INFO(apiHandle, "Called writei2c_sync, res=%s", json_object_to_json_string(j_response)); json_object_put(j_response); } @@ -116,7 +116,7 @@ extern int wrap_ucs_sendmessage_sync(uint16_t src_addr, uint16_t msg_id, uint8_t int msgid = (int)msg_id; size_t data_size = (size_t)data_sz; - AFB_ApiNotice(unicensHalApiHandle, "--- HAL triggering send message ---"); + AFB_API_NOTICE(unicensHalApiHandle, "--- HAL triggering send message ---"); /* skip data attribute if possible, wrap_json_unpack may fail to deal with * an empty Base64 string */ @@ -125,19 +125,19 @@ extern int wrap_ucs_sendmessage_sync(uint16_t src_addr, uint16_t msg_id, uint8_t else wrap_json_pack(&j_query, "{s:i, s:i}", "node", node, "msgid", msgid); - AFB_ApiNotice(unicensHalApiHandle, "wrap_ucs_sendmessage: jquery=%s", json_object_to_json_string(j_query)); + AFB_API_NOTICE(unicensHalApiHandle, "wrap_ucs_sendmessage: jquery=%s", json_object_to_json_string(j_query)); - err = AFB_ServiceSync(unicensHalApiHandle, "UNICENS", "sendmessage", j_query, &j_response); + err = afb_api_call_sync_legacy(unicensHalApiHandle, "UNICENS", "sendmessage", j_query, &j_response); if (err != 0) { - AFB_ApiError(unicensHalApiHandle, "Failed to call wrap_ucs_sendmessage ret=%d", err); + AFB_API_ERROR(unicensHalApiHandle, "Failed to call wrap_ucs_sendmessage ret=%d", err); } else { - AFB_ApiNotice(unicensHalApiHandle, "Called wrap_ucs_sendmessage, successful"); + AFB_API_NOTICE(unicensHalApiHandle, "Called wrap_ucs_sendmessage, successful"); } if (j_response != NULL) { - AFB_ApiNotice(unicensHalApiHandle, "wrap_ucs_sendmessage, response=%s", json_object_to_json_string(j_response)); + AFB_API_NOTICE(unicensHalApiHandle, "wrap_ucs_sendmessage, response=%s", json_object_to_json_string(j_response)); json_object_put(j_response); } @@ -145,11 +145,11 @@ extern int wrap_ucs_sendmessage_sync(uint16_t src_addr, uint16_t msg_id, uint8_t } /* ---------------------------- ASYNCHRONOUS API ---------------------------- */ -static void wrap_ucs_i2cwrite_cb(void *closure, int status, struct json_object *j_result, AFB_ApiT apiHandle) +static void wrap_ucs_i2cwrite_cb(void *closure, int status, struct json_object *j_result, afb_api_t apiHandle) { async_job_t *job_ptr; - AFB_ApiInfo(apiHandle, "%s: closure=%p status=%d, res=%s", __func__, closure, status, json_object_to_json_string(j_result)); + AFB_API_INFO(apiHandle, "%s: closure=%p status=%d, res=%s", __func__, closure, status, json_object_to_json_string(j_result)); if(closure) { job_ptr = (async_job_t *) closure; @@ -183,7 +183,7 @@ extern int wrap_ucs_i2cwrite(uint16_t node, j_array = json_object_new_array(); if(! j_query || ! j_array) { - AFB_ApiError(unicensHalApiHandle, "Failed to create writei2c json objects"); + AFB_API_ERROR(unicensHalApiHandle, "Failed to create writei2c json objects"); return -1; } @@ -196,7 +196,7 @@ extern int wrap_ucs_i2cwrite(uint16_t node, job_ptr = malloc(sizeof(async_job_t)); if(! job_ptr) { - AFB_ApiError(unicensHalApiHandle, "Failed to create async job object"); + AFB_API_ERROR(unicensHalApiHandle, "Failed to create async job object"); json_object_put(j_query); return -2; } @@ -204,7 +204,7 @@ extern int wrap_ucs_i2cwrite(uint16_t node, job_ptr->result_fptr = result_fptr; job_ptr->result_user_ptr = result_user_ptr; - AFB_ServiceCall(unicensHalApiHandle, "UNICENS", "writei2c", j_query, wrap_ucs_i2cwrite_cb, job_ptr); + afb_api_call_legacy(unicensHalApiHandle, "UNICENS", "writei2c", j_query, wrap_ucs_i2cwrite_cb, job_ptr); return 0; } diff --git a/plugin/unicens-output/wrap_unicens.h b/plugin/unicens-output/wrap_unicens.h index 6199476..42fa934 100644 --- a/plugin/unicens-output/wrap_unicens.h +++ b/plugin/unicens-output/wrap_unicens.h @@ -26,7 +26,7 @@ #include <ctl-plugin.h> -extern AFB_ApiT unicensHalApiHandle; +extern afb_api_t unicensHalApiHandle; /* Asynchronous API: result callback */ typedef void (*wrap_ucs_result_cb_t)(uint8_t result, void *user_ptr); @@ -39,7 +39,7 @@ extern int wrap_ucs_i2cwrite(uint16_t node, void *result_user_ptr); /* Synchronous API: functions */ -extern int wrap_ucs_subscribe_sync(AFB_ApiT apiHandle); -extern int wrap_ucs_i2cwrite_sync(AFB_ApiT apiHandle, uint16_t node, uint8_t *data_ptr, uint8_t data_sz); +extern int wrap_ucs_subscribe_sync(afb_api_t apiHandle); +extern int wrap_ucs_i2cwrite_sync(afb_api_t apiHandle, uint16_t node, uint8_t *data_ptr, uint8_t data_sz); extern int wrap_ucs_sendmessage_sync(uint16_t src_addr, uint16_t msg_id, uint8_t *data_ptr, uint8_t data_sz); diff --git a/plugin/unicens-output/wrap_volume.c b/plugin/unicens-output/wrap_volume.c index 9c3d7a1..3029a5a 100644 --- a/plugin/unicens-output/wrap_volume.c +++ b/plugin/unicens-output/wrap_volume.c @@ -47,7 +47,7 @@ static int wrap_volume_service_timeout_cb(sd_event_source* source, sd_event_source_unref(source); if((ret = lib_most_volume_service())) - AFB_ApiError(unicensHalApiHandle, "lib_most_volume_service returns %d", ret); + AFB_API_ERROR(unicensHalApiHandle, "lib_most_volume_service returns %d", ret); return 0; } @@ -56,9 +56,9 @@ static void wrap_volume_service_cb(uint16_t timeout) { uint64_t usec; - sd_event_now(AFB_GetEventLoop(unicensHalApiHandle), CLOCK_BOOTTIME, &usec); + sd_event_now(afb_api_get_event_loop(unicensHalApiHandle), CLOCK_BOOTTIME, &usec); - sd_event_add_time(AFB_GetEventLoop(unicensHalApiHandle), + sd_event_add_time(afb_api_get_event_loop(unicensHalApiHandle), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), @@ -95,19 +95,19 @@ extern int wrap_volume_init(void) return -ret; } -extern int wrap_volume_master(AFB_ApiT apiHandle, int volume) +extern int wrap_volume_master(afb_api_t apiHandle, int volume) { int ret; if((ret = lib_most_volume_set(LIB_MOST_VOLUME_MASTER, (uint8_t) wrap_volume_calculate(volume, 100, 255)))) { - AFB_ApiError(apiHandle, "%s: volume library not ready.", __func__); + AFB_API_ERROR(apiHandle, "%s: volume library not ready.", __func__); } return -ret; } -extern int wrap_volume_pcm(AFB_ApiT apiHandle, int *volume_ptr, int volume_sz) +extern int wrap_volume_pcm(afb_api_t apiHandle, int *volume_ptr, int volume_sz) { int cnt, new_value, ret = 0; @@ -118,7 +118,7 @@ extern int wrap_volume_pcm(AFB_ApiT apiHandle, int *volume_ptr, int volume_sz) new_value = wrap_volume_calculate(volume_ptr[cnt], 100, 255); if((ret = lib_most_volume_set((enum lib_most_volume_channel_t) cnt, (uint8_t) new_value))) { - AFB_ApiError(apiHandle, "%s: volume library not ready.", __func__); + AFB_API_ERROR(apiHandle, "%s: volume library not ready.", __func__); break; } } @@ -126,12 +126,12 @@ extern int wrap_volume_pcm(AFB_ApiT apiHandle, int *volume_ptr, int volume_sz) return -ret; } -extern int wrap_volume_node_avail(AFB_ApiT apiHandle, int node, int available) +extern int wrap_volume_node_avail(afb_api_t apiHandle, int node, int available) { int ret; if((ret = lib_most_volume_node_available((uint16_t) node, (uint8_t) available))) - AFB_ApiError(apiHandle, "%s: volume library not ready.", __func__); + AFB_API_ERROR(apiHandle, "%s: volume library not ready.", __func__); return -ret; } diff --git a/plugin/unicens-output/wrap_volume.h b/plugin/unicens-output/wrap_volume.h index 7cdcd93..1489c60 100644 --- a/plugin/unicens-output/wrap_volume.h +++ b/plugin/unicens-output/wrap_volume.h @@ -29,6 +29,6 @@ #include <ctl-plugin.h> extern int wrap_volume_init(void); -extern int wrap_volume_master(AFB_ApiT apiHandle, int volume); -extern int wrap_volume_pcm(AFB_ApiT apiHandle, int *volume_ptr, int volume_sz); -extern int wrap_volume_node_avail(AFB_ApiT apiHandle, int node, int available);
\ No newline at end of file +extern int wrap_volume_master(afb_api_t apiHandle, int volume); +extern int wrap_volume_pcm(afb_api_t apiHandle, int *volume_ptr, int volume_sz); +extern int wrap_volume_node_avail(afb_api_t apiHandle, int node, int available);
\ No newline at end of file |