Merge pull request #92 from qiyongzhong0/bc26_fix_optimize
Optimize working mode configuration, fix the bug of socket connection…
This commit is contained in:
commit
b52cb287b0
|
@ -104,10 +104,21 @@ static int bc26_sleep(struct at_device *device)
|
|||
LOG_D("no memory for resp create.");
|
||||
return(-RT_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* enable sleep mode */
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+QSCLK=1") != RT_EOK)
|
||||
|
||||
{
|
||||
LOG_D("enable sleep fail.");
|
||||
LOG_D("enable sleep fail.\"AT+QSCLK=1\" execute fail.");
|
||||
at_delete_resp(resp);
|
||||
return(-RT_ERROR);
|
||||
}
|
||||
|
||||
/* enable PSM mode */
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+CPSMS=1,,,\"01000011\",\"00000001\"") != RT_EOK)
|
||||
|
||||
{
|
||||
LOG_D("enable sleep fail.\"AT+CPSMS=1...\" execute fail.");
|
||||
at_delete_resp(resp);
|
||||
return(-RT_ERROR);
|
||||
}
|
||||
|
@ -156,9 +167,18 @@ static int bc26_wakeup(struct at_device *device)
|
|||
rt_thread_mdelay(200);
|
||||
}
|
||||
|
||||
/* disable sleep mode */
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+QSCLK=0") != RT_EOK)
|
||||
{
|
||||
LOG_D("wake up fail.");
|
||||
LOG_D("wake up fail. \"AT+QSCLK=0\" execute fail.");
|
||||
at_delete_resp(resp);
|
||||
return(-RT_ERROR);
|
||||
}
|
||||
|
||||
/* disable PSM mode */
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+CPSMS=0") != RT_EOK)
|
||||
{
|
||||
LOG_D("wake up fail.\"AT+CPSMS=0\" execute fail.");
|
||||
at_delete_resp(resp);
|
||||
return(-RT_ERROR);
|
||||
}
|
||||
|
@ -680,12 +700,26 @@ static void bc26_init_thread_entry(void *parameter)
|
|||
goto __exit;
|
||||
}
|
||||
|
||||
/* disable low power mode */
|
||||
/* disable sleep mode */
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+QSCLK=0") != RT_EOK)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
/* disable eDRX mode */
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+CEDRXS=0") != RT_EOK)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
/* disable PSM mode */
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+CPSMS=0") != RT_EOK)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
/* Get the baudrate */
|
||||
if (at_obj_exec_cmd(device->client, resp, "AT+IPR?") != RT_EOK)
|
||||
|
@ -920,18 +954,14 @@ static int bc26_control(struct at_device *device, int cmd, void *arg)
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
case AT_DEVICE_CTRL_POWER_ON:
|
||||
result = bc26_power_on(device);
|
||||
break;
|
||||
case AT_DEVICE_CTRL_POWER_OFF:
|
||||
result = bc26_power_off(device);
|
||||
break;
|
||||
case AT_DEVICE_CTRL_SLEEP:
|
||||
result = bc26_sleep(device);
|
||||
break;
|
||||
case AT_DEVICE_CTRL_WAKEUP:
|
||||
result = bc26_wakeup(device);
|
||||
break;
|
||||
case AT_DEVICE_CTRL_POWER_ON:
|
||||
case AT_DEVICE_CTRL_POWER_OFF:
|
||||
case AT_DEVICE_CTRL_RESET:
|
||||
case AT_DEVICE_CTRL_LOW_POWER:
|
||||
case AT_DEVICE_CTRL_NET_CONN:
|
||||
|
|
|
@ -154,7 +154,7 @@ static int bc26_socket_close(struct at_socket *socket)
|
|||
static int bc26_socket_connect(struct at_socket *socket, char *ip, int32_t port,
|
||||
enum at_socket_type type, rt_bool_t is_client)
|
||||
{
|
||||
#define CONN_RETRY 3
|
||||
#define CONN_RETRY 2
|
||||
|
||||
int i = 0;
|
||||
const char *type_str = RT_NULL;
|
||||
|
@ -241,6 +241,7 @@ static int bc26_socket_connect(struct at_socket *socket, char *ip, int32_t port,
|
|||
if (i == CONN_RETRY)
|
||||
{
|
||||
LOG_E("%s device socket(%d) connect failed.", device->name, device_socket);
|
||||
result = -RT_ERROR;
|
||||
}
|
||||
|
||||
if (resp)
|
||||
|
@ -300,7 +301,7 @@ static int at_wait_send_finish(struct at_socket *socket, size_t settings_size)
|
|||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
rt_thread_mdelay(50);
|
||||
rt_thread_mdelay(100);
|
||||
}
|
||||
|
||||
return -RT_ETIMEOUT;
|
||||
|
@ -407,8 +408,7 @@ static int bc26_socket_send(struct at_socket *socket, const char *buff, size_t b
|
|||
|
||||
if (type == AT_SOCKET_TCP)
|
||||
{
|
||||
at_wait_send_finish(socket, cur_pkt_size);
|
||||
//rt_thread_mdelay(10);
|
||||
at_wait_send_finish(socket, 2*cur_pkt_size);
|
||||
}
|
||||
|
||||
sent_size += cur_pkt_size;
|
||||
|
|
Loading…
Reference in New Issue