@@ -104,10 +104,21 @@ static int bc26_sleep(struct at_device *device)
104104 LOG_D ("no memory for resp create." );
105105 return (- RT_ERROR );
106106 }
107-
107+
108+ /* enable sleep mode */
108109 if (at_obj_exec_cmd (device -> client , resp , "AT+QSCLK=1" ) != RT_EOK )
110+
109111 {
110- LOG_D ("enable sleep fail." );
112+ LOG_D ("enable sleep fail.\"AT+QSCLK=1\" execute fail." );
113+ at_delete_resp (resp );
114+ return (- RT_ERROR );
115+ }
116+
117+ /* enable PSM mode */
118+ if (at_obj_exec_cmd (device -> client , resp , "AT+CPSMS=1,,,\"01000011\",\"00000001\"" ) != RT_EOK )
119+
120+ {
121+ LOG_D ("enable sleep fail.\"AT+CPSMS=1...\" execute fail." );
111122 at_delete_resp (resp );
112123 return (- RT_ERROR );
113124 }
@@ -156,9 +167,18 @@ static int bc26_wakeup(struct at_device *device)
156167 rt_thread_mdelay (200 );
157168 }
158169
170+ /* disable sleep mode */
159171 if (at_obj_exec_cmd (device -> client , resp , "AT+QSCLK=0" ) != RT_EOK )
160172 {
161- LOG_D ("wake up fail." );
173+ LOG_D ("wake up fail. \"AT+QSCLK=0\" execute fail." );
174+ at_delete_resp (resp );
175+ return (- RT_ERROR );
176+ }
177+
178+ /* disable PSM mode */
179+ if (at_obj_exec_cmd (device -> client , resp , "AT+CPSMS=0" ) != RT_EOK )
180+ {
181+ LOG_D ("wake up fail.\"AT+CPSMS=0\" execute fail." );
162182 at_delete_resp (resp );
163183 return (- RT_ERROR );
164184 }
@@ -680,12 +700,26 @@ static void bc26_init_thread_entry(void *parameter)
680700 goto __exit ;
681701 }
682702
683- /* disable low power mode */
703+ /* disable sleep mode */
684704 if (at_obj_exec_cmd (device -> client , resp , "AT+QSCLK=0" ) != RT_EOK )
685705 {
686706 result = - RT_ERROR ;
687707 goto __exit ;
688708 }
709+
710+ /* disable eDRX mode */
711+ if (at_obj_exec_cmd (device -> client , resp , "AT+CEDRXS=0" ) != RT_EOK )
712+ {
713+ result = - RT_ERROR ;
714+ goto __exit ;
715+ }
716+
717+ /* disable PSM mode */
718+ if (at_obj_exec_cmd (device -> client , resp , "AT+CPSMS=0" ) != RT_EOK )
719+ {
720+ result = - RT_ERROR ;
721+ goto __exit ;
722+ }
689723
690724 /* Get the baudrate */
691725 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)
920954
921955 switch (cmd )
922956 {
923- case AT_DEVICE_CTRL_POWER_ON :
924- result = bc26_power_on (device );
925- break ;
926- case AT_DEVICE_CTRL_POWER_OFF :
927- result = bc26_power_off (device );
928- break ;
929957 case AT_DEVICE_CTRL_SLEEP :
930958 result = bc26_sleep (device );
931959 break ;
932960 case AT_DEVICE_CTRL_WAKEUP :
933961 result = bc26_wakeup (device );
934962 break ;
963+ case AT_DEVICE_CTRL_POWER_ON :
964+ case AT_DEVICE_CTRL_POWER_OFF :
935965 case AT_DEVICE_CTRL_RESET :
936966 case AT_DEVICE_CTRL_LOW_POWER :
937967 case AT_DEVICE_CTRL_NET_CONN :
0 commit comments