[CA] [All] URI support , Optimization , License verification
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / arduino / cableserver.cpp
1 /******************************************************************
2 *
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
4 *
5 *
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ******************************************************************/
20
21 #include "cableserver.h"
22
23 #include <Arduino.h>
24 #include <SPI.h>
25 #include <boards.h>
26 #include <RBL_nRF8001.h>
27 #include <services.h>
28
29 #include <logger.h>
30 #include "oic_malloc.h"
31 #include "caadapterutils.h"
32
33 #define TAG "LES"
34
35 CAResult_t CAInitializeBle()
36 {
37     OIC_LOG(DEBUG, TAG, "IN");
38
39     // Set your BLE Shield name here, max. length 10
40     ble_set_name("SAMSUNG");
41
42     OIC_LOG(DEBUG, TAG, "LEName Set");
43
44     ble_begin();
45
46     OIC_LOG(DEBUG, TAG, "OUT");
47     return CA_STATUS_OK;
48
49 }
50
51 CAResult_t CAAddNewBleServiceInGattServer(const char *service_uuid)
52 {
53     // Not Supported - Done at compile time
54     return CA_STATUS_OK;
55 }
56
57 CAResult_t CARemoveBleServiceFromGattServer(const char *svc_path)
58 {
59     // Not Supported - Done at compile time
60     return CA_STATUS_OK;
61 }
62
63 CAResult_t CARemoveAllBleServicesFromGattServer()
64 {
65     // Not Supported
66     return CA_STATUS_OK;
67 }
68
69 CAResult_t CARegisterBleServicewithGattServer(const char *svc_path)
70 {
71     // Not Supported - Done at compile time
72     return CA_STATUS_OK;
73 }
74
75 CAResult_t CAAddNewCharacteristicsToGattServer(const char *svc_path,
76         const char *char_uuid,
77         const char *char_value,
78         int char_value_len,
79         int read)
80 {
81     // Not Supported - Done at compile time
82     return CA_STATUS_OK;
83 }
84
85 CAResult_t CARemoveCharacteristicsFromGattServer(const char *char_path)
86 {
87     // Not Supported
88     return CA_STATUS_OK;
89 }
90
91 unsigned char CAIsBleDataAvailable()
92 {
93     return ble_available();
94 }
95
96 unsigned char CAIsBleConnected()
97 {
98     return ble_connected();
99 }
100 char CAReadBleData()
101 {
102     return (char)ble_read();
103 }
104
105 CAResult_t CABleDoEvents()
106 {
107     ble_do_events();
108     return CA_STATUS_OK;
109 }
110
111 CAResult_t CAWriteBleData(unsigned char *data, uint8_t len)
112 {
113     // Currently ble_write_bytes api returns void.
114     ble_write_bytes(data, len);
115     return CA_STATUS_OK;
116 }