[337] | 1 | /*
|
---|
| 2 | * Copyright (C) 2009-2012 by Matthias Ringwald
|
---|
| 3 | *
|
---|
| 4 | * Redistribution and use in source and binary forms, with or without
|
---|
| 5 | * modification, are permitted provided that the following conditions
|
---|
| 6 | * are met:
|
---|
| 7 | *
|
---|
| 8 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 9 | * notice, this list of conditions and the following disclaimer.
|
---|
| 10 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 12 | * documentation and/or other materials provided with the distribution.
|
---|
| 13 | * 3. Neither the name of the copyright holders nor the names of
|
---|
| 14 | * contributors may be used to endorse or promote products derived
|
---|
| 15 | * from this software without specific prior written permission.
|
---|
| 16 | * 4. Any redistribution, use, or modification is done solely for
|
---|
| 17 | * personal benefit and not for any commercial purpose or for
|
---|
| 18 | * monetary gain.
|
---|
| 19 | *
|
---|
| 20 | * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
|
---|
| 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
---|
| 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
---|
| 24 | * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
---|
| 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
---|
| 27 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
---|
| 28 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
| 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
---|
| 30 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 31 | * SUCH DAMAGE.
|
---|
| 32 | *
|
---|
| 33 | * Please inquire about commercial licensing options at btstack@ringwald.ch
|
---|
| 34 | *
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * interface to provide link key and remote name storage
|
---|
| 39 | */
|
---|
| 40 |
|
---|
| 41 | #ifndef __REMOTE_DEVICE_DB_H
|
---|
| 42 | #define __REMOTE_DEVICE_DB_H
|
---|
| 43 |
|
---|
| 44 | #include <btstack/utils.h>
|
---|
| 45 | #include "gap.h"
|
---|
| 46 |
|
---|
| 47 | #if defined __cplusplus
|
---|
| 48 | extern "C" {
|
---|
| 49 | #endif
|
---|
| 50 |
|
---|
| 51 | typedef struct {
|
---|
| 52 |
|
---|
| 53 | // management
|
---|
| 54 | void (*open)(void);
|
---|
| 55 | void (*close)(void);
|
---|
| 56 |
|
---|
| 57 | // link key
|
---|
| 58 | int (*get_link_key)(bd_addr_t *bd_addr, link_key_t *link_key, link_key_type_t * type);
|
---|
| 59 | void (*put_link_key)(bd_addr_t *bd_addr, link_key_t *key, link_key_type_t type);
|
---|
| 60 | void (*delete_link_key)(bd_addr_t *bd_addr);
|
---|
| 61 |
|
---|
| 62 | // remote name
|
---|
| 63 | int (*get_name)(bd_addr_t *bd_addr, device_name_t *device_name);
|
---|
| 64 | void (*put_name)(bd_addr_t *bd_addr, device_name_t *device_name);
|
---|
| 65 | void (*delete_name)(bd_addr_t *bd_addr);
|
---|
| 66 |
|
---|
| 67 | // persistent rfcomm channel
|
---|
| 68 | uint8_t (*persistent_rfcomm_channel)(char *servicename);
|
---|
| 69 |
|
---|
| 70 | } remote_device_db_t;
|
---|
| 71 |
|
---|
| 72 | extern remote_device_db_t remote_device_db_iphone;
|
---|
| 73 | extern const remote_device_db_t remote_device_db_memory;
|
---|
| 74 |
|
---|
| 75 | // MARK: non-persisten implementation
|
---|
| 76 | #include <btstack/linked_list.h>
|
---|
| 77 | #define MAX_NAME_LEN 32
|
---|
| 78 | typedef struct {
|
---|
| 79 | // linked list - assert: first field
|
---|
| 80 | linked_item_t item;
|
---|
| 81 |
|
---|
| 82 | bd_addr_t bd_addr;
|
---|
| 83 | } db_mem_device_t;
|
---|
| 84 |
|
---|
| 85 | typedef struct {
|
---|
| 86 | db_mem_device_t device;
|
---|
| 87 | link_key_t link_key;
|
---|
| 88 | link_key_type_t link_key_type;
|
---|
| 89 | } db_mem_device_link_key_t;
|
---|
| 90 |
|
---|
| 91 | typedef struct {
|
---|
| 92 | db_mem_device_t device;
|
---|
| 93 | char device_name[MAX_NAME_LEN];
|
---|
| 94 | } db_mem_device_name_t;
|
---|
| 95 |
|
---|
| 96 | typedef struct {
|
---|
| 97 | // linked list - assert: first field
|
---|
| 98 | linked_item_t item;
|
---|
| 99 |
|
---|
| 100 | char service_name[MAX_NAME_LEN];
|
---|
| 101 | uint8_t channel;
|
---|
| 102 | } db_mem_service_t;
|
---|
| 103 |
|
---|
| 104 | #if defined __cplusplus
|
---|
| 105 | }
|
---|
| 106 | #endif
|
---|
| 107 |
|
---|
| 108 | #endif // __REMOTE_DEVICE_DB_H
|
---|