Skip to content

Commit 4a8fa79

Browse files
Rocketctfacchinm
authored andcommitted
GSM: modify begin() to allow setting bands
1 parent c13877b commit 4a8fa79

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

libraries/GSM/examples/GSMClient/GSMClient.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ char pass[] = SECRET_PASSWORD;
1111
const char server[] = "www.example.com";
1212
const char* ip_address;
1313
int port = 80;
14-
1514
GSMClient client;
1615

1716
void setup() {
1817
Serial.begin(115200);
1918
while(!Serial) {}
2019
Serial.println("Starting Carrier Network registration");
21-
if(!GSM.begin(pin, apn, username, pass, CATNB)){
20+
if(!GSM.begin(pin, apn, username, pass, CATNB, BAND_20 | BAND_19)){
2221
Serial.println("The board was not able to register to the network...");
2322
// do nothing forevermore:
2423
while(1);

libraries/GSM/src/GSM.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mbed::CellularDevice *mbed::CellularDevice::get_default_instance()
2626
return &device;
2727
}
2828

29-
int arduino::GSMClass::begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat, bool restart) {
29+
int arduino::GSMClass::begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat, uint32_t band, bool restart) {
3030

3131
if(restart || isCmuxEnable()) {
3232
pinMode(PJ_10, OUTPUT);
@@ -69,9 +69,11 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern
6969
_username = username;
7070
_password = password;
7171
_rat = rat;
72+
_band = (FrequencyBand) band;
7273
_context->set_credentials(apn, username, password);
7374

7475
_context->set_access_technology(rat);
76+
_context->set_band(_band);
7577

7678
int connect_status = NSAPI_ERROR_AUTH_FAILURE;
7779
uint8_t retryCount = 0;

libraries/GSM/src/GSM.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class GSMClass : public MbedSocketClass {
6969
*
7070
* return: 0 in case of success, negative number in case of failure
7171
*/
72-
int begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat = CATNB, bool restart = true);
72+
int begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat = CATNB, uint32_t band = BAND_20, bool restart = true);
7373

7474
/*
7575
* Disconnect from the network
@@ -104,6 +104,7 @@ class GSMClass : public MbedSocketClass {
104104
const char* _password = nullptr;
105105
bool _cmuxGSMenable = _CMUX_ENABLE;
106106
RadioAccessTechnologyType _rat;
107+
FrequencyBand _band;
107108
NetworkInterface* gsm_if = nullptr;
108109
mbed::CellularContext* _context = nullptr;
109110
mbed::CellularDevice* _device = nullptr;

0 commit comments

Comments
 (0)