@@ -571,9 +571,13 @@ bool BytebeamArduino::initSDK() {
571571 printArchitectureInfo ();
572572
573573#ifdef BYTEBEAM_ARDUINO_ARCH_SUPPORTS_FS
574- if (!readDeviceConfigFile ()) {
575- BytebeamLogger::Error (__FILE__, __func__, " Initialization failed, error while reading the device config file.\n " );
576- return false ;
574+ if (this ->deviceConfigStr == NULL ) {
575+ if (!readDeviceConfigFile ()) {
576+ BytebeamLogger::Error (__FILE__, __func__, " Initialization failed, error while reading the device config file.\n " );
577+ return false ;
578+ }
579+ } else {
580+ BytebeamLogger::Info (__FILE__, __func__, " Using Provided Device Config Data!\n " );
577581 }
578582#else
579583 BytebeamLogger::Info (__FILE__, __func__, " Architecture doesn't support file system" );
@@ -762,8 +766,8 @@ BytebeamArduino::~BytebeamArduino() {
762766
763767#ifdef BYTEBEAM_ARDUINO_USE_WIFI
764768 bool BytebeamArduino::begin ( const deviceConfigFileSystem fileSystem,
765- const char * fileName,
766- BytebeamLogger::DebugLevel level) {
769+ const char * fileName,
770+ BytebeamLogger::DebugLevel level) {
767771 // set the device config file system
768772 this ->fileSystem = fileSystem;
769773
@@ -794,13 +798,43 @@ BytebeamArduino::~BytebeamArduino() {
794798
795799 return result;
796800 }
801+
802+ bool BytebeamArduino::begin ( char * deviceConfigData,
803+ BytebeamLogger::DebugLevel level) {
804+ // set the device config data
805+ this ->deviceConfigStr = deviceConfigData;
806+
807+ // set the bytbeam logger log level
808+ BytebeamLogger::setLogLevel (level);
809+
810+ // fix : ensure wifi status before using ntp methods o/w they will give hard fault
811+ if (WiFi.status () != WL_CONNECTED) {
812+ BytebeamLogger::Error (__FILE__, __func__, " Begin abort, could not find WiFi connectivity.\n " );
813+ return false ;
814+ }
815+
816+ // so we got the wifi conectivity at this point
817+ // before initializing the core sdk make sure time client is working fine with wifi
818+ if (!BytebeamTime.begin ()) {
819+ BytebeamLogger::Error (__FILE__, __func__, " Begin abort, time client begin failed.\n " );
820+ return false ;
821+ }
822+
823+ // share the time instance with the log module
824+ BytebeamLog::setTimeInstance (&BytebeamTime);
825+
826+ // initialize the core sdk and give back the status to the user
827+ bool result = initSDK ();
828+
829+ return result;
830+ }
797831#endif
798832
799833#ifdef BYTEBEAM_ARDUINO_USE_MODEM
800834 bool BytebeamArduino::begin ( TinyGsm* modem,
801- const deviceConfigFileSystem fileSystem,
802- const char * fileName,
803- BytebeamLogger::DebugLevel level) {
835+ const deviceConfigFileSystem fileSystem,
836+ const char * fileName,
837+ BytebeamLogger::DebugLevel level) {
804838 // set the device config file system
805839 this ->fileSystem = fileSystem;
806840
@@ -840,6 +874,46 @@ BytebeamArduino::~BytebeamArduino() {
840874
841875 return result;
842876 }
877+
878+ bool BytebeamArduino::begin ( TinyGsm* modem,
879+ char * deviceConfigData,
880+ BytebeamLogger::DebugLevel level) {
881+ // set the device config data
882+ this ->deviceConfigStr = deviceConfigData;
883+
884+ // set the bytbeam logger log level
885+ BytebeamLogger::setLogLevel (level);
886+
887+ // fix : ensure modem instance before using modem class methods o/w they will give hard fault
888+ if (!modem) {
889+ BytebeamLogger::Error (__FILE__, __func__, " Begin abort, failed to get Modem instance.\n " );
890+ return false ;
891+ }
892+
893+ // initiaize the gsm client with the modem instance
894+ this ->gsmClient .init (modem, 0 );
895+
896+ // share the modem instance with the time module
897+ BytebeamTime.setModemInstance (modem);
898+
899+ // setup the gsm OTA client
900+ BytebeamOTA.setupGsmClient (modem);
901+
902+ // so we got the modem conectivity at this point
903+ // before initializing the core sdk make sure time client is working fine with modem
904+ if (!BytebeamTime.begin ()) {
905+ BytebeamLogger::Error (__FILE__, __func__, " Begin abort, time client begin failed.\n " );
906+ return false ;
907+ }
908+
909+ // share the time instance with the log module
910+ BytebeamLog::setTimeInstance (&BytebeamTime);
911+
912+ // initialize the core sdk and give back the status to the user
913+ bool result = initSDK ();
914+
915+ return result;
916+ }
843917#endif
844918
845919bool BytebeamArduino::loop () {
0 commit comments