remove newline sins they already being added
This commit is contained in:
parent
6ba0d37d08
commit
3ed3534130
@ -427,7 +427,7 @@ void MQTT_EventCallback(int32_t event){
|
|||||||
* User must copy the topic or payload data if it needs to be saved.
|
* User must copy the topic or payload data if it needs to be saved.
|
||||||
*/
|
*/
|
||||||
void BrokerCB(char* topic, char* payload){
|
void BrokerCB(char* topic, char* payload){
|
||||||
LOG_INFO("TOPIC: %s \tPAYLOAD: %s\r\n", topic, payload);
|
LOG_INFO("TOPIC: %s \tPAYLOAD: %s", topic, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void ToggleLED1CB(char* topic, char* payload){
|
// void ToggleLED1CB(char* topic, char* payload){
|
||||||
@ -499,7 +499,7 @@ int WifiInit(){
|
|||||||
ret |= pthread_attr_setdetachstate(&pattrs_spawn, PTHREAD_CREATE_DETACHED);
|
ret |= pthread_attr_setdetachstate(&pattrs_spawn, PTHREAD_CREATE_DETACHED);
|
||||||
ret = pthread_create(&spawn_thread, &pattrs_spawn, sl_Task, NULL);
|
ret = pthread_create(&spawn_thread, &pattrs_spawn, sl_Task, NULL);
|
||||||
if(ret != 0){
|
if(ret != 0){
|
||||||
LOG_ERROR("could not create simplelink task\n\r");
|
LOG_ERROR("could not create simplelink task");
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +509,7 @@ int WifiInit(){
|
|||||||
|
|
||||||
ret = Network_IF_InitDriver(ROLE_STA);
|
ret = Network_IF_InitDriver(ROLE_STA);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
LOG_ERROR("Failed to start SimpleLink Device\n\r");
|
LOG_ERROR("Failed to start SimpleLink Device");
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ int WifiInit(){
|
|||||||
|
|
||||||
ret = Network_IF_ConnectAP(SSID_NAME, security_params);
|
ret = Network_IF_ConnectAP(SSID_NAME, security_params);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
LOG_ERROR("Connection to an AP failed\n\r");
|
LOG_ERROR("Connection to an AP failed");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
@ -535,10 +535,10 @@ int WifiInit(){
|
|||||||
|
|
||||||
ret = sl_WlanProfileAdd((signed char*)SSID_NAME, strlen(SSID_NAME), 0, &securityParams, NULL, 7, 0);
|
ret = sl_WlanProfileAdd((signed char*)SSID_NAME, strlen(SSID_NAME), 0, &securityParams, NULL, 7, 0);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
LOG_ERROR("failed to add profile %s\r\n", SSID_NAME);
|
LOG_ERROR("failed to add profile %s", SSID_NAME);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
LOG_INFO("profile added %s\r\n", SSID_NAME);
|
LOG_INFO("profile added %s", SSID_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,10 +556,8 @@ void MQTTPublish(char * topic, char * payload){
|
|||||||
void MQTTTask(void * args){
|
void MQTTTask(void * args){
|
||||||
|
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
mq_attr attr;
|
|
||||||
UART_Handle uartHandle;
|
UART_Handle uartHandle;
|
||||||
struct msgQueue queueElement;
|
struct msgQueue queueElement;
|
||||||
MQTTClient_Handle mqttClientHandle;
|
|
||||||
|
|
||||||
uartHandle = InitTerm();
|
uartHandle = InitTerm();
|
||||||
UART_control(uartHandle, UART_CMD_RXDISABLE, NULL);
|
UART_control(uartHandle, UART_CMD_RXDISABLE, NULL);
|
||||||
@ -569,9 +567,10 @@ void MQTTTask(void * args){
|
|||||||
ret = ti_net_SlNet_initConfig();
|
ret = ti_net_SlNet_initConfig();
|
||||||
if(0 != ret)
|
if(0 != ret)
|
||||||
{
|
{
|
||||||
LOG_ERROR("Failed to initialize SlNetSock\n\r");
|
LOG_ERROR("Failed to initialize SlNetSock");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mq_attr attr;
|
||||||
attr.mq_maxmsg = 10;
|
attr.mq_maxmsg = 10;
|
||||||
attr.mq_msgsize = sizeof(struct msgQueue);
|
attr.mq_msgsize = sizeof(struct msgQueue);
|
||||||
appQueue = mq_open("appQueue", O_CREAT, 0, &attr);
|
appQueue = mq_open("appQueue", O_CREAT, 0, &attr);
|
||||||
@ -584,8 +583,6 @@ void MQTTTask(void * args){
|
|||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MQTT_DEMO:
|
|
||||||
|
|
||||||
ret = MQTT_IF_Init(mqttInitParams);
|
ret = MQTT_IF_Init(mqttInitParams);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
while(1);
|
while(1);
|
||||||
@ -595,6 +592,8 @@ MQTT_DEMO:
|
|||||||
setTime();
|
setTime();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
MQTTClient_Handle mqttClientHandle;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In case a persistent session is being used, subscribe is called before connect so that the module
|
* In case a persistent session is being used, subscribe is called before connect so that the module
|
||||||
* is aware of the topic callbacks the user is using. This is important because if the broker is holding
|
* is aware of the topic callbacks the user is using. This is important because if the broker is holding
|
||||||
@ -606,14 +605,14 @@ MQTT_DEMO:
|
|||||||
// ret |= MQTT_IF_Subscribe(mqttClientHandle, "cc32xx/ToggleLED1", MQTT_QOS_2, ToggleLED1CB);
|
// ret |= MQTT_IF_Subscribe(mqttClientHandle, "cc32xx/ToggleLED1", MQTT_QOS_2, ToggleLED1CB);
|
||||||
// ret |= MQTT_IF_Subscribe(mqttClientHandle, "cc32xx/ToggleLED2", MQTT_QOS_2, ToggleLED2CB);
|
// ret |= MQTT_IF_Subscribe(mqttClientHandle, "cc32xx/ToggleLED2", MQTT_QOS_2, ToggleLED2CB);
|
||||||
// ret |= MQTT_IF_Subscribe(mqttClientHandle, "cc32xx/ToggleLED3", MQTT_QOS_2, ToggleLED3CB);
|
// ret |= MQTT_IF_Subscribe(mqttClientHandle, "cc32xx/ToggleLED3", MQTT_QOS_2, ToggleLED3CB);
|
||||||
ret |= MQTT_IF_Subscribe(mqttClientHandle, "ems20/handshake/0964590/reply", MQTT_QOS_2, BrokerCB);
|
// ret |= MQTT_IF_Subscribe(mqttClientHandle, "ems20/handshake/0964590/reply", MQTT_QOS_2, BrokerCB);
|
||||||
ret |= MQTT_IF_Subscribe(mqttClientHandle, "ems20/handshake/0971472/request", MQTT_QOS_2, BrokerCB);
|
// ret |= MQTT_IF_Subscribe(mqttClientHandle, "ems20/handshake/0971472/request", MQTT_QOS_2, BrokerCB);
|
||||||
if(ret < 0){
|
// if(ret < 0){
|
||||||
while(1);
|
// while(1);
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
LOG_INFO("Subscribed to all topics successfully\r\n");
|
// LOG_INFO("Subscribed to all topics successfully\r\n");
|
||||||
}
|
// }
|
||||||
|
|
||||||
mqttClientHandle = MQTT_IF_Connect(mqttClientParams, mqttConnParams, MQTT_EventCallback);
|
mqttClientHandle = MQTT_IF_Connect(mqttClientParams, mqttConnParams, MQTT_EventCallback);
|
||||||
if(mqttClientHandle < 0){
|
if(mqttClientHandle < 0){
|
||||||
@ -631,7 +630,7 @@ MQTT_DEMO:
|
|||||||
|
|
||||||
if(queueElement.event == APP_MQTT_PUBLISH){
|
if(queueElement.event == APP_MQTT_PUBLISH){
|
||||||
|
|
||||||
LOG_TRACE("APP_MQTT_PUBLISH\r\n");
|
LOG_TRACE("APP_MQTT_PUBLISH");
|
||||||
|
|
||||||
MQTT_IF_Publish(mqttClientHandle,
|
MQTT_IF_Publish(mqttClientHandle,
|
||||||
queueElement.topic,
|
queueElement.topic,
|
||||||
@ -642,7 +641,7 @@ MQTT_DEMO:
|
|||||||
}
|
}
|
||||||
else if(queueElement.event == APP_MQTT_CON_TOGGLE){
|
else if(queueElement.event == APP_MQTT_CON_TOGGLE){
|
||||||
|
|
||||||
LOG_TRACE("APP_MQTT_CON_TOGGLE %d\r\n", connected);
|
LOG_TRACE("APP_MQTT_CON_TOGGLE %d", connected);
|
||||||
|
|
||||||
|
|
||||||
if(connected){
|
if(connected){
|
||||||
@ -658,11 +657,8 @@ MQTT_DEMO:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(queueElement.event == APP_MQTT_DEINIT){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if(queueElement.event == APP_BTN_HANDLER){
|
else if(queueElement.event == APP_BTN_HANDLER){
|
||||||
LOG_TRACE("APP_BTN_HANDLER: does nothing\r\n");
|
LOG_TRACE("APP_BTN_HANDLER: does nothing");
|
||||||
|
|
||||||
// struct msgQueue queueElement;
|
// struct msgQueue queueElement;
|
||||||
|
|
||||||
@ -684,16 +680,6 @@ MQTT_DEMO:
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit = 1;
|
|
||||||
if(connected){
|
|
||||||
MQTT_IF_Disconnect(mqttClientHandle);
|
|
||||||
}
|
|
||||||
MQTT_IF_Deinit();
|
|
||||||
|
|
||||||
LOG_INFO("looping the MQTT functionality of the example for demonstration purposes only\r\n");
|
|
||||||
sleep(2);
|
|
||||||
goto MQTT_DEMO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user