summaryrefslogtreecommitdiffstats
path: root/stack/goep/goep_fs.c
blob: 4373341fceaefbb379815070a6895b193e467d3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*****************************************************************************
**
**  Name:       goep_fs.c
**
**  File:       Implements the Object Interface for GOEP Profiles
**
**  Copyright (c) 2000-2004, WIDCOMM Inc., All Rights Reserved.
**  WIDCOMM Bluetooth Core. Proprietary and confidential.
**
*****************************************************************************/

#include <string.h>
#include <ctype.h>
#include <stdio.h>

#include "gki.h"
#include "btu.h"
#include "goep_fs.h"

/*****************************************************************************
**
**  Function:    GOEP_OpenRsp
**
**  Purpose:     Report the status of tGOEP_OPEN_CBACK callback function.
**
**  Parameters:  fd         - File handle.
**               status     - Status of the operation.
**               file_size  - total number of bytes in this file.
**               event_id   - event id as given in the tGOEP_OPEN_CBACK function.
**
**  Returns:     void
**
*****************************************************************************/
void GOEP_OpenRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT32 file_size,
                   UINT16 event_id)
{
    tGOEP_OPEN_RSP  *p_evt_msg;
    UINT16          size = sizeof(tGOEP_OPEN_RSP);

    /* get an GKI buffer and send the event along with the event data to BTU task */
    p_evt_msg = (tGOEP_OPEN_RSP *)GKI_getbuf(size);
    if (p_evt_msg != NULL)
    {
        memset(&p_evt_msg->hdr, 0, sizeof(BT_HDR));
        p_evt_msg->hdr.event    = event_id;
        p_evt_msg->fd           = fd;
        p_evt_msg->status       = status;
        p_evt_msg->file_size    = file_size;

        GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_evt_msg);
    }
}

/*****************************************************************************
**
**  Function:    GOEP_ReadRsp
**
**  Purpose:     Report the status of tGOEP_READ_CBACK callback function.
**
**  Parameters:  fd         - File handle.
**               status     - Status of the operation.
**               bytes_read - total number of bytes read from the file.
**               event_id   - event id as given in the tGOEP_READ_CBACK function.
**
**  Returns:     void
**
*****************************************************************************/
void GOEP_ReadRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT16 bytes_read,
                   UINT16 event_id)
{
    tGOEP_READ_RSP  *p_evt_msg;
    UINT16          size = sizeof(tGOEP_READ_RSP);

    /* get an GKI buffer and send the event along with the event data to BTU task */
    p_evt_msg = (tGOEP_READ_RSP *)GKI_getbuf(size);
    if (p_evt_msg != NULL)
    {
        memset(&p_evt_msg->hdr, 0, sizeof(BT_HDR));
        p_evt_msg->hdr.event    = event_id;
        p_evt_msg->fd           = fd;
        p_evt_msg->status       = status;
        p_evt_msg->bytes_read   = bytes_read;

        GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_evt_msg);
    }
}

/*****************************************************************************
**
**  Function:    GOEP_WriteRsp
**
**  Purpose:     Report the status of tGOEP_WRITE_CBACK callback function.
**
**  Parameters:  fd         - File handle.
**               status     - Status of the operation.
**               event_id   - event id as given in the tGOEP_WRITE_CBACK function.
**
**  Returns:     void
**
*****************************************************************************/
void GOEP_WriteRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT16 event_id)
{
    tGOEP_WRITE_RSP *p_evt_msg;
    UINT16          size = sizeof(tGOEP_WRITE_RSP);

    /* get an GKI buffer and send the event along with the event data to BTU task */
    p_evt_msg = (tGOEP_WRITE_RSP *)GKI_getbuf(size);
    if (p_evt_msg != NULL)
    {
        memset(&p_evt_msg->hdr, 0, sizeof(BT_HDR));
        p_evt_msg->hdr.event    = event_id;
        p_evt_msg->fd           = fd;
        p_evt_msg->status       = status;

        GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_evt_msg);
    }
}

/*****************************************************************************
**
**  Function:   GOEP_DirentryRsp
**
**  Purpose:    Report the status of tGOEP_DIRENTRY_CBACK callback function.
**
** Parameters:  status - GOEP_OK if p_entry points to a valid entry.
**                       GOEP_EODIR if no more entries (p_entry is ignored).
**                       GOEP_FAIL if any errors have occurred.
**              event_id   - event id as given in the tGOEP_DIRENTRY_CBACK function.
**
**  Returns:    void
**
*****************************************************************************/
void GOEP_DirentryRsp (tGOEP_STATUS status, UINT16 event_id)
{
    tGOEP_DIRENTRY_RSP *p_evt_msg;
    UINT16              size = sizeof(tGOEP_DIRENTRY_RSP);

    /* get an GKI buffer and send the event along with the event data to BTU task */
    p_evt_msg = (tGOEP_DIRENTRY_RSP *)GKI_getbuf(size);
    if (p_evt_msg != NULL)
    {
        memset(&p_evt_msg->hdr, 0, sizeof(BT_HDR));
        p_evt_msg->hdr.event    = event_id;
        p_evt_msg->status       = status;

        GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_evt_msg);
    }
}