Skip to content

Commit 0aae2de

Browse files
committed
make isInitialized private and use
1 parent 49038e8 commit 0aae2de

File tree

2 files changed

+57
-57
lines changed

2 files changed

+57
-57
lines changed

src/BytebeamArduino.cpp

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@ boolean BytebeamArduino::init(const deviceConfigFileSystem fileSystem, const cha
628628
return true;
629629
}
630630

631+
boolean BytebeamArduino::isInitialized() {
632+
// return the client status i.e initialized or de-initialized
633+
return this->isClientActive;
634+
}
635+
631636
BytebeamArduino::BytebeamArduino()
632637
#ifdef BYTEBEAM_ARDUINO_USE_MODEM
633638
: secureClient(&gsmClient)
@@ -732,15 +737,10 @@ BytebeamArduino::~BytebeamArduino() {
732737
}
733738
#endif
734739

735-
boolean BytebeamArduino::isInitialized() {
736-
// return the client status i.e initialized or de-initialized
737-
return this->isClientActive;
738-
}
739-
740740
boolean BytebeamArduino::loop() {
741-
// client should be active and if not just log the info to serial and abort :)
742-
if(!this->isClientActive) {
743-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
741+
// client should be initialized and if not just log the info to serial and abort :)
742+
if(!isInitialized()) {
743+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
744744
return false;
745745
}
746746

@@ -788,9 +788,9 @@ boolean BytebeamArduino::loop() {
788788
}
789789

790790
boolean BytebeamArduino::isConnected() {
791-
// client should be active and if not just log the info to serial and abort :)
792-
if(!this->isClientActive) {
793-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
791+
// client should be initialized and if not just log the info to serial and abort :)
792+
if(!isInitialized()) {
793+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
794794
return false;
795795
}
796796

@@ -799,9 +799,9 @@ boolean BytebeamArduino::isConnected() {
799799
}
800800

801801
boolean BytebeamArduino::handleActions(char* actionReceivedStr) {
802-
// client should be active and if not just log the info to serial and abort :)
803-
if(!this->isClientActive) {
804-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
802+
// client should be initialized and if not just log the info to serial and abort :)
803+
if(!isInitialized()) {
804+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
805805
return false;
806806
}
807807

@@ -931,9 +931,9 @@ boolean BytebeamArduino::handleActions(char* actionReceivedStr) {
931931
}
932932

933933
boolean BytebeamArduino::addActionHandler(int (*funcPtr)(char* args, char* actionId), char* actionName) {
934-
// client should be active and if not just log the info to serial and abort :)
935-
if(!this->isClientActive) {
936-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
934+
// client should be initialized and if not just log the info to serial and abort :)
935+
if(!isInitialized()) {
936+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
937937
return false;
938938
}
939939

@@ -958,9 +958,9 @@ boolean BytebeamArduino::addActionHandler(int (*funcPtr)(char* args, char* actio
958958
}
959959

960960
boolean BytebeamArduino::removeActionHandler(char* actionName) {
961-
// client should be active and if not just log the info to serial and abort :)
962-
if(!this->isClientActive) {
963-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
961+
// client should be initialized and if not just log the info to serial and abort :)
962+
if(!isInitialized()) {
963+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
964964
return false;
965965
}
966966

@@ -990,9 +990,9 @@ boolean BytebeamArduino::removeActionHandler(char* actionName) {
990990
}
991991

992992
boolean BytebeamArduino::updateActionHandler(int (*newFuncPtr)(char* args, char* actionId), char* actionName) {
993-
// client should be active and if not just log the info to serial and abort :)
994-
if(!this->isClientActive) {
995-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
993+
// client should be initialized and if not just log the info to serial and abort :)
994+
if(!isInitialized()) {
995+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
996996
return false;
997997
}
998998

@@ -1015,9 +1015,9 @@ boolean BytebeamArduino::updateActionHandler(int (*newFuncPtr)(char* args, char*
10151015
}
10161016

10171017
boolean BytebeamArduino::isActionHandlerThere(char* actionName) {
1018-
// client should be active and if not just log the info to serial and abort :)
1019-
if(!this->isClientActive) {
1020-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1018+
// client should be initialized and if not just log the info to serial and abort :)
1019+
if(!isInitialized()) {
1020+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
10211021
return false;
10221022
}
10231023

@@ -1040,9 +1040,9 @@ boolean BytebeamArduino::isActionHandlerThere(char* actionName) {
10401040
}
10411041

10421042
boolean BytebeamArduino::printActionHandlerArray() {
1043-
// client should be active and if not just log the info to serial and abort :)
1044-
if(!this->isClientActive) {
1045-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1043+
// client should be initialized and if not just log the info to serial and abort :)
1044+
if(!isInitialized()) {
1045+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
10461046
return false;
10471047
}
10481048

@@ -1062,9 +1062,9 @@ boolean BytebeamArduino::printActionHandlerArray() {
10621062
}
10631063

10641064
boolean BytebeamArduino::resetActionHandlerArray() {
1065-
// client should be active and if not just log the info to serial and abort :)
1066-
if(!this->isClientActive) {
1067-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1065+
// client should be initialized and if not just log the info to serial and abort :)
1066+
if(!isInitialized()) {
1067+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
10681068
return false;
10691069
}
10701070

@@ -1074,9 +1074,9 @@ boolean BytebeamArduino::resetActionHandlerArray() {
10741074
}
10751075

10761076
boolean BytebeamArduino::publishActionCompleted(char* actionId) {
1077-
// client should be active and if not just log the info to serial and abort :)
1078-
if(!this->isClientActive) {
1079-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1077+
// client should be initialized and if not just log the info to serial and abort :)
1078+
if(!isInitialized()) {
1079+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
10801080
return false;
10811081
}
10821082

@@ -1096,9 +1096,9 @@ boolean BytebeamArduino::publishActionCompleted(char* actionId) {
10961096
}
10971097

10981098
boolean BytebeamArduino::publishActionFailed(char* actionId) {
1099-
// client should be active and if not just log the info to serial and abort :)
1100-
if(!this->isClientActive) {
1101-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1099+
// client should be initialized and if not just log the info to serial and abort :)
1100+
if(!isInitialized()) {
1101+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
11021102
return false;
11031103
}
11041104

@@ -1118,9 +1118,9 @@ boolean BytebeamArduino::publishActionFailed(char* actionId) {
11181118
}
11191119

11201120
boolean BytebeamArduino::publishActionProgress(char* actionId, int progressPercentage) {
1121-
// client should be active and if not just log the info to serial and abort :)
1122-
if(!this->isClientActive) {
1123-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1121+
// client should be initialized and if not just log the info to serial and abort :)
1122+
if(!isInitialized()) {
1123+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
11241124
return false;
11251125
}
11261126

@@ -1140,9 +1140,9 @@ boolean BytebeamArduino::publishActionProgress(char* actionId, int progressPerce
11401140
}
11411141

11421142
boolean BytebeamArduino::publishToStream(char* streamName, const char* payload) {
1143-
// client should be active and if not just log the info to serial and abort :)
1144-
if(!this->isClientActive) {
1145-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1143+
// client should be initialized and if not just log the info to serial and abort :)
1144+
if(!isInitialized()) {
1145+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
11461146
return false;
11471147
}
11481148

@@ -1169,9 +1169,9 @@ boolean BytebeamArduino::publishToStream(char* streamName, const char* payload)
11691169
}
11701170

11711171
boolean BytebeamArduino::end() {
1172-
// client should be active and if not just log the info to serial and abort :)
1173-
if(!this->isClientActive) {
1174-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1172+
// client should be initialized and if not just log the info to serial and abort :)
1173+
if(!isInitialized()) {
1174+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
11751175
return false;
11761176
}
11771177

@@ -1247,9 +1247,9 @@ boolean BytebeamArduino::end() {
12471247
}
12481248

12491249
boolean BytebeamArduino::enableOTA() {
1250-
// client should be active and if not just log the info to serial and abort :)
1251-
if(!this->isClientActive) {
1252-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1250+
// client should be initialized and if not just log the info to serial and abort :)
1251+
if(!isInitialized()) {
1252+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
12531253
return false;
12541254
}
12551255

@@ -1277,9 +1277,9 @@ boolean BytebeamArduino::end() {
12771277
}
12781278

12791279
boolean BytebeamArduino::isOTAEnabled() {
1280-
// client should be active and if not just log the info to serial and abort :)
1281-
if(!this->isClientActive) {
1282-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1280+
// client should be initialized and if not just log the info to serial and abort :)
1281+
if(!isInitialized()) {
1282+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
12831283
return false;
12841284
}
12851285

@@ -1288,9 +1288,9 @@ boolean BytebeamArduino::end() {
12881288
}
12891289

12901290
boolean BytebeamArduino::disableOTA() {
1291-
// client should be active and if not just log the info to serial and abort :)
1292-
if(!this->isClientActive) {
1293-
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam client is not initialized.");
1291+
// client should be initialized and if not just log the info to serial and abort :)
1292+
if(!isInitialized()) {
1293+
BytebeamLogger::Error(__FILE__, __func__, "Bytebeam Client is not Initialized.");
12941294
return false;
12951295
}
12961296

src/BytebeamArduino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class BytebeamArduino : private PubSubClient,
100100
BytebeamLogger::DebugLevel level = BytebeamLogger::LOG_WARN);
101101
#endif
102102

103-
boolean isInitialized();
104103
boolean loop();
105104
boolean isConnected();
106105
boolean handleActions(char* actionReceivedStr);
@@ -138,6 +137,7 @@ class BytebeamArduino : private PubSubClient,
138137
boolean setupBytebeamClient();
139138
void clearBytebeamClient();
140139
boolean init(const deviceConfigFileSystem fileSystem, const char* fileName);
140+
boolean isInitialized();
141141

142142
// private variables
143143
int mqttPort;

0 commit comments

Comments
 (0)