BLE demo for mbed Ported RunningElectronics's SBDBT firmware for BLE. It can communicate with iOS

Dependencies:   FatFileSystem mbed

Fork of BTstack by Norimasa Okamoto

Committer:
todotani
Date:
Wed Feb 20 14:18:38 2013 +0000
Revision:
6:cf06ba884429
Parent:
1:6078e430af82
Change tick timer to 1ms. Change attribute 0xFFF1 as read of DigitalIn p5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
todotani 1:6078e430af82 1 /*
todotani 1:6078e430af82 2 * Copyright (C) 2010 by Matthias Ringwald
todotani 1:6078e430af82 3 *
todotani 1:6078e430af82 4 * Redistribution and use in source and binary forms, with or without
todotani 1:6078e430af82 5 * modification, are permitted provided that the following conditions
todotani 1:6078e430af82 6 * are met:
todotani 1:6078e430af82 7 *
todotani 1:6078e430af82 8 * 1. Redistributions of source code must retain the above copyright
todotani 1:6078e430af82 9 * notice, this list of conditions and the following disclaimer.
todotani 1:6078e430af82 10 * 2. Redistributions in binary form must reproduce the above copyright
todotani 1:6078e430af82 11 * notice, this list of conditions and the following disclaimer in the
todotani 1:6078e430af82 12 * documentation and/or other materials provided with the distribution.
todotani 1:6078e430af82 13 * 3. Neither the name of the copyright holders nor the names of
todotani 1:6078e430af82 14 * contributors may be used to endorse or promote products derived
todotani 1:6078e430af82 15 * from this software without specific prior written permission.
todotani 1:6078e430af82 16 *
todotani 1:6078e430af82 17 * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
todotani 1:6078e430af82 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
todotani 1:6078e430af82 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
todotani 1:6078e430af82 20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
todotani 1:6078e430af82 21 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
todotani 1:6078e430af82 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
todotani 1:6078e430af82 23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
todotani 1:6078e430af82 24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
todotani 1:6078e430af82 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
todotani 1:6078e430af82 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
todotani 1:6078e430af82 27 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
todotani 1:6078e430af82 28 * SUCH DAMAGE.
todotani 1:6078e430af82 29 *
todotani 1:6078e430af82 30 */
todotani 1:6078e430af82 31
todotani 1:6078e430af82 32 /*
todotani 1:6078e430af82 33 * sdp_util.h
todotani 1:6078e430af82 34 */
todotani 1:6078e430af82 35
todotani 1:6078e430af82 36 #pragma once
todotani 1:6078e430af82 37
todotani 1:6078e430af82 38 #include <stdint.h>
todotani 1:6078e430af82 39
todotani 1:6078e430af82 40 #if defined __cplusplus
todotani 1:6078e430af82 41 extern "C" {
todotani 1:6078e430af82 42 #endif
todotani 1:6078e430af82 43
todotani 1:6078e430af82 44 typedef enum {
todotani 1:6078e430af82 45 DE_NIL = 0,
todotani 1:6078e430af82 46 DE_UINT,
todotani 1:6078e430af82 47 DE_INT,
todotani 1:6078e430af82 48 DE_UUID,
todotani 1:6078e430af82 49 DE_STRING,
todotani 1:6078e430af82 50 DE_BOOL,
todotani 1:6078e430af82 51 DE_DES,
todotani 1:6078e430af82 52 DE_DEA,
todotani 1:6078e430af82 53 DE_URL
todotani 1:6078e430af82 54 } de_type_t;
todotani 1:6078e430af82 55
todotani 1:6078e430af82 56 typedef enum {
todotani 1:6078e430af82 57 DE_SIZE_8 = 0,
todotani 1:6078e430af82 58 DE_SIZE_16,
todotani 1:6078e430af82 59 DE_SIZE_32,
todotani 1:6078e430af82 60 DE_SIZE_64,
todotani 1:6078e430af82 61 DE_SIZE_128,
todotani 1:6078e430af82 62 DE_SIZE_VAR_8,
todotani 1:6078e430af82 63 DE_SIZE_VAR_16,
todotani 1:6078e430af82 64 DE_SIZE_VAR_32
todotani 1:6078e430af82 65 } de_size_t;
todotani 1:6078e430af82 66
todotani 1:6078e430af82 67 // UNIVERSAL ATTRIBUTE DEFINITIONS
todotani 1:6078e430af82 68 #define SDP_ServiceRecordHandle 0x0000
todotani 1:6078e430af82 69 #define SDP_ServiceClassIDList 0x0001
todotani 1:6078e430af82 70 #define SDP_ServiceRecordState 0x0002
todotani 1:6078e430af82 71 #define SDP_ServiceID 0x0003
todotani 1:6078e430af82 72 #define SDP_ProtocolDescriptorList 0x0004
todotani 1:6078e430af82 73 #define SDP_BrowseGroupList 0x0005
todotani 1:6078e430af82 74 #define SDP_LanguageBaseAttributeIDList 0x0006
todotani 1:6078e430af82 75 #define SDP_ServiceInfoTimeToLive 0x0007
todotani 1:6078e430af82 76 #define SDP_ServiceAvailability 0x0008
todotani 1:6078e430af82 77 #define SDP_BluetoothProfileDescriptorList 0x0009
todotani 1:6078e430af82 78 #define SDP_DocumentationURL 0x000a
todotani 1:6078e430af82 79 #define SDP_ClientExecutableURL 0x000b
todotani 1:6078e430af82 80 #define SDP_IconURL 0x000c
todotani 1:6078e430af82 81 #define SDP_AdditionalProtocolDescriptorList 0x000d
todotani 1:6078e430af82 82 #define SDP_SupportedFormatsList 0x0303
todotani 1:6078e430af82 83
todotani 1:6078e430af82 84 // SERVICE CLASSES
todotani 1:6078e430af82 85 #define SDP_OBEXObjectPush 0x1105
todotani 1:6078e430af82 86 #define SDP_OBEXFileTransfer 0x1106
todotani 1:6078e430af82 87 #define SDP_PublicBrowseGroup 0x1002
todotani 1:6078e430af82 88
todotani 1:6078e430af82 89 // PROTOCOLS
todotani 1:6078e430af82 90 #define SDP_SDPProtocol 0x0001
todotani 1:6078e430af82 91 #define SDP_UDPProtocol 0x0002
todotani 1:6078e430af82 92 #define SDP_RFCOMMProtocol 0x0003
todotani 1:6078e430af82 93 #define SDP_OBEXProtocol 0x0008
todotani 1:6078e430af82 94 #define SDP_L2CAPProtocol 0x0100
todotani 1:6078e430af82 95
todotani 1:6078e430af82 96 // OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
todotani 1:6078e430af82 97 #define SDP_Offest_ServiceName 0x0000
todotani 1:6078e430af82 98 #define SDP_Offest_ServiceDescription 0x0001
todotani 1:6078e430af82 99 #define SDP_Offest_ProviderName 0x0002
todotani 1:6078e430af82 100
todotani 1:6078e430af82 101 // OBEX
todotani 1:6078e430af82 102 #define SDP_vCard_2_1 0x01
todotani 1:6078e430af82 103 #define SDP_vCard_3_0 0x02
todotani 1:6078e430af82 104 #define SDP_vCal_1_0 0x03
todotani 1:6078e430af82 105 #define SDP_iCal_2_0 0x04
todotani 1:6078e430af82 106 #define SDP_vNote 0x05
todotani 1:6078e430af82 107 #define SDP_vMessage 0x06
todotani 1:6078e430af82 108 #define SDP_OBEXFileTypeAny 0xFF
todotani 1:6078e430af82 109
todotani 1:6078e430af82 110 // MARK: DateElement
todotani 1:6078e430af82 111 void de_dump_data_element(uint8_t * record);
todotani 1:6078e430af82 112 int de_get_len(uint8_t *header);
todotani 1:6078e430af82 113 de_size_t de_get_size_type(uint8_t *header);
todotani 1:6078e430af82 114 de_type_t de_get_element_type(uint8_t *header);
todotani 1:6078e430af82 115 int de_get_header_size(uint8_t * header);
todotani 1:6078e430af82 116 void de_create_sequence(uint8_t *header);
todotani 1:6078e430af82 117 void de_store_descriptor_with_len(uint8_t * header, de_type_t type, de_size_t size, uint32_t len);
todotani 1:6078e430af82 118 uint8_t * de_push_sequence(uint8_t *header);
todotani 1:6078e430af82 119 void de_pop_sequence(uint8_t * parent, uint8_t * child);
todotani 1:6078e430af82 120 void de_add_number(uint8_t *seq, de_type_t type, de_size_t size, uint32_t value);
todotani 1:6078e430af82 121 void de_add_data( uint8_t *seq, de_type_t type, uint16_t size, uint8_t *data);
todotani 1:6078e430af82 122
todotani 1:6078e430af82 123 int de_get_data_size(uint8_t * header);
todotani 1:6078e430af82 124 void de_add_uuid128(uint8_t * seq, uint8_t * uuid);
todotani 1:6078e430af82 125
todotani 1:6078e430af82 126 // MARK: SDP
todotani 1:6078e430af82 127 uint16_t sdp_append_attributes_in_attributeIDList(uint8_t *record, uint8_t *attributeIDList, uint16_t startOffset, uint16_t maxBytes, uint8_t *buffer);
todotani 1:6078e430af82 128 uint8_t * sdp_get_attribute_value_for_attribute_id(uint8_t * record, uint16_t attributeID);
todotani 1:6078e430af82 129 uint8_t sdp_set_attribute_value_for_attribute_id(uint8_t * record, uint16_t attributeID, uint32_t value);
todotani 1:6078e430af82 130 int sdp_record_matches_service_search_pattern(uint8_t *record, uint8_t *serviceSearchPattern);
todotani 1:6078e430af82 131 int spd_get_filtered_size(uint8_t *record, uint8_t *attributeIDList);
todotani 1:6078e430af82 132 int sdp_filter_attributes_in_attributeIDList(uint8_t *record, uint8_t *attributeIDList, uint16_t startOffset, uint16_t maxBytes, uint16_t *usedBytes, uint8_t *buffer);
todotani 1:6078e430af82 133
todotani 1:6078e430af82 134 void sdp_create_spp_service(uint8_t *service, int service_id, const char *name);
todotani 1:6078e430af82 135
todotani 1:6078e430af82 136 #if defined __cplusplus
todotani 1:6078e430af82 137 }
todotani 1:6078e430af82 138 #endif