• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Low Power RF & Wireless Connectivity » Low Power RF Bluetooth® Low Energy & ANT Forum » "how to add a service" example for BLE keyfob
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

"how to add a service" example for BLE keyfob

"how to add a service" example for BLE keyfob

This question is answered
Rene Limberger
Posted by Rene Limberger
on Jan 12 2012 15:19 PM
Intellectual920 points

Hello!

Im working on small little hardware project based on the CC2540 and I'm starting off with the Keyfob demo app and slowly modify it for my hardware and application. 

I was wondering if someone could post a brief step-by-step guide on how to add a service to provide additional data from my hardware. there are a lot of files in the PROFILES directory and I'm not exactly sure where to add what.

specifically i want to add a service which provides a signed 16bit int (s16) value.

i was thinking of reusing one of the acceleration values (x for example) but that seems to be 8 bit only but i need 16 bit.

thanks in advance,

-r 

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • kazola
    Posted by kazola
    on Jan 12 2012 15:25 PM
    Guru10665 points

    I could try to do that but I'm not at work right now.

    Why don't you try to do a "ctrl+shift+F" on IAR and search the word "service"? If I do not remember wrong, it was quite easy to identify several info that could be interesting for you this way :)



    Please click the     Verify Answer     button on a post if it answers your question! :)

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Joakim Lindh
    Posted by Joakim Lindh
    on Jan 13 2012 04:12 AM
    Verified Answer
    Verified by Rene Limberger
    Genius13370 points

    Hi Rene,

    I'm gonna try to make this easy for you.

    I suggest that you take a look at the simpleGATTprofile (found at C:\Texas Instruments\BLE-CC2540-1.1a\Projects\ble\Profiles\SimpleProfile). You can copy, rename, modify and add to your keyfob project (Right-click on "PROFILES" in IAR and "Add files..."). After that you would have to add the new service by calling SimpleProfile_AddService( GATT_ALL_SERVICES ); (Or whatever you renamed the profile to) from the KeyFobApp_Init function.

    When it comes to modifying the profile, please have a look at the simpleBLEperipheral project to make sure that you understand. If you want to add peripheral hardware functionality just have a look at the accelerometer.c in the keyfob project.

    I hope I haven't confused you :) Go ahead and try, I'll be around if you get stuck.

    Br

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Rene Limberger
    Posted by Rene Limberger
    on Jan 13 2012 06:01 AM
    Intellectual920 points

    Thanks so much, will try these suggestions. 

    One follow up. Are GATT attributes always 8 bit or can they be 13 or even 32 bit? the code i looked at so far seems to only use 8bit gatt attribute values. i have some data that is 16 and other that is 32 bit so I'm wondering how i add an attribute to a service that has that many bits.

    thanks,

    -r

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Joakim Lindh
    Posted by Joakim Lindh
    on Jan 13 2012 08:49 AM
    Genius13370 points

    Interesting question, since the processor is a 8051 type, I guess 8 bit is the way to go here. If you want to store a 16 bit value in an attribute you could separate it, like this;

    static uint8 characteristicValue[2] = { 0, 0};

    characteristicValue[ 0 ] = HI_UINT16( your16BitData);

    characteristicValue[ 1 ] = LO_UINT16( your16BitData);

    I'm not into bits and bytes so maybe my suggestions is not the most optimized one, but it works.

    Br

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Flor
    Posted by Flor
    on Feb 15 2012 17:17 PM
    Intellectual260 points

    Hi Rene and TI team, 

    Did you were able to solve the issue of greater size values. I am adding a gyroscope to the system that has 16 bits and I am facing some problems...

    Please, let me know if I am right in this. 

    From the structure of attAttribute_t if I want to store a value of 16 bits I will need to store it divided in 8 bit pieces? 

    /* GATT Attribute format.
    */
    typedef struct attAttribute_t
    {
    gattAttrType_t type; //!< Attribute type (2 or 16 octet UUIDs)
    uint8 permissions; //!< Attribute permissions
    uint16 handle; //!< Attribute handle - assigned internally by attribute server
    uint8* const pValue; //!< Attribute value - encoding of the octet array is defined in
    //!< the applicable profile. The maximum length of an attribute
    //!< value shall be 512 octets.
    } gattAttribute_t;
    
    
    thanks in advance
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use