Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ublox-cellular-base-n2xx by
Revision 2:30cf9c0797cd, committed 2017-07-11
- Comitter:
- ciombor
- Date:
- Tue Jul 11 21:22:58 2017 +0000
- Parent:
- 1:d4ff95ab40ae
- Commit message:
- .
Changed in this revision
UbloxCellularBaseN2xx.cpp | Show annotated file Show diff for this revision Revisions of this file |
UbloxCellularBaseN2xx.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/UbloxCellularBaseN2xx.cpp Mon Jun 26 13:48:04 2017 +0100 +++ b/UbloxCellularBaseN2xx.cpp Tue Jul 11 21:22:58 2017 +0000 @@ -455,6 +455,7 @@ void UbloxCellularBaseN2xx::parser_abort_cb() { +tr_debug("Tomek ERROR - parser jest abortowany...\n\n"); _at->abort(); } @@ -527,7 +528,8 @@ void UbloxCellularBaseN2xx::modem_init() { // Meant to be overridden - #error need to do something here! + //#error need to do something here! + //TOMEK modem jest już uruchomiony } void UbloxCellularBaseN2xx::modem_deinit() @@ -656,7 +658,8 @@ /* Initialize GPIO lines */ tr_info("Powering up modem..."); - onboard_modem_init(); + //onboard_modem_init(); + modem_init(); /* Give SARA-N2XX time to reset */ tr_debug("Waiting for 5 seconds (booting SARA-N2xx)..."); wait_ms(5000); @@ -697,8 +700,10 @@ } // Now do a hard power-off - onboard_modem_power_down(); - onboard_modem_deinit(); + //onboard_modem_power_down(); + //onboard_modem_deinit(); + modem_power_down(); + modem_deinit(); _dev_info.reg_status_csd = CSD_NOT_REGISTERED_NOT_SEARCHING; _dev_info.reg_status_psd = PSD_NOT_REGISTERED_NOT_SEARCHING; @@ -720,7 +725,7 @@ if (success) { if (strstr(buf, "Neul Hi2110")) - *dev = DEV_SARA_N2; + *dev = DEV_SARA_N2; } UNLOCK(); @@ -782,6 +787,7 @@ // Perform registration. bool UbloxCellularBaseN2xx::nwk_registration() { +//tr_debug("TOMEK DEBUG nwk_registration 1"); bool registered = false; int status; int at_timeout; @@ -790,31 +796,69 @@ at_timeout = _at_timeout; // Has to be inside LOCK()s MBED_ASSERT(_at != NULL); - + + cereg(1); +/* // Enable the packet switched and network registration unsolicited result codes if (cereg(1)) { +tr_debug("TOMEK DEBUG nwk_registration 2"); // See if we are already in automatic mode if (get_cops(&status)) { +tr_debug("TOMEK DEBUG nwk_registration 1"); if (status != 0) { // Don't check return code here as there's not much // we can do if this fails. +tr_debug("TOMEK DEBUG nwk_registration 3"); cops(0); } } - +tr_debug("TOMEK DEBUG nwk_registration 4"); // query cereg just in case get_cereg(); registered = is_registered_eps(); - +tr_debug("TOMEK DEBUG nwk_registration 5"); at_set_timeout(1000); for (int waitSeconds = 0; !registered && (waitSeconds < 180); waitSeconds++) { _at->recv(UNNATURAL_STRING); registered = is_registered_eps(); +tr_debug("TOMEK DEBUG nwk_registration 6"); } at_set_timeout(at_timeout); } else { tr_error("Failed to set CEREG=1"); } +tr_debug("TOMEK DEBUG nwk_registration 7"); +*/ + reboot(); // rebot potrzebuje więcej czasu, niż ta funkcja mu daje. Dlatego jest error, ale on w niczym nie przeszkadza.. +// _at->recv("OK"); + wait(14); + +bool success = false; + for(int i = 3; i>0;i--) + { + success = _at->send("AT+CFUN=1\r") + && _at->recv("OK") + && _at->send("AT+CGDCONT=1,\"IP\",\"test-ap-2\"\r") // do przetestowania.. + && _at->recv("OK") + && _at->send("AT+CGATT=1\r") + && _at->recv("OK") + && _at->send("AT+COPS=1,2,\"24408\"\r")// do sparametryzowania.. + && _at->recv("OK"); + if (success) + break; + } + + wait(5); + for(int i=40;i>0;i--) + { + get_cereg(); + wait(3); + if(is_registered_eps()) + { + registered = true; + break; + } + } UNLOCK(); return registered;
--- a/UbloxCellularBaseN2xx.h Mon Jun 26 13:48:04 2017 +0100 +++ b/UbloxCellularBaseN2xx.h Tue Jul 11 21:22:58 2017 +0000 @@ -238,12 +238,12 @@ #if MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_TIMEOUT #define AT_PARSER_TIMEOUT MBED_CONF_UBLOX_CELL_GEN_DRV_AT_PARSER_TIMEOUT #else - #define AT_PARSER_TIMEOUT 8*1000 // Milliseconds + #define AT_PARSER_TIMEOUT 2*1000 // Milliseconds #endif /** A string that would not normally be sent by the modem on the AT interface. */ - #define UNNATURAL_STRING "\x01" + #define UNNATURAL_STRING "\x01984123654897798346467643543468468486486456436" /** Supported u-blox modem variants. */ @@ -392,9 +392,9 @@ * classInit() must be called separately by the first one to wake * the beast. */ - void baseClassInit(PinName tx = MDMTXD, - PinName rx = MDMRXD, - int baud = MBED_CONF_UBLOX_CELL_BAUD_RATE, + void baseClassInit(PinName tx = PA_9, + PinName rx = PA_10, + int baud = 9600, bool debug_on = false); /** Set the AT parser timeout.