Skip to content

Commit 4d3f1a4

Browse files
pekkapesuAri Parkkila
authored andcommitted
BG96 power handling added
1 parent 26aa16f commit 4d3f1a4

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "QUECTEL_BG96_CellularInformation.h"
2222
#include "QUECTEL_BG96_CellularContext.h"
2323
#include "CellularLog.h"
24+
#include "DigitalOut.h"
25+
#include "mbed_wait_api.h"
2426

2527
using namespace mbed;
2628
using namespace events;
@@ -74,6 +76,51 @@ void QUECTEL_BG96::set_ready_cb(Callback<void()> callback)
7476
_at->set_urc_handler(DEVICE_READY_URC, callback);
7577
}
7678

79+
nsapi_error_t QUECTEL_BG96::hard_power_on()
80+
{
81+
DigitalOut ModemResetIn (MBED_CONF_QUECTEL_BG96_POWER);
82+
printf("QUECTEL_BG96::hard_power_on\n");
83+
wait_ms(250);
84+
ModemResetIn = 0;
85+
wait_ms(250);
86+
ModemResetIn = 1;
87+
wait_ms(500);
88+
wait_ms(250);
89+
return NSAPI_ERROR_OK;
90+
}
91+
nsapi_error_t QUECTEL_BG96::soft_power_on()
92+
{
93+
DigitalOut ModemPwrkey (MBED_CONF_QUECTEL_BG96_RESET);
94+
printf("QUECTEL_BG96::soft_power_on\n");
95+
ModemPwrkey = 0;
96+
wait_ms(100);
97+
ModemPwrkey = 1;
98+
wait_ms(500);
99+
ModemPwrkey = 0;
100+
wait_ms(500);
101+
printf("wait for RDY\n");
102+
_at->lock();
103+
_at->set_at_timeout(60000);
104+
_at->resp_start();
105+
_at->set_stop_tag("RDY");
106+
bool rdy = _at->consume_to_stop_tag();
107+
_at->set_stop_tag(OK);
108+
_at->unlock();
109+
if (!rdy)
110+
{
111+
return NSAPI_ERROR_DEVICE_ERROR;
112+
}
113+
return NSAPI_ERROR_OK;
114+
}
115+
nsapi_error_t QUECTEL_BG96::hard_power_off()
116+
{
117+
DigitalOut ModemPwrkey (MBED_CONF_QUECTEL_BG96_POWER);
118+
printf("QUECTEL_BG96::hard_power_off\n");
119+
ModemPwrkey = 1;
120+
wait_ms(250);
121+
ModemPwrkey = 0;
122+
return NSAPI_ERROR_OK;
123+
}
77124
#if MBED_CONF_QUECTEL_BG96_PROVIDE_DEFAULT
78125
#include "UARTSerial.h"
79126
CellularDevice *CellularDevice::get_default_instance()

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class QUECTEL_BG96 : public AT_CellularDevice {
4040
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
4141
virtual AT_CellularInformation *open_information_impl(ATHandler &at);
4242
virtual void set_ready_cb(Callback<void()> callback);
43+
virtual nsapi_error_t hard_power_on();
44+
virtual nsapi_error_t hard_power_off();
45+
virtual nsapi_error_t soft_power_on();
4346

4447
public:
4548
void handle_urc(FileHandle *fh);

features/cellular/framework/targets/QUECTEL/BG96/mbed_lib.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
"provide-default": {
2525
"help": "Provide as default CellularDevice [true/false]",
2626
"value": false
27+
},
28+
"power": {
29+
"help": "Modem's power key.",
30+
"value": null
31+
},
32+
"reset": {
33+
"help": "Modem's reset key.",
34+
"value": null
2735
}
2836
}
2937
}

0 commit comments

Comments
 (0)