mbed base bard check program for BlueTooth USB dongle module (3 switches, 6 leds, I2C LCD, A/D)

Dependencies:   USBHost mbed

Fork of BTstack by Norimasa Okamoto

Committer:
tamaki
Date:
Mon Oct 17 00:25:18 2016 +0000
Revision:
3:7b7d1273e2d5
Parent:
0:1ed23ab1345f
mbed base bard check program
; for BlueTooth USB dongle module
; (3 switches, 6 leds, I2C LCD, A/D)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:1ed23ab1345f 1 /*
va009039 0:1ed23ab1345f 2 * Copyright (C) 2009-2012 by Matthias Ringwald
va009039 0:1ed23ab1345f 3 *
va009039 0:1ed23ab1345f 4 * Redistribution and use in source and binary forms, with or without
va009039 0:1ed23ab1345f 5 * modification, are permitted provided that the following conditions
va009039 0:1ed23ab1345f 6 * are met:
va009039 0:1ed23ab1345f 7 *
va009039 0:1ed23ab1345f 8 * 1. Redistributions of source code must retain the above copyright
va009039 0:1ed23ab1345f 9 * notice, this list of conditions and the following disclaimer.
va009039 0:1ed23ab1345f 10 * 2. Redistributions in binary form must reproduce the above copyright
va009039 0:1ed23ab1345f 11 * notice, this list of conditions and the following disclaimer in the
va009039 0:1ed23ab1345f 12 * documentation and/or other materials provided with the distribution.
va009039 0:1ed23ab1345f 13 * 3. Neither the name of the copyright holders nor the names of
va009039 0:1ed23ab1345f 14 * contributors may be used to endorse or promote products derived
va009039 0:1ed23ab1345f 15 * from this software without specific prior written permission.
va009039 0:1ed23ab1345f 16 * 4. Any redistribution, use, or modification is done solely for
va009039 0:1ed23ab1345f 17 * personal benefit and not for any commercial purpose or for
va009039 0:1ed23ab1345f 18 * monetary gain.
va009039 0:1ed23ab1345f 19 *
va009039 0:1ed23ab1345f 20 * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
va009039 0:1ed23ab1345f 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
va009039 0:1ed23ab1345f 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
va009039 0:1ed23ab1345f 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
va009039 0:1ed23ab1345f 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
va009039 0:1ed23ab1345f 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
va009039 0:1ed23ab1345f 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
va009039 0:1ed23ab1345f 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
va009039 0:1ed23ab1345f 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
va009039 0:1ed23ab1345f 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
va009039 0:1ed23ab1345f 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
va009039 0:1ed23ab1345f 31 * SUCH DAMAGE.
va009039 0:1ed23ab1345f 32 *
va009039 0:1ed23ab1345f 33 * Please inquire about commercial licensing options at btstack@ringwald.ch
va009039 0:1ed23ab1345f 34 *
va009039 0:1ed23ab1345f 35 */
va009039 0:1ed23ab1345f 36 #pragma once
va009039 0:1ed23ab1345f 37
va009039 0:1ed23ab1345f 38 #include <stdint.h>
va009039 0:1ed23ab1345f 39 #include <btstack/linked_list.h>
va009039 0:1ed23ab1345f 40
va009039 0:1ed23ab1345f 41 #include "config.h"
va009039 0:1ed23ab1345f 42
va009039 0:1ed23ab1345f 43 typedef enum {
va009039 0:1ed23ab1345f 44 SDP_ErrorResponse = 1,
va009039 0:1ed23ab1345f 45 SDP_ServiceSearchRequest,
va009039 0:1ed23ab1345f 46 SDP_ServiceSearchResponse,
va009039 0:1ed23ab1345f 47 SDP_ServiceAttributeRequest,
va009039 0:1ed23ab1345f 48 SDP_ServiceAttributeResponse,
va009039 0:1ed23ab1345f 49 SDP_ServiceSearchAttributeRequest,
va009039 0:1ed23ab1345f 50 SDP_ServiceSearchAttributeResponse
va009039 0:1ed23ab1345f 51 } SDP_PDU_ID_t;
va009039 0:1ed23ab1345f 52
va009039 0:1ed23ab1345f 53 // service record
va009039 0:1ed23ab1345f 54 // -- uses user_data field for actual
va009039 0:1ed23ab1345f 55 typedef struct {
va009039 0:1ed23ab1345f 56 // linked list - assert: first field
va009039 0:1ed23ab1345f 57 linked_item_t item;
va009039 0:1ed23ab1345f 58
va009039 0:1ed23ab1345f 59 // client connection
va009039 0:1ed23ab1345f 60 void * connection;
va009039 0:1ed23ab1345f 61
va009039 0:1ed23ab1345f 62 // data is contained in same memory
va009039 0:1ed23ab1345f 63 uint32_t service_record_handle;
va009039 0:1ed23ab1345f 64 uint8_t service_record[0];
va009039 0:1ed23ab1345f 65 } service_record_item_t;
va009039 0:1ed23ab1345f 66
va009039 0:1ed23ab1345f 67
va009039 0:1ed23ab1345f 68 void sdp_init(void);
va009039 0:1ed23ab1345f 69
va009039 0:1ed23ab1345f 70 void sdp_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type,
va009039 0:1ed23ab1345f 71 uint16_t channel, uint8_t *packet, uint16_t size));
va009039 0:1ed23ab1345f 72
va009039 0:1ed23ab1345f 73 #ifdef EMBEDDED
va009039 0:1ed23ab1345f 74 // register service record internally - the normal version creates a copy of the record
va009039 0:1ed23ab1345f 75 // pre: AttributeIDs are in ascending order => ServiceRecordHandle is first attribute if present
va009039 0:1ed23ab1345f 76 // @returns ServiceRecordHandle or 0 if registration failed
va009039 0:1ed23ab1345f 77 uint32_t sdp_register_service_internal(void *connection, service_record_item_t * record_item);
va009039 0:1ed23ab1345f 78 #else
va009039 0:1ed23ab1345f 79 // register service record internally - this special version doesn't copy the record, it cannot be freeed
va009039 0:1ed23ab1345f 80 // pre: AttributeIDs are in ascending order
va009039 0:1ed23ab1345f 81 // pre: ServiceRecordHandle is first attribute and valid
va009039 0:1ed23ab1345f 82 // pre: record
va009039 0:1ed23ab1345f 83 // @returns ServiceRecordHandle or 0 if registration failed
va009039 0:1ed23ab1345f 84 uint32_t sdp_register_service_internal(void *connection, uint8_t * service_record);
va009039 0:1ed23ab1345f 85 #endif
va009039 0:1ed23ab1345f 86
va009039 0:1ed23ab1345f 87 // unregister service record internally
va009039 0:1ed23ab1345f 88 void sdp_unregister_service_internal(void *connection, uint32_t service_record_handle);
va009039 0:1ed23ab1345f 89
va009039 0:1ed23ab1345f 90 //
va009039 0:1ed23ab1345f 91 void sdp_unregister_services_for_connection(void *connection);
va009039 0:1ed23ab1345f 92
va009039 0:1ed23ab1345f 93 //
va009039 0:1ed23ab1345f 94 int sdp_handle_service_search_request(uint8_t * packet, uint16_t remote_mtu);
va009039 0:1ed23ab1345f 95 int sdp_handle_service_attribute_request(uint8_t * packet, uint16_t remote_mtu);
va009039 0:1ed23ab1345f 96 int sdp_handle_service_search_attribute_request(uint8_t * packet, uint16_t remote_mtu);