1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Run new astyle formatter against all the examples

This commit is contained in:
Federico Fissore
2013-10-21 09:58:40 +02:00
parent 3c6ee46828
commit b4c68b3dff
259 changed files with 5160 additions and 5217 deletions

View File

@ -1,19 +1,19 @@
/*
This example enables you to change or remove the PIN number of
This example enables you to change or remove the PIN number of
a SIM card inserted into a GSM shield.
Circuit:
* GSM shield
* SIM card
Created 12 Jun 2012
by David del Peral
This example code is part of the public domain
This example code is part of the public domain
http://arduino.cc/en/Tutorial/GSMToolsPinManagement
*/
// libraries
@ -39,32 +39,32 @@ void setup()
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Change PIN example\n");
PINManager.begin();
// check if the SIM have pin lock
while(!auth){
while (!auth) {
int pin_query = PINManager.isPIN();
if(pin_query == 1)
if (pin_query == 1)
{
// if SIM is locked, enter PIN code
Serial.print("Enter PIN code: ");
user_input = readSerial();
// check PIN code
if(PINManager.checkPIN(user_input) == 0)
if (PINManager.checkPIN(user_input) == 0)
{
auth = true;
PINManager.setPINUsed(true);
Serial.println(oktext);
}
else
{
{
// if PIN code was incorrected
Serial.println("Incorrect PIN. Remember that you have 3 opportunities.");
}
}
else if(pin_query == -1)
else if (pin_query == -1)
{
// PIN code is locked, user must enter PUK code
Serial.println("PIN locked. Enter PUK code: ");
@ -72,7 +72,7 @@ void setup()
Serial.print("Now, enter a new PIN code: ");
user_input = readSerial();
// check PUK code
if(PINManager.checkPUK(puk, user_input) == 0)
if (PINManager.checkPUK(puk, user_input) == 0)
{
auth = true;
PINManager.setPINUsed(true);
@ -84,32 +84,32 @@ void setup()
Serial.println("Incorrect PUK or invalid new PIN. Try again!.");
}
}
else if(pin_query == -2)
else if (pin_query == -2)
{
// the worst case, PIN and PUK are locked
Serial.println("PIN & PUK locked. Use PIN2/PUK2 in a mobile phone.");
while(true);
while (true);
}
else
{
// SIM does not requires authetication
// SIM does not requires authetication
Serial.println("No pin necessary.");
auth = true;
}
}
// start GSM shield
Serial.print("Checking register in GSM network...");
if(PINManager.checkReg() == 0)
if (PINManager.checkReg() == 0)
Serial.println(oktext);
// if you are connect by roaming
else if(PINManager.checkReg() == 1)
Serial.println("ROAMING " + oktext);
else if (PINManager.checkReg() == 1)
Serial.println("ROAMING " + oktext);
else
{
// error connection
Serial.println(errortext);
while(true);
while (true);
}
}
@ -118,19 +118,19 @@ void loop()
// Function loop implements pin management user menu
// Only if you SIM use pin lock, you can change PIN code
// user_op variables save user option
Serial.println("Choose an option:\n1 - On/Off PIN.");
if(PINManager.getPINUsed())
if (PINManager.getPINUsed())
Serial.println("2 - Change PIN.");
String user_op = readSerial();
if(user_op == "1")
if (user_op == "1")
{
Serial.println("Enter your PIN code:");
user_input = readSerial();
// activate/deactivate PIN lock
PINManager.switchPIN(user_input);
}
else if(user_op == "2" & PINManager.getPINUsed())
else if (user_op == "2" & PINManager.getPINUsed())
{
Serial.println("Enter your actual PIN code:");
String oldPIN = readSerial();
@ -152,7 +152,7 @@ void loop()
String readSerial()
{
String text = "";
while(1)
while (1)
{
while (Serial.available() > 0)
{
@ -161,7 +161,7 @@ String readSerial()
{
return text;
}
if(inChar!='\r')
if (inChar != '\r')
text += inChar;
}
}