building release type
This commit is contained in:
parent
328f4ec329
commit
220949d94d
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "x64-Debug",
|
"name": "x64-Release",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"configurationType": "Debug",
|
"configurationType": "Release",
|
||||||
"inheritEnvironments": [ "clang_cl_x64" ],
|
"inheritEnvironments": [ "msvc_x64" ],
|
||||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
@ -53,6 +53,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "WITH_STATIC_LIBRARIES",
|
"name": "WITH_STATIC_LIBRARIES",
|
||||||
|
"value": "True",
|
||||||
|
"type": "BOOL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "WITH_LIB_CPP",
|
||||||
"value": "False",
|
"value": "False",
|
||||||
"type": "BOOL"
|
"type": "BOOL"
|
||||||
}
|
}
|
||||||
|
@ -18,37 +18,37 @@
|
|||||||
if (CJSON_FOUND )
|
if (CJSON_FOUND )
|
||||||
add_definitions("-DWITH_CJSON")
|
add_definitions("-DWITH_CJSON")
|
||||||
|
|
||||||
set( CLIENT_INC ${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include
|
set (MOSQUITTO_IDIR "" CACHE FILEPATH "C:/Program Files/mosquitto/devel/" )
|
||||||
${STDBOOL_H_PATH} ${STDINT_H_PATH} ${mosquitto_SOURCE_DIR}/deps
|
set (MOSQUITTO_LIBRARIES "" CACHE FILEPATH "C:/Program Files/mosquitto/devel/")
|
||||||
${mosquitto_SOURCE_DIR}/src ${CJSON_INCLUDE_DIRS} )
|
set (PLUGIN_NAME wamo)
|
||||||
|
|
||||||
set( CLIENT_DIR ${mosquitto_BINARY_DIR}/lib ${CJSON_DIR})
|
add_library(${PLUGIN_NAME} MODULE
|
||||||
|
${PLUGIN_NAME}.c
|
||||||
include_directories(${CLIENT_INC})
|
|
||||||
link_directories(${CLIENT_DIR} ${mosquitto_SOURCE_DIR})
|
|
||||||
|
|
||||||
add_library(wamo MODULE
|
|
||||||
json_help.c
|
json_help.c
|
||||||
json_help.h
|
json_help.h
|
||||||
wamo.c)
|
)
|
||||||
|
|
||||||
set_target_properties(wamo PROPERTIES
|
target_include_directories(${PLUGIN_NAME} PRIVATE
|
||||||
|
"${CJSON_INCLUDE_DIRS}"
|
||||||
|
"${STDBOOL_H_PATH} ${STDINT_H_PATH}"
|
||||||
|
"${mosquitto_SOURCE_DIR}"
|
||||||
|
"C:/Program Files/mosquitto/devel/"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_directories(${PLUGIN_NAME} PRIVATE ${MOSQUITTO_LIBRARIES} )
|
||||||
|
|
||||||
|
set_target_properties(${PLUGIN_NAME} PROPERTIES
|
||||||
|
PREFIX ""
|
||||||
POSITION_INDEPENDENT_CODE 1
|
POSITION_INDEPENDENT_CODE 1
|
||||||
)
|
)
|
||||||
set_target_properties(wamo PROPERTIES PREFIX "")
|
|
||||||
set_target_properties(wamo PROPERTIES IMPORTED_IMPLIB ${CJSON_LIBRARIES})
|
|
||||||
|
|
||||||
target_link_libraries(wamo ${CJSON_LIBRARIES})
|
set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "")
|
||||||
|
set_target_properties(${PLUGIN_NAME} PROPERTIES IMPORTED_IMPLIB ${CJSON_LIBRARIES})
|
||||||
|
|
||||||
|
target_link_libraries(${PLUGIN_NAME} PRIVATE ${CJSON_LIBRARIES})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto)
|
||||||
set_target_properties(wamo PROPERTIES IMPORTED_IMPLIB mosquitto)
|
endif()
|
||||||
target_link_libraries(wamo mosquitto)
|
|
||||||
install(TARGETS wamo
|
|
||||||
DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
|
||||||
else()
|
|
||||||
install(TARGETS wamo
|
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
endif()
|
endif()
|
@ -71,22 +71,23 @@ int json_del_id_from_array(cJSON* json, const char* name, const char* id)
|
|||||||
|
|
||||||
jtmp = cJSON_GetObjectItem(json, name);
|
jtmp = cJSON_GetObjectItem(json, name);
|
||||||
if (jtmp) {
|
if (jtmp) {
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 1");
|
// mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 1");
|
||||||
if (cJSON_IsArray(jtmp) == true) {
|
if (cJSON_IsArray(jtmp) == true) {
|
||||||
// cJSON_DeleteItemFromObject(json, name);
|
// cJSON_DeleteItemFromObject(json, name);
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 2");
|
// mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 2");
|
||||||
cJSON_ArrayForEach(tid, jtmp)
|
cJSON_ArrayForEach(tid, jtmp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( strcmp( cJSON_GetStringValue(tid),id) == 0)
|
if ( strcmp( cJSON_GetStringValue(tid),id) == 0)
|
||||||
{
|
{
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 3");
|
// mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 3");
|
||||||
detached_item = cJSON_DetachItemFromArray(jtmp, array_index);
|
detached_item = cJSON_DetachItemFromArray(jtmp, array_index);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 4");
|
return MOSQ_ERR_INVAL;
|
||||||
|
// mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 4");
|
||||||
}
|
}
|
||||||
array_index++;
|
array_index++;
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,7 @@ static cJSON* subscribedTopics = NULL;
|
|||||||
static int callback_control(int event, void* event_data, void* userdata)
|
static int callback_control(int event, void* event_data, void* userdata)
|
||||||
{
|
{
|
||||||
struct mosquitto_evt_acl_check* ed = event_data;
|
struct mosquitto_evt_acl_check* ed = event_data;
|
||||||
char* payload = NULL;
|
|
||||||
uint32_t payload_len;
|
|
||||||
|
|
||||||
UNUSED(event);
|
UNUSED(event);
|
||||||
UNUSED(userdata);
|
UNUSED(userdata);
|
||||||
|
|
||||||
@ -67,38 +65,37 @@ static int callback_control(int event, void* event_data, void* userdata)
|
|||||||
json_create_array(subscribedTopics, topic);
|
json_create_array(subscribedTopics, topic);
|
||||||
json_add_id_to_array(subscribedTopics, topic, client_id);
|
json_add_id_to_array(subscribedTopics, topic, client_id);
|
||||||
char* json_string = cJSON_Print(subscribedTopics);
|
char* json_string = cJSON_Print(subscribedTopics);
|
||||||
payload = cJSON_PrintUnformatted(subscribedTopics);
|
char* payload = cJSON_PrintUnformatted(subscribedTopics);
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: client with id %s subscribed to topic %s", client_id, topic);
|
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: client with id %s subscribed to topic %s", client_id, topic);
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: subscribed topics %s", json_string);
|
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: subscribed topics %s", json_string);
|
||||||
|
|
||||||
if (payload == NULL) return MOSQ_ERR_MALFORMED_PACKET;
|
if (payload == NULL) return MOSQ_ERR_MALFORMED_PACKET;
|
||||||
|
|
||||||
payload_len = strlen(payload);
|
uint32_t payload_len = strlen(payload);
|
||||||
if (payload_len > MQTT_MAX_PAYLOAD) {
|
if (payload_len > MQTT_MAX_PAYLOAD) {
|
||||||
free(payload);
|
free(payload);
|
||||||
return MOSQ_ERR_PAYLOAD_SIZE;
|
return MOSQ_ERR_PAYLOAD_SIZE;
|
||||||
}
|
}
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: DEBUG MESSAGE BEFORE PUBLISHING ...");
|
|
||||||
|
mosquitto_broker_publish_copy(NULL, "mqtt/subscriptions",
|
||||||
mosquitto_broker_publish(NULL, "mqtt/subscriptions",
|
(int)payload_len, payload, 0, 0, NULL);
|
||||||
(int)payload_len, payload, 0, true, NULL);
|
|
||||||
}
|
}
|
||||||
else if (access == MOSQ_ACL_UNSUBSCRIBE) {
|
else if (access == MOSQ_ACL_UNSUBSCRIBE) {
|
||||||
json_del_id_from_array(subscribedTopics, topic, client_id);
|
json_del_id_from_array(subscribedTopics, topic, client_id);
|
||||||
char* json_string = cJSON_Print(subscribedTopics);
|
char* json_string = cJSON_Print(subscribedTopics);
|
||||||
payload = cJSON_PrintUnformatted(subscribedTopics);
|
char* payload = cJSON_PrintUnformatted(subscribedTopics);
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: client with id %s unscribed to topic %s", client_id, topic);
|
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: client with id %s unscribed to topic %s", client_id, topic);
|
||||||
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: subscribed topics %s", json_string);
|
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: subscribed topics %s", json_string);
|
||||||
|
|
||||||
if (payload == NULL) return MOSQ_ERR_MALFORMED_PACKET;
|
if (payload == NULL) return MOSQ_ERR_MALFORMED_PACKET;
|
||||||
|
|
||||||
payload_len = strlen(payload);
|
uint32_t payload_len = strlen(payload);
|
||||||
if (payload_len > MQTT_MAX_PAYLOAD) {
|
if (payload_len > MQTT_MAX_PAYLOAD) {
|
||||||
free(payload);
|
free(payload);
|
||||||
return MOSQ_ERR_PAYLOAD_SIZE;
|
return MOSQ_ERR_PAYLOAD_SIZE;
|
||||||
}
|
}
|
||||||
mosquitto_broker_publish(NULL, "mqtt/subscriptions",
|
mosquitto_broker_publish_copy(NULL, "mqtt/subscriptions",
|
||||||
(int)payload_len, payload, 0, true, NULL);
|
(int)payload_len, payload, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user