2015年11月23日 星期一

CC2640 vs CC2541


1. compare CC2640 and CC254x.
http://referencedesigner.com/blog/ti-cc2640-vs-cc2540-ble/2506/

2. Compare CC26xx and Nordic nrf52832
http://referencedesigner.com/blog/ti-cc2650-cc2640-vs-nordic-nrf52832/2489/

3. The difference between CC2640 and CC2650:

Q: What is the difference between CC2640 and CC2650?

The multi-standard CC2650 wireless MCU supports BLE as well as other wireless protocols, such as 802.15.4. The CC2640 supports Bluetooth Low Energy only. All code generated from the BLE-Stack 2.0 SDK is binary compatible with both the CC2650 & CC2640. Additionally, IDE project configuration settings in the BLE-Stack v2.0 SDK for CC2650 & CC2640 are cross-compatible; however, it is strongly recommended to not change the CPU settings in the IDE. Although the CC2650 has the HW & ROM capability to support additional wireless protocols, a given SW build can only support one wireless protocol. from TI BLE wiki.
4. TI engineer answer:
https://e2e.ti.com/support/wireless_connectivity/f/538/p/417820/1486886#1486886
1) Basically because the radio is totally redesigned. 
2) This is just because the modern ARM processors are more efficient than the old 8051. Additionally we are using new production process, new technology, etc. Adding a built-in DCDC regulator also increases efficiency. Keep in mind though, that none of the numbers in the datasheet are for running both cores simultaneously. 
3) You are correct on CC2640CC2541 will not be able to fulfill all of 4.1 due to RAM limitations.
4) How many BLE devices may handle the cc2640? There was a limit of.... 3 (AFAIR) in cc2541
Our current number is 8
5) Everything is faster in the CC2640 compared to the CC2541. Really.
6) The CC2541 will still be supported by us. We also plan to update the BLE stack for CC254x to 1.4.1 this year. It you prefer a device that have been in the market for several years and is mature, and you can live with the current consumption and the 8051 core, the CC2541 is still a good part to use.
7) You can get the CC26xx SensorTag for $29 with a low cost debugger for just additional $15. Get a kit and check it out! 
from  

2015年11月5日 星期四

Android Studio - Study


Eclipse + plug-in Android ADT -->  Eclipse ADT bundle -> Android Studio
Good materials (Chinese)
http://www.sdk.tw/2014/12/android-sdk-android-studio.html

Download Android Studio 1.4.1 is about 1.2 GB.

There is a known issue about Tools.jar is not in Android Studio classpath.
Just change your JAVA_HOME to JDK path. The tools.jar is not in JRE but in JDK.

2015年11月3日 星期二

Connect cp2102 or FTDI to Android 3.1 +

The issue here is that the CP210x driver is not enabled in the Android kernel by default. So you will either need to build this driver in to your kernel to get the tty access and ability to use JavaComm.
The other option is to use the USB Host functionality and access your CP210x directly with it's API.
from Preston answered Dec 10 '13 at 15:19


Roger Clark 



The other people trying experience, still not work.
http://www.crifan.com/add_rts_and_dtr_support_for_silicon_labs_cp2102_in_usb_serial_for_android/

CP210x driver on Android 4.0.4
http://124.16.139.131:24080/lxr/source/kernel/omap/drivers/usb/serial/cp210x.c?v=android-4.0.4


It works if your Android kernel support CP210x or FTDI driver by using this App.
"USB Serial Terminal Lite"
https://play.google.com/store/apps/details?id=com.oneman.freeusbtools&hl=zh_TW


6/26/14




Ok.

Eventually solved my own problem.

When I imported the projects into Eclipse, the default Java Build path -> Source   location settings are are for /src and /gen
However the project sources for this are in /java/src/...

So I've moved the files into /src as this seem to be the default (possibly current best practice ???) - as I said, I'm new to Android dev, so I'm not sure what the norms are, but when you create an empty project in the latest version of Eclipse it puts the source files in /src

The issue of the library name was just syntax, i.e the project can be renamed in Eclipse from "main" to USBSerialLibrary using the Refactor -> Rename command.

The stuff in the HowTo about linking the library seems to be out of date as well. As far as I can see (and it works for me in Eclipse ADT  v22.6.2-1085508), is just to add the USBSerialLibrary project as a library to the Android setting in Properties.

BTW. I seem to need to compile as Android 4.2.2 because of a reference to JELLYBEAN in the code

I'm also getting lots of warnings, but normally isn't good news, however the only ones that probably needs to be dealt with in the long term is that

import android.widget.TwoLineListItem;

appears to be deprecated.

Anyway, I hope this helps anyone else just starting out on this journey ;-)

2015年10月5日 星期一

Javascript note

1. Older examples may use a type attribute: <script type="text/javascript">
    The type attribute is not required. JavaScript is the default scripting language in HTML. (from W3school).
2. Script function can put any where such as <body> or <head>.
    Keeping all code in one place, is always a good habit. 
    It is a good idea to place scripts at the bottom of the <body> element.
    This can improve page load, because HTML display is not blocked by scripts loading.
    (from W3school).
3. external file by using .js
  <script src="myScript.js"></script>

    The advantages: (from W3school)
  • It separates HTML and code
  • It makes HTML and JavaScript easier to read and maintain
  • Cached JavaScript files can speed up page loads
4. Display functions:

  • Writing into an alert box, using window.alert().
  • Writing into the HTML output using document.write().
  • Writing into an HTML element, using innerHTML.
  • Writing into the browser console, using console.log().
5. 

Max bonding number of TI CC2541

Below is from TI forum discussion:

Excess pairings over 10 are not stored (bond table is full). You will enter a successful connection.

In the bond manager when a new bond is to be stored, if bondIdx in the below code snippet is equal to GAP_BONDINGS_MAX then the bond will not be stored and the next time you connect you will have to repeat the pairing process over again.

// First see if we already have an existing bond for this device
bondIdx = gapBondMgrFindAddr( pBondRec->publicAddr );
if ( bondIdx >= GAP_BONDINGS_MAX )
{
bondIdx = gapBondMgrFindEmpty();
}


from https://e2e.ti.com/support/wireless_connectivity/f/538/t/388554


The white list for CC2540 and CC2541 has a maximum of 8 entries.
https://e2e.ti.com/support/wireless_connectivity/f/538/p/182903/1111969#1111969

Other Bluetooth connection limitation issue:
http://superuser.com/questions/332767/limit-to-the-number-of-devices-that-can-be-paired-with-a-bluetooth-device
Sony up to nine:
https://us.en.kb.sony.com/app/answers/detail/a_id/39047/~/what-is-the-maximum-number-of-bluetooth-wireless-devices-that-can-be-paired%3F

Provide some solution for fix the probelm.
such as FIFO loop to saving Key. 
https://e2e.ti.com/support/wireless_connectivity/f/538/p/458133/1654011


bcomdef.h
/** @defgroup BLE_NV_IDS BLE Non-volatile IDs
 * @{
 */
// Device NV Items -    Range 0 - 0x1F
#define BLE_NVID_IRK                    0x02  //!< The Device's IRK
#define BLE_NVID_CSRK                   0x03  //!< The Device's CSRK
#define BLE_NVID_SIGNCOUNTER            0x04  //!< The Device's Sign Counter

// Bonding NV Items -   Range  0x20 - 0x5F    - This allows for 10 bondings
#define BLE_NVID_GAP_BOND_START         0x20  //!< Start of the GAP Bond Manager's NV IDs
#define BLE_NVID_GAP_BOND_END           0x5f  //!< End of the GAP Bond Manager's NV IDs Range

// GATT Configuration NV Items - Range  0x70 - 0x79 - This must match the number of Bonding entries
#define BLE_NVID_GATT_CFG_START         0x70  //!< Start of the GATT Configuration NV IDs
#define BLE_NVID_GATT_CFG_END           0x79  //!< End of the GATT Configuration NV IDs

//----------could add for saving counter to deal with FIFO bonding info
// Customer NV Items - Range  0x80 - 0x8F - This must match the number of Bonding entries
#define BLE_NVID_CUST_START             0x80  //!< Start of the Customer's NV IDs
#define BLE_NVID_CUST_END               0x8F  //!< End of the Customer's NV IDs

/** @} End BLE_NV_IDS */

ti_51ew_cc2540b.xcl
// Internal flash used for NV address space.
// ---------------------------
//
// Address range for HAL_FLASH_PAGE_SIZE == 2048
-D_BLENV_ADDRESS_SPACE_START=0x7E800
-D_BLENV_ADDRESS_SPACE_END=0x7F7FF
//
// Address range for HAL_FLASH_PAGE_SIZE == 4096
//-D_BLENV_ADDRESS_SPACE_START=0x7D000

//-D_BLENV_ADDRESS_SPACE_END=0x7EFFF


http://www.deyisupport.com/question_answer/wireless_connectivity/bluetooth/f/103/t/48352.aspx
注意下面的表述,也就是说2K,1K存数据,另1K是做备份。
The main reason for SNV is that it's only possible to erase a page, and not a small area of flash.  As you re-write a SNV data item, the SNV will create a new space for it and write it. The old space will be marked as invalid, and will become free again when that page is erased.  There is only one active page and then a mirror page where the valid items are copied to when the page gets full. I think the max size for everything in SNV is 1K (minus about 250K for bonding info).


How to implement saving FIFO bonding info to unlimit GAP_BONDINGS_LIMIT 10, could refer the above URL.
It add counter by using BLE_NVID_CUST_START to record the FIFO index, but it suggests to implement in the connection_terminate. I think it will have problem if bonding done at connection, you will never do the FIFO counter if power off the device before terminate connection event does.
Another way is add main.c to check bonding if full then clear one space for next bonding process. By this way, could add bonding counter to handle this.

OSAL API note:
There are some important considerations when using this API: 
1. These are blocking function calls and an operation may take several milliseconds to complete. This is especially true for NV write operations. In addition, interrupts may be disabled for several milliseconds. It is best to execute these functions at times when they do not conflict with other timing-critical operations. For example, a good time to write NV items would be when the receiver is turned off. 
2. Try to perform NV writes infrequently. It takes time and power; also most flash devices have a limited number of erase cycles. 
3. If the structure of one or more NV items changes, especially when upgrading from one version of a TI stack software to another, it is necessary to erase and re-initialize the NV memory. Otherwise, read and write operations on NV items that changed will fail or produce erroneous results.