version 1.1.2.7, 2012/05/10 09:06:42
|
version 1.2.2.1, 2012/06/28 09:01:42
|
Line 152 mqtt_cli_Subscribe(mqtt_cli_t * __restrict cli, mqtt_s
|
Line 152 mqtt_cli_Subscribe(mqtt_cli_t * __restrict cli, mqtt_s
|
if (siz == -1) { |
if (siz == -1) { |
LOGERR; |
LOGERR; |
return NULL; |
return NULL; |
} | } else |
| memset(cli->buf->msg_base, 0, cli->buf->msg_len); |
|
|
if ((siz = mqtt_wait4data(cli->sock, cli->timeout, POLLIN | POLLPRI)) == -1) { |
if ((siz = mqtt_wait4data(cli->sock, cli->timeout, POLLIN | POLLPRI)) == -1) { |
return NULL; |
return NULL; |
Line 204 mqtt_cli_Unsubscribe(mqtt_cli_t * __restrict cli, mqtt
|
Line 205 mqtt_cli_Unsubscribe(mqtt_cli_t * __restrict cli, mqtt
|
if (siz == -1) { |
if (siz == -1) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
} | } else |
| memset(cli->buf->msg_base, 0, cli->buf->msg_len); |
|
|
if ((siz = mqtt_wait4data(cli->sock, cli->timeout, POLLIN | POLLPRI)) == -1) { |
if ((siz = mqtt_wait4data(cli->sock, cli->timeout, POLLIN | POLLPRI)) == -1) { |
return -1; |
return -1; |
Line 239 mqtt_cli_Unsubscribe(mqtt_cli_t * __restrict cli, mqtt
|
Line 241 mqtt_cli_Unsubscribe(mqtt_cli_t * __restrict cli, mqtt
|
* @csTopic = Topic |
* @csTopic = Topic |
* @pData = Data |
* @pData = Data |
* @datLen = Data length |
* @datLen = Data length |
* return: -1 error or 0 ok | * return: -1 error or > -1 sended bytes |
*/ |
*/ |
int |
int |
mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short msgID, u_char Dup, u_char QoS, u_char Retain, |
mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short msgID, u_char Dup, u_char QoS, u_char Retain, |
const char *csTopic, const void *pData, int datLen) |
const char *csTopic, const void *pData, int datLen) |
{ |
{ |
int siz = 0; | int wlen = 0, siz = 0; |
|
|
if (!cli || !csTopic) |
if (!cli || !csTopic) |
return -1; |
return -1; |
Line 258 mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short
|
Line 260 mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short
|
if (siz == -1) { |
if (siz == -1) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
|
} else { |
|
wlen = siz; |
|
memset(cli->buf->msg_base, 0, cli->buf->msg_len); |
} |
} |
|
|
if (QoS == MQTT_QOS_ONCE) /* no reply */ |
if (QoS == MQTT_QOS_ONCE) /* no reply */ |
Line 303 mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short
|
Line 308 mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short
|
if (siz == -1) { |
if (siz == -1) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
} | } else |
| memset(cli->buf->msg_base, 0, cli->buf->msg_len); |
|
|
if ((siz = mqtt_wait4data(cli->sock, cli->timeout, POLLIN | POLLPRI)) == -1) { |
if ((siz = mqtt_wait4data(cli->sock, cli->timeout, POLLIN | POLLPRI)) == -1) { |
return -1; |
return -1; |
Line 315 mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short
|
Line 321 mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short
|
} |
} |
|
|
/* receive PUBCOMP */ |
/* receive PUBCOMP */ |
|
siz = recv(cli->sock, cli->buf->msg_base, cli->buf->msg_len, 0); |
|
if (siz == -1) { |
|
LOGERR; |
|
return -1; |
|
} |
|
|
siz = mqtt_readPUBCOMP(cli->buf); |
siz = mqtt_readPUBCOMP(cli->buf); |
if (siz == -1) |
if (siz == -1) |
return -1; |
return -1; |
Line 328 mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short
|
Line 340 mqtt_cli_Publish(mqtt_cli_t * __restrict cli, u_short
|
} while (0); |
} while (0); |
|
|
end: |
end: |
return 0; | return wlen; |
} |
} |