Samsung Rugby 4 and Linux
2018.04.24


1. About
2. Kermit (AT Commands)
3. Gammu
4. OBEX
5. Tips
    a. Best connection method - Samsung's Kies mode
    b. Creating compatible M4A files
6. Bugs
7. Reference

1. About
The Samsung Rugby 4 (SM-B780A) is a mobile flip phone with a USB 2 interface.  The phone also hosts a MicroSD memory slot  for additional storage up to 32GB.  The USB interface will act as a serial terminal if the Linux qcaux.ko kernel module is loaded.  (ie. Qualcomm USB Auxiliary Serial Port driver, creating a /dev/ttyACM0 device file.)  This phone also offers BlueTooth and WiFi interfaces, however I have not tried utilizing the below tasks with the BlueTooth or WiFi interfaces.  Although the BlueTooth interface should work with Gammu, BlueTooth transfer rates will be much slower than a wired connection.

    Operating System:  It maybe noted, this Samsung Rugby 4 maybe running Linux for an operating system, based on deducing the supported operating systems documented within the Intel Centrino Advanced-N 6230 Dual Band CPU (ie. Intel XMM6230 CPU) specifications; citing Microsoft Windows and Linux operating supported.  Samsung's website only states "OS: MMP / Samsung Proprietary" for this Rugby 4.  Samsung's proprietary operating system Bada was stated as being migrated to Tizen.  Comparison of the Rugby 4's icons seems to still resemble the Bada operating system.  However, these are merrily graphical in nature.  Samsung's notation for MMP may reference "Mondriaan Memory Protection".  AFTER SOME TIME, I realized the files contained within the filesystem are named in android.* notation, indicating an Android operating system.


2. Kermit (AT Commands)
My personal favorite serial communication tool is kermit.  Following is a configuration file.

File /home/roger/.kermrc

set modem type none
set line /dev/ttyACM0
set speed 115200
set carrier-watch off
log session ~/kermit/session.log


Connect the Samsung Rugby to your Linux computer via the USB interface and ensure the qcaux module is loaded, creating the /dev/ttyACM0 device file.  Start kermit via command line console and issue the connect command.  Once connected, issuing AT+CLAC will return a listing of supported AT Commands for your device.  Some commands are already documented on the Internet and some within Gammu source code.  (ie. AT+CPBR or PhoneBookRetrieve command)  Be aware some commands will restart the mobile device such as the AT+FSF prefixed commands.

*NOTE: Cheaper Samsung phones having a USB port (ie. Samsung Gusto 3) seem to disable AT Commands, or maybe just the Samsung Verizon (or CDMA) phones do not have AT Command support as they're using CDMA phone technology.  While GSM/GSPR (ie. AT&T) do provide AT Commands.


3. Gammu
Ensure the Linux Kernel qcaux module is loaded, creating the /dev/ttyACM0 device file and your user is within the appropriate group (eg. /etc/group) for accessing this device file.

NOTE: During early 12/2018, I recently tested my Samsung Rugby 4 using Gammu, and noticed "model=obex" seemed to provide the best functionality.  (Or it could have been "model=at", as I'm typing this from memory.)

[gammu]
port = /dev/ttyACM0
connection = at115200
;model=mobex
model = at
Logfile = /home/roger/tmp/gammu.log
Logformat = textall


Supposedly "model = mobex" is the Samsung OBEX protocol, but I was not able to successfully communicate with the Samsung Rugby 4 as of yet.  Seems only "model = at" works.

First, identify your connected phone.

$  gammu 0 identify
Device         : /dev/ttyACM0
Manufacturer   : Samsung
Model          : unknown (SM-B780A)
Firmware       : B780AUSOE3
IMEI           : 888888888888888


Return 1-20 phone book entries
$ gammu --getmemory ME 1 200

Backup all possible data
$ gammu 0 --backup /tmp/phonebook.log

Automatically backup all possible data
$ (echo no; echo ALL) | gammu --backup phonebook.log

Other gammu commands, such as Calendar and Tasks likely are not yet implemented with the Samsung Rugby.


4. OBEX

Recently I've found the Samsung Rugby supports Samsung's OBEX file system or something called mobex.  To activate OBEX mode via AT Commands, issue the  AT+SYNCML=MOBEXSTART command.  The protocol is documented within the samsyncro Google Code project and the documentation is titled "Documentation of the m-obex protocol used by some Samsung mobiles" and currently hosted as a Wiki page.  This is as far as I've gotten with this protocol.


5. Tips

    a. Seemingly the best protocol to set for the connection method of these phones is Samsung's Kies mode.  Set this as the default mode within the settings page of the device.  Kies mode allows both, AT Commands and the additional MicroSD storage to be utilized at the same time.

    b. Creating compatible M4A files.

        I had trouble creating Samsung playable files using FAAC, and had better success using FFmpeg.

       $ ffmpeg -i infile.wav -c:a libfdk_aac -cutoff 20000 -vbr 5 outfile.m4a
      
$ ffmpeg -i nokia-ring-ring-32bit-48000Hz-clipped.wav -c:a libfdk_aac -cutoff 20000 -vbr 5 nokia-ring-ring.m4a


6. Bugs

RESTRICTED FILENAME LENGTH
Took me a while to understand why some of my classical music was not being seen by the device even after verifying the files did exist on the MicroSD card, the device appears to be limiting filenames to less than 64 characters.  The only file system having such a requisite is the ISO 9660 or Juliet file systems.  As such I believe operating system on the device is mounting the MicroSD storage within a ISO9660 or Juliet emulation mode.  After ensuring all my classical filename's were all less than 64 characters, the device seemingly had no additional problems reading in all the file's metadata.

The following snippet allows you to easily find *.m4a files with file names greater than 64 characters and prints the file names to terminal.  From here, move or rename those files names by either; Removing duplicate words within the file name, Removing the chatter near the end of the file name, or Removing duplicate spaces or not needed punctuation.  Oddly, I found abcde.sh duplicating the track's name within the file name.  Less odd were the not needed duplicate punctuation marks or underscores.  Lastly if the previous did not shorten the name to less than 64 characters, removed some of the file name's ending chatter just prior to the three letter file type file suffix.

# Find file name lengths less/greater than size
$ find . -type f -printf "%f\n" |grep m4a | awk 'length($0) > 64 { print NR ":" $0 }'

COVER/LID DISPLAY SCREEN BRIGHT WHITE LOGO SCREEN
Another nagging issue is the service provider AT&T startup logo/animation, and is also displayed on the outer display as a bright white screen whenever dialing a number.  Obviously Gammu only works with maintaining the animations and logos with Nokia phones, while also AT Commands seemed to not adequate for augmenting the animation or logo files.

ID3 FILENAME TAGS NOT UPDATING
The Samsung Rugby 4 seems to prefer ID3v1 and/or ID3v2.3 (id3lib via EasyTag) tags.  Problems seem to occur when using ID3v2.4 (libid3tag via EasyTag) tags.  When an MP3 file provides both ID3v1 (end of file) and ID3v2.3 (start of file) tags, the device may use either.  The device displays the "Audiobook" Genre when using ID3v2.3 tags, and only displays "Unknown" when using ID3v1 tags, or when using more than on tag versions.  If the users was using ID3v1 and ID3v2.4 and then reverted to using ID3v1 and ID3v2.3, the phone database may still revert to using only ID3v1.  Removing the battery may reset the database, giving preference to the later ID3v2.3 acceptable version.  The device's optimal ID3 tag version seems to be ID3v2.3 as the ID3v2.3 version does successfully print the Audiobook Genre instead of unknown Genre when using ID3v1.  (ID3v2.4 seems to send all tags into unknown fields.)

Seems the phone operating system only updates certain ID3 tags only once during the initial file import/transfer to the phone.  (ie. I presume these are the sort fields, such as Album and Genre contained within a separate sorting database, while apparently updating the file name tag only?)  Once the user fixes the filename lengths to less than 16 bytes as noted above, users now have to contend with this bug for their MP3 (or music) files.  Removing the battery seems to alleviate some of these issues, but the phone's date and time information requires manual updating as well as other settings afterwards.  The best fix is to attach the device to a computer using a USB cable and port capable of supplying backup power while removing the back case and battery to gain access to the MicroSD card.  Remove the MicroSD card and reinsert the battery.  Power on the device, and may require the USB cord to be removed.  (The device gets buggy at this point, as you'll be presented with a large battery power charging icon with the device defaulting to powered off.)  Once the device is powered back on and you have verified the MP3 player's database is empty of entries, repeat the process and instead reinsert the MicroSD card.  Upon the device's restart and database initialization, you'll hopefully find your MP3 ID3 tags are now showing.

The likely reason for this bug, the sorting database for files with ID3 tags is located on the phone memory.  In order to force a rescan, the device has to see the files have changed, and the only method to do this is by removing and reinserting the MicroSD memory card.  (ie. See the file properties, file added date.)

7. Reference
AT Commands Reference Guide  (AT_Commands_Reference_Guide_r0.pdf)
Commands in SCH-A890 (http://es.edaboard.com/topic-371460.0.html)
SamsungS105v1_6h.txt (http://gatling.ikk.sztaki.hu/~kissg/gsm/atscan/unprocessed/SamsungS105v1_6h.txt)
BitPIM development files and forums contains AT Commands for Samsung phones.