Apparently, one can also create and modify any files in the SIM's directory..
To pair my phone I issued a raw AT commands, piggy-backing off of the Adafruit FONA library's "getReply(.)" method in the Adafruit_FONA.cpp file and added my own method:
- Code: Select all | TOGGLE FULL SIZE
boolean Adafruit_FONA::sendRawCommand(char* com){
getReply(com,FONA_DEFAULT_TIMEOUT_MS);
return true;
}
Don't forget to add the method declaration to the class declaration in Adafruit_FONA.h:
- Code: Select all | TOGGLE FULL SIZE
boolean sendRawCommand(char* com);
Finally, I added a 'z' selection to the FONATest.cpp, allowing me to send raw AT Commands:
- Code: Select all | TOGGLE FULL SIZE
case 'z':{
char number[30];
flushSerial();
Serial.print(F("send AT Command"));
readline(number, 30);
Serial.println("Sending: ");
Serial.println(number);
fona.sendRawCommand(number);
break;
}
These are the commands I sent to the phone to pair it, connect to the phonebook service, and download the contact list:
0.) AT+BTPAIRCFG=2
This sets the bluetooth to automatic pairing mode.
1.) AT+BTSCAN=1
This will scan for all devices in range. It will return a list of devices to pair. My phone was device number 2. (X's obscure the device ID).
FONA Response: BTSCAN: 0,2,"SAMSUNG-SM-N920A",XX:XX:XX:XX:XX:XX,-80
2.) AT+BTPAIR=0,1
This will pair with device #2 (my phone).
FONA Response: +BTPAIR: 2,"SAMSUNG-SM-N920A",XX:XX:XX:XX:XX:XX
3.) AT+BTGETPROF=2
This will get the profile services provided by my phone, device #2.
FONA Response:
+BTGETPROF: 10,"PBAP"
+BTGETPROF: 1,"A2DP(Source)"
+BTGETPROF: 2,"HFP(AG)"
+BTGETPROF: 8,"AVRCP(Target)"
4.) AT+BTCONNECT=2,10
This connects the SIM800 to my phone (#2) to service #10, PBAP, the phonebook service.
FONA Response: +BTCONNECT: 1,"SAMSUNG-SM-N920A",XX:XX:XX:XX:XX:XX,"PBAP(C)"
5.) AT+BTPBSYNC=0,1,0
This syncs my contact list with the SIM800, but doesn't store it in permanently in the file system yet. It took a few seconds for the response.
FONA Response: +BTPBSYNC: 0,0,15046
6.) AT+BTPBSYNC=1,1,0,0
I *think* this transfers the file that was downloaded in step number 5 and pushes to the directory. I dunno, maybe somebody can clarify what's happening here. I think it's necessary.
FONA Response: +BTPBSYNC: 1,0,135,0
It looks like 135 records were transferred.
7.) AT+FSDRIVE=0
Set the file system drive to zero, the local drive.
FONA Response: +FSDRIVE : C
8.) AT+LSFS="C:\User\BT\"
Check out the directory to find the phone book file.
FONA Response: remotePb1.txt
There is one file in the directory. That's the phonebook!
9.) AT+FSREAD="C:\User\BT\remotePb1.txt",1,1024,0
This reads the first 1024 characters, starting at position zero.
I'm not gonna show the results, because the FONA returned VCards representing all of my contacts!
This is cool stuff and looks like it could set the foundation for a new Bluetooth FONA library..!? There are lots more things that can be done in the file system-- you can create any directory or file you like. I think this is a great alternative to worrying about using an external SD card for storage, or managing EEPROM on the device yourself. At least there is a file system.
Hope you found this helpful!