0

HOWTO: BT Pairing, Phone book syncing, SIM800's File system
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

HOWTO: BT Pairing, Phone book syncing, SIM800's File system

by frooty4adafruit on Fri Sep 16, 2016 9:47 pm

Hi, Everybody! A helpful suggestion for anyone looking to store phone numbers (or anything else)-- forget using an SD card! The SIM800's file directory can be (in)directly accessed. I was able to synch my personal phone's contact list (~15k) onto the device.

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!
Last edited by frooty4adafruit on Mon Feb 19, 2018 8:53 pm, edited 6 times in total.

frooty4adafruit
 
Posts: 40
Joined: Tue Sep 29, 2015 2:27 am

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by adafruit2 on Mon Sep 19, 2016 4:48 pm

huh interesting!

adafruit2
Site Admin
 
Posts: 18321
Joined: Fri Mar 11, 2005 7:36 pm

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by daderaide on Tue Oct 04, 2016 7:41 pm

Thanks for this! It worked great for me although I didn't do the phonebook stuff yet. I've got the bluetooth set up and working though. For those that are really new to programming like me, I wanted to add that I also had to add this line to the Adafruit_FONA.h file.

boolean sendRawCommand(char* com);

Once I put all three of those entries into their respective locations, it compiled and I was able to send AT commands. There is a lot of good information in the SIM800 bluetooth application note. I needed to change the connection mode and those commands are listed in there.

EDIT: I just realized that although this was fun to experiment with, it's pretty much unnecessary to add this extra code. All you have to to so hit "S" for a serial pass through and you can send commands directly to the SIM800 and bypass the test program.

daderaide
 
Posts: 3
Joined: Tue Oct 04, 2016 7:35 pm

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by frooty4adafruit on Wed Oct 05, 2016 7:12 pm

Glad you found this helpful, and thanks for the 'serial' tip! There is a *ton* of stuff you can do with the SIM800h; I'm going through all the supplemental documentation and seeing what works..

FYI on the phone book-- The documentation is a bit contradictory in that in some places it says you can dial out directly from the phonebook and in other places it says this functionality is not available. I haven't tried it yet, so I dunno. In any case, you can always have your code parse the phonebook and indirectly dial the numbers there.

PS: Sorry about not including the .h file changes-- I didn't consider new programmers.

frooty4adafruit
 
Posts: 40
Joined: Tue Sep 29, 2015 2:27 am

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by sys_spud on Mon Nov 14, 2016 11:52 am

In the SIM800 Application Note v1.04, there's a phonebook command to return name by number, or number by name:
Code: Select all | TOGGLE FULL SIZE
AT+CPBFEX=1, "xxxxxxxxx"     (Return number by supplied name lookup)
AT+CPBFEX=0, nnnnnnnnnn    (Return name by supplied number)


I tried this from the Fona Test sketch serial pass-thru, and it does work. I haven't used it in a sketch yet.

Hope this helps...

sys_spud
 
Posts: 23
Joined: Sun Aug 31, 2008 9:34 pm

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by cry4brk on Mon Nov 14, 2016 6:43 pm

sys_spud wrote:In the SIM800 Application Note v1.04, there's a phonebook command to return name by number, or number by name:
Code: Select all | TOGGLE FULL SIZE
AT+CPBFEX=1, "xxxxxxxxx"     (Return number by supplied name lookup)
AT+CPBFEX=0, nnnnnnnnnn    (Return name by supplied number)


I tried this from the Fona Test sketch serial pass-thru, and it does work. I haven't used it in a sketch yet.

Hope this helps...


This one is useful if you want to check if the senders number is saved on the sim, than replay to sms if not the number is not ADMIN number. Could save a lot of flash and ram space used to store admins phone numbers. Thank you.

cry4brk
 
Posts: 174
Joined: Tue Oct 09, 2012 3:14 pm

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by sys_spud on Wed Nov 23, 2016 11:46 pm

Hi All-

I added a blog post/tutorial on how to load records for the iPhone (couple of gotchas) and link to an example sketch showing how to retrieve "N" number of records. The sketch parses out the name and number. Crude, but may be useful....

Check out: http://thisoldgeek.blogspot.com/2016/11/sim800-bluetooth-sync-iphone-contacts.html Link to download the example sketch from github is in the post.

Hope this helps....

sys_spud
 
Posts: 23
Joined: Sun Aug 31, 2008 9:34 pm

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by frooty4adafruit on Thu Nov 24, 2016 9:18 am

That's great! Perhaps you could add a line about dialing directly from the phonebook..?

Code: Select all | TOGGLE FULL SIZE
ATD>1;

This will dial the 1st entry in the phonebook.

frooty4adafruit
 
Posts: 40
Joined: Tue Sep 29, 2015 2:27 am

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by Frostedfocus on Mon Dec 05, 2016 4:14 am

I have tried to activate the tunnel and then send a raw AT command and all i get in return is ERROR.
I have also tried modifying the code in the 3 diffrent places as suggested but my code doesnt want to load up then.

Does anybody know why this is happening.

Thanks

Frostedfocus
 
Posts: 6
Joined: Thu Nov 24, 2016 3:37 am

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by Frostedfocus on Mon Dec 05, 2016 6:17 am

Great i finnaly figured everything out, i have my laptop connected aswel as my phone with 2 other fona's in a bluetooth network, im busy working on home automation and the system is showing progress on screen sharing and music and call control and then there is the option of the phonebook loaded up onto the system

Frostedfocus
 
Posts: 6
Joined: Thu Nov 24, 2016 3:37 am

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by smiletec on Tue Jun 06, 2017 12:58 pm

@frostedfocus
Can you share a link that will assist me in such deep understanding? Am working on my final year project and it has to do with a whole lot of these...I will be glad you did

smiletec
 
Posts: 1
Joined: Tue Jun 06, 2017 12:54 pm

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by frooty4adafruit on Tue Jun 06, 2017 1:25 pm

@smiletec,

Give me a shout if you need a hand, too. I've been knee-deep in 3G/Bluetooth/Wifi IoT integration for a couple years now. Lots of battle scars! :D

frooty4adafruit
 
Posts: 40
Joined: Tue Sep 29, 2015 2:27 am

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by kokkerud on Sat Jan 20, 2018 11:39 am

works well with feather fona u4 and Samsung galaxy s7

kokkerud
 
Posts: 2
Joined: Sat Jan 20, 2018 11:35 am

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by simeonjmcg on Sun Feb 18, 2018 5:16 pm

I am using the FONA feather, and I got as far as the AT+BTPAIR 0,1, but when I confirm pairing on my phone, I get "Couldn't pair with SIM800H because of an incorrect PIN or passkey." This is regardless of whether I initiate pairing from FONA via serial console, or if I initiate via my phone. I've even tried to pair using my laptop's Bluetooth, but that also did not work. Anyone have any ideas?

simeonjmcg
 
Posts: 2
Joined: Sun Feb 18, 2018 4:18 pm

Re: HOWTO: BT Pairing, Phone book syncing, SIM800's File sy

by frooty4adafruit on Sun Feb 18, 2018 6:36 pm

Try:

AT+BTPAIRCFG=2

This sets pairing to automatic. More data here:

http://mt-system.ru/sites/default/files ... _v1.04.pdf

frooty4adafruit
 
Posts: 40
Joined: Tue Sep 29, 2015 2:27 am

Please be positive and constructive with your questions and comments.