5b46df5223dc9211cc25fbbb62a33e77503a25df
[platform/upstream/iotivity.git] / resource / csdk / connectivity / lib / arduino / RBL_nRF8001.patch
1 diff -rupN RBL_nRF8001_old/RBL_nRF8001.cpp RBL_nRF8001/RBL_nRF8001.cpp
2 --- RBL_nRF8001_old/RBL_nRF8001.cpp     2015-01-13 12:25:32.000000000 +0530
3 +++ RBL_nRF8001/RBL_nRF8001.cpp 2015-01-13 12:40:41.740244741 +0530
4 @@ -22,7 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOU
5  #endif
6  
7  /* Store the setup for the nRF8001 in the flash of the AVR to save on RAM */
8 -static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;
9 +static const hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;
10  
11  #if defined(BLEND_MICRO)
12  static char device_name[11] = "BlendMicro";
13 @@ -31,7 +31,10 @@ static char device_name[11] = "Blend
14  #else
15  static char device_name[11] = "BLE Shield";
16  #endif
17 -               
18 +
19 +#define BLE_ADDRESS_SIZE 18
20 +static unsigned char *gLeAddress = NULL;
21 +
22  static uint16_t Adv_Timeout = 0;       // Advertising all the time
23  static uint16_t Adv_Interval = 0x0050; /* advertising interval 50ms
24  
25 @@ -117,7 +120,7 @@ void ble_begin()
26          aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
27      }
28      aci_state.aci_setup_info.number_of_pipes    = NUMBER_OF_PIPES;
29 -    aci_state.aci_setup_info.setup_msgs         = setup_msgs;
30 +    aci_state.aci_setup_info.setup_msgs         = (hal_aci_data_t*)setup_msgs;
31      aci_state.aci_setup_info.num_setup_msgs     = NB_SETUP_MESSAGES;
32  
33      /*
34 @@ -159,7 +162,7 @@ void ble_begin()
35  static volatile byte ack = 0;
36  
37  void ble_write(unsigned char data)
38 -{          
39 +{
40      if(tx_buffer_len == MAX_TX_BUFF)
41      {
42              return;
43 @@ -199,13 +202,13 @@ unsigned char ble_connected()
44  }
45  
46  void ble_set_name(char *name)
47 -{       
48 +{
49      unsigned char len=0;
50 -    
51 +
52      len = strlen(name);
53      if(len > 10)
54      {
55 -        Serial.print("the new name is too long");        
56 +        Serial.print("the new name is too long");
57      }
58      else
59      {
60 @@ -236,6 +239,10 @@ void ble_reset(uint8_t reset_pin)
61  void ble_disconnect(void)
62  {
63         lib_aci_disconnect(&aci_state, ACI_REASON_TERMINATE);
64 +    if (NULL != gLeAddress)
65 +    {
66 +        free(gLeAddress);
67 +    }
68  }
69  
70  static void process_events()
71 @@ -271,6 +278,7 @@ static void process_events()
72                              lib_aci_set_local_data(&aci_state, PIPE_GAP_DEVICE_NAME_SET , (uint8_t *)&device_name , strlen(device_name));
73                              lib_aci_connect(Adv_Timeout/* in seconds */, Adv_Interval /* advertising interval 50ms*/);
74                              Serial.println(F("Advertising started"));
75 +                            lib_aci_get_address();
76                          }
77                          break;
78                  }
79 @@ -294,6 +302,32 @@ static void process_events()
80                      lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET,
81                      (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version), sizeof(aci_evt_cmd_rsp_params_get_device_version_t));
82                  }
83 +
84 +                if (ACI_CMD_GET_DEVICE_ADDRESS == aci_evt->params.cmd_rsp.cmd_opcode)
85 +                {
86 +                    if (NULL != gLeAddress)
87 +                    {
88 +                        free(gLeAddress);
89 +                    }
90 +                    gLeAddress = (unsigned char *) malloc (BLE_ADDRESS_SIZE);
91 +                    if (NULL == gLeAddress)
92 +                    {
93 +                        Serial.println("error");
94 +                        break;
95 +                    }
96 +                    char *tempAddr = (char *) gLeAddress;
97 +                    int8_t iter = 0;
98 +                    for (iter = BTLE_DEVICE_ADDRESS_SIZE - 1; iter >= 0; iter--)
99 +                    {
100 +                        sprintf(tempAddr, "%02x%c",
101 +                                 (uint8_t)aci_evt->params.cmd_rsp.params.get_device_address.bd_addr_own[iter], 58);
102 +                        tempAddr += 3;
103 +                    }
104 +                    gLeAddress[BLE_ADDRESS_SIZE - 1] = '\0';
105 +                    Serial.println("LEAddress :");
106 +                    Serial.println((char *)gLeAddress);
107 +                    return;
108 +                }
109                  break;
110  
111              case ACI_EVT_CONNECTED:
112 @@ -471,3 +505,12 @@ void ble_do_events()
113  #endif
114  }
115  
116 +unsigned char* ble_getAddress()
117 +{
118 +    return gLeAddress;
119 +}
120 +
121 +void ble_radio_reset()
122 +{
123 +    lib_aci_radio_reset();
124 +}
125 diff -rupN RBL_nRF8001_old/RBL_nRF8001.h RBL_nRF8001/RBL_nRF8001.h
126 --- RBL_nRF8001_old/RBL_nRF8001.h       2015-01-13 12:25:32.000000000 +0530
127 +++ RBL_nRF8001/RBL_nRF8001.h   2015-01-13 12:40:41.740244741 +0530
128 @@ -48,6 +48,8 @@ void ble_set_pins(uint8_t reqn, uint8_t
129  unsigned char ble_busy();
130  void ble_reset(uint8_t reset_pin);
131  void ble_disconnect(void);
132 +unsigned char* ble_getAddress();
133 +void ble_radio_reset();
134  
135  #endif
136  
137 diff -rupN RBL_nRF8001_old/RBL_nRF8001.xml RBL_nRF8001/RBL_nRF8001.xml
138 --- RBL_nRF8001_old/RBL_nRF8001.xml     2015-01-14 01:52:26.000000000 +0530
139 +++ RBL_nRF8001/RBL_nRF8001.xml 2015-07-21 14:27:18.000000000 +0530
140 @@ -5,10 +5,10 @@
141      <Device>nRF8001_Dx</Device>
142      <Service Type="local" PrimaryService="true">
143          <Name>UART over BTLE</Name>
144 -        <Uuid BaseUUID="713D0000503E4C75BA943148F18D941E" BaseUUIDName="Custom UART">0000</Uuid>
145 +        <Uuid BaseUUID="ADE30000C7844F63A987EB69F70EE816" BaseUUIDName="Custom UART">D529</Uuid>
146          <Characteristic>
147              <Name>UART RX</Name>
148 -            <Uuid BaseUUID="713D0000503E4C75BA943148F18D941E" BaseUUIDName="Custom UART">0003</Uuid>
149 +            <Uuid BaseUUID="AD7B000046374B8690B69D787F03D218" BaseUUIDName="Custom UART2">334f</Uuid>
150              <DefaultValue></DefaultValue>
151              <UsePresentationFormat>0</UsePresentationFormat>
152              <MaxDataLength>20</MaxDataLength>
153 @@ -30,7 +30,7 @@
154          </Characteristic>
155          <Characteristic>
156              <Name>UART TX</Name>
157 -            <Uuid BaseUUID="713D0000503E4C75BA943148F18D941E" BaseUUIDName="Custom UART">0002</Uuid>
158 +            <Uuid BaseUUID="E9240000458042C4883195048216B256" BaseUUIDName="Custom UART3">1982</Uuid>
159              <DefaultValue></DefaultValue>
160              <UsePresentationFormat>0</UsePresentationFormat>
161              <MaxDataLength>20</MaxDataLength>
162 @@ -111,7 +111,7 @@
163          <AddServiceUpdateCharacteristicPipe>true</AddServiceUpdateCharacteristicPipe>
164          <TimingChangeDelay>5</TimingChangeDelay>
165          <ServiceToAdvertise>
166 -            <Uuid BaseUUID="713D0000503E4C75BA943148F18D941E" BaseUUIDName="Custom UART">0000</Uuid>
167 +            <Uuid BaseUUID="ADE30000C7844F63A987EB69F70EE816" BaseUUIDName="Custom UART">D529</Uuid>
168          </ServiceToAdvertise>
169          <CustomAdTypes>
170              <AdType index="1">
171 diff -rupN RBL_nRF8001_old/RBL_services.h RBL_nRF8001/RBL_services.h
172 --- RBL_nRF8001_old/RBL_services.h      2015-01-14 01:52:26.000000000 +0530
173 +++ RBL_nRF8001/RBL_services.h  2015-07-17 15:22:22.000000000 +0530
174 @@ -49,7 +49,7 @@
175  #define GAP_PPCP_SLAVE_LATENCY 0
176  #define GAP_PPCP_CONN_TIMEOUT 0xa /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */
177  
178 -#define NB_SETUP_MESSAGES 23
179 +#define NB_SETUP_MESSAGES 24
180  #define SETUP_MESSAGES_CONTENT {\
181      {0x00,\
182          {\
183 @@ -59,13 +59,13 @@
184      {0x00,\
185          {\
186              0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x05,0x01,0x01,0x00,0x00,0x06,0x00,0x00,\
187 -            0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
188 +            0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd5,\
189          },\
190      },\
191      {0x00,\
192          {\
193 -            0x1f,0x06,0x10,0x1c,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
194 -            0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x03,0x90,0x01,0xff,\
195 +            0x1f,0x06,0x10,0x1c,0x29,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
196 +            0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x03,0x90,0x03,0xff,\
197          },\
198      },\
199      {0x00,\
200 @@ -112,30 +112,30 @@
201      {0x00,\
202          {\
203              0x1f,0x06,0x20,0x8c,0x03,0x02,0x00,0x0b,0x29,0x02,0x01,0x00,0x00,0x04,0x04,0x10,0x10,0x00,0x0c,0x28,\
204 -            0x00,0x01,0x1e,0x94,0x8d,0xf1,0x48,0x31,0x94,0xba,0x75,0x4c,\
205 +            0x00,0x01,0x16,0xe8,0x0e,0xf7,0x69,0xeb,0x87,0xa9,0x63,0x4f,\
206          },\
207      },\
208      {0x00,\
209          {\
210 -            0x1f,0x06,0x20,0xa8,0x3e,0x50,0x00,0x00,0x3d,0x71,0x04,0x04,0x13,0x13,0x00,0x0d,0x28,0x03,0x01,0x04,\
211 -            0x0e,0x00,0x1e,0x94,0x8d,0xf1,0x48,0x31,0x94,0xba,0x75,0x4c,\
212 +            0x1f,0x06,0x20,0xa8,0x84,0xc7,0x29,0xd5,0xe3,0xad,0x04,0x04,0x13,0x13,0x00,0x0d,0x28,0x03,0x01,0x04,\
213 +            0x0e,0x00,0x18,0xd2,0x03,0x7f,0x78,0x9d,0xb6,0x90,0x86,0x4b,\
214          },\
215      },\
216      {0x00,\
217          {\
218 -            0x1f,0x06,0x20,0xc4,0x3e,0x50,0x03,0x00,0x3d,0x71,0x44,0x10,0x14,0x00,0x00,0x0e,0x00,0x03,0x02,0x00,\
219 +            0x1f,0x06,0x20,0xc4,0x37,0x46,0x4f,0x33,0x7b,0xad,0x44,0x10,0x14,0x00,0x00,0x0e,0x33,0x4f,0x03,0x00,\
220              0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
221          },\
222      },\
223      {0x00,\
224          {\
225              0x1f,0x06,0x20,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x13,0x13,0x00,0x0f,0x28,0x03,0x01,\
226 -            0x10,0x10,0x00,0x1e,0x94,0x8d,0xf1,0x48,0x31,0x94,0xba,0x75,\
227 +            0x10,0x10,0x00,0x56,0xb2,0x16,0x82,0x04,0x95,0x31,0x88,0xc4,\
228          },\
229      },\
230      {0x00,\
231          {\
232 -            0x1f,0x06,0x20,0xfc,0x4c,0x3e,0x50,0x02,0x00,0x3d,0x71,0x14,0x00,0x14,0x00,0x00,0x10,0x00,0x02,0x02,\
233 +            0x1f,0x06,0x20,0xfc,0x42,0x80,0x45,0x82,0x19,0x24,0xe9,0x14,0x00,0x14,0x00,0x00,0x10,0x19,0x82,0x04,\
234              0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
235          },\
236      },\
237 @@ -159,18 +159,25 @@
238      {0x00,\
239          {\
240              0x1f,0x06,0x40,0x00,0x2a,0x00,0x01,0x00,0x80,0x04,0x00,0x03,0x00,0x00,0x2a,0x05,0x01,0x00,0x04,0x04,\
241 -            0x00,0x0a,0x00,0x0b,0x00,0x03,0x02,0x00,0x08,0x04,0x00,0x0e,\
242 +            0x00,0x0a,0x00,0x0b,0x33,0x4f,0x03,0x00,0x08,0x04,0x00,0x0e,\
243          },\
244      },\
245      {0x00,\
246          {\
247 -            0x19,0x06,0x40,0x1c,0x00,0x00,0x00,0x02,0x02,0x00,0x02,0x04,0x00,0x10,0x00,0x11,0x2a,0x27,0x01,0x00,\
248 +            0x19,0x06,0x40,0x1c,0x00,0x00,0x19,0x82,0x04,0x00,0x02,0x04,0x00,0x10,0x00,0x11,0x2a,0x27,0x01,0x00,\
249              0x80,0x04,0x00,0x14,0x00,0x00,\
250          },\
251      },\
252      {0x00,\
253          {\
254 -            0x13,0x06,0x50,0x00,0x1e,0x94,0x8d,0xf1,0x48,0x31,0x94,0xba,0x75,0x4c,0x3e,0x50,0x00,0x00,0x3d,0x71,\
255 +            0x1f,0x06,0x50,0x00,0x16,0xe8,0x0e,0xf7,0x69,0xeb,0x87,0xa9,0x63,0x4f,0x84,0xc7,0x00,0x00,0xe3,0xad,\
256 +            0x18,0xd2,0x03,0x7f,0x78,0x9d,0xb6,0x90,0x86,0x4b,0x37,0x46,\
257 +        },\
258 +    },\
259 +    {0x00,\
260 +        {\
261 +            0x17,0x06,0x50,0x1c,0x00,0x00,0x7b,0xad,0x56,0xb2,0x16,0x82,0x04,0x95,0x31,0x88,0xc4,0x42,0x80,0x45,\
262 +            0x00,0x00,0x24,0xe9,\
263          },\
264      },\
265      {0x00,\
266 @@ -180,7 +187,7 @@
267      },\
268      {0x00,\
269          {\
270 -            0x06,0x06,0xf0,0x00,0x03,0x3d,0x6c,\
271 +            0x06,0x06,0xf0,0x00,0x03,0x2b,0x7e,\
272          },\
273      },\
274  }