Hexiwear library for communicating with the on-board KW40Z BLE device. KW40Z handles also the touch buttons.

Fork of Hexi_KW40Z by Hexiwear

Committer:
khuang
Date:
Tue Sep 20 01:04:31 2016 +0000
Revision:
3:9e92f113c671
Parent:
2:bb66c19c3c04
Child:
4:8586f50385d2
Child:
5:8c7c1cc024ed
Altered case for packetType_passDiplay. Bonding Passkey now accessible through GetPassKey() function.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cotigac 0:c2d52562f36b 1 /** BLE KW40Z Driver for Hexiwear
cotigac 0:c2d52562f36b 2 * This file contains BLE and Touch Buttons driver functionality for Hexiwear
cotigac 0:c2d52562f36b 3 *
cotigac 0:c2d52562f36b 4 * Redistribution and use in source and binary forms, with or without modification,
cotigac 0:c2d52562f36b 5 * are permitted provided that the following conditions are met:
cotigac 0:c2d52562f36b 6 *
cotigac 0:c2d52562f36b 7 * Redistributions of source code must retain the above copyright notice, this list
cotigac 0:c2d52562f36b 8 * of conditions and the following disclaimer.
cotigac 0:c2d52562f36b 9 *
cotigac 0:c2d52562f36b 10 * Redistributions in binary form must reproduce the above copyright notice, this
cotigac 0:c2d52562f36b 11 * list of conditions and the following disclaimer in the documentation and/or
cotigac 0:c2d52562f36b 12 * other materials provided with the distribution.
cotigac 0:c2d52562f36b 13 *
cotigac 0:c2d52562f36b 14 * Neither the name of NXP, nor the names of its
cotigac 0:c2d52562f36b 15 * contributors may be used to endorse or promote products derived from this
cotigac 0:c2d52562f36b 16 * software without specific prior written permission.
cotigac 0:c2d52562f36b 17 *
cotigac 0:c2d52562f36b 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
cotigac 0:c2d52562f36b 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
cotigac 0:c2d52562f36b 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
cotigac 0:c2d52562f36b 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
cotigac 0:c2d52562f36b 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
cotigac 0:c2d52562f36b 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
cotigac 0:c2d52562f36b 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
cotigac 0:c2d52562f36b 25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
cotigac 0:c2d52562f36b 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
cotigac 0:c2d52562f36b 27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cotigac 0:c2d52562f36b 28 *
cotigac 0:c2d52562f36b 29 * visit: http://www.mikroe.com and http://www.nxp.com
cotigac 0:c2d52562f36b 30 *
cotigac 0:c2d52562f36b 31 * get support at: http://www.mikroe.com/forum and https://community.nxp.com
cotigac 0:c2d52562f36b 32 *
cotigac 0:c2d52562f36b 33 * Project HEXIWEAR, 2015
cotigac 0:c2d52562f36b 34 */
cotigac 0:c2d52562f36b 35
cotigac 0:c2d52562f36b 36 #include "Hexi_KW40Z.h"
cotigac 0:c2d52562f36b 37
cotigac 0:c2d52562f36b 38 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 39 RawSerial pc(USBTX, USBRX); // tx, rx
cotigac 0:c2d52562f36b 40 #endif
cotigac 0:c2d52562f36b 41
cotigac 0:c2d52562f36b 42 KW40Z::KW40Z(PinName txPin,PinName rxPin) : device(txPin, rxPin), mainThread(&KW40Z::mainStarter, this, osPriorityNormal,1024), rxThread(&KW40Z::rxStarter, this, osPriorityNormal,1024)
cotigac 0:c2d52562f36b 43 {
cotigac 0:c2d52562f36b 44 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 45 pc.baud(115200);
cotigac 0:c2d52562f36b 46 pc.printf("Initializing\r\n");
cotigac 0:c2d52562f36b 47 #endif
cotigac 0:c2d52562f36b 48
cotigac 0:c2d52562f36b 49 device.baud(230400);
cotigac 0:c2d52562f36b 50 device.format(8, Serial::None, 2);
cotigac 0:c2d52562f36b 51
cotigac 0:c2d52562f36b 52 rxBuff = (uint8_t*)&hostInterface_rxPacket;
cotigac 1:f6f9b24aea57 53
cotigac 1:f6f9b24aea57 54 /* initialize callbacks */
cotigac 1:f6f9b24aea57 55 buttonUpCb = NULL;
cotigac 1:f6f9b24aea57 56 buttonDownCb = NULL;
cotigac 1:f6f9b24aea57 57 buttonLeftCb = NULL;
cotigac 1:f6f9b24aea57 58 buttonRightCb = NULL;
cotigac 1:f6f9b24aea57 59 buttonSlideCb = NULL;
cotigac 1:f6f9b24aea57 60 alertCb = NULL;
cotigac 1:f6f9b24aea57 61 passkeyCb = NULL;
cotigac 1:f6f9b24aea57 62 notificationsCb = NULL;
cotigac 2:bb66c19c3c04 63
cotigac 2:bb66c19c3c04 64 kw40_version.ver_patchNumber = 0;
cotigac 2:bb66c19c3c04 65 kw40_version.ver_minorNumber = 0;
cotigac 2:bb66c19c3c04 66 kw40_version.ver_majorNumber = 0;
cotigac 2:bb66c19c3c04 67
cotigac 2:bb66c19c3c04 68 activeTsiGroup = 0;
cotigac 2:bb66c19c3c04 69 advertisementMode = 0;
cotigac 2:bb66c19c3c04 70 linkState = 0;
khuang 3:9e92f113c671 71 bondPassKey = 0;
cotigac 0:c2d52562f36b 72
cotigac 0:c2d52562f36b 73 /* intialization finalized, signal to start the threads */
cotigac 0:c2d52562f36b 74 mainThread.signal_set(START_THREAD);
cotigac 0:c2d52562f36b 75 rxThread.signal_set(START_THREAD);
cotigac 0:c2d52562f36b 76 }
cotigac 0:c2d52562f36b 77
cotigac 0:c2d52562f36b 78 KW40Z::~KW40Z(void)
cotigac 0:c2d52562f36b 79 {
cotigac 0:c2d52562f36b 80 }
cotigac 0:c2d52562f36b 81
cotigac 2:bb66c19c3c04 82 void KW40Z::attach_buttonUp(button_t btnFct) { buttonUpCb = btnFct; }
cotigac 2:bb66c19c3c04 83 void KW40Z::attach_buttonDown(button_t btnFct) { buttonDownCb = btnFct; }
cotigac 2:bb66c19c3c04 84 void KW40Z::attach_buttonLeft(button_t btnFct) { buttonLeftCb = btnFct; }
cotigac 2:bb66c19c3c04 85 void KW40Z::attach_buttonRight(button_t btnFct) { buttonRightCb = btnFct; }
cotigac 2:bb66c19c3c04 86 void KW40Z::attach_buttonSlide(button_t btnFct) { buttonSlideCb = btnFct; }
cotigac 2:bb66c19c3c04 87 void KW40Z::attach_alert(alert_t alertFct) { alertCb = alertFct; }
cotigac 2:bb66c19c3c04 88 void KW40Z::attach_passkey(passkey_t passkeyFct){ passkeyCb = passkeyFct; }
cotigac 2:bb66c19c3c04 89 void KW40Z::attach_notifications(notifications_t notFct) { notificationsCb = notFct; }
cotigac 0:c2d52562f36b 90
cotigac 0:c2d52562f36b 91 void KW40Z::rxStarter(void const *p) {
cotigac 0:c2d52562f36b 92 KW40Z *instance = (KW40Z*)p;
cotigac 0:c2d52562f36b 93 instance->rxTask();
cotigac 0:c2d52562f36b 94 }
cotigac 0:c2d52562f36b 95
cotigac 0:c2d52562f36b 96 void KW40Z::mainStarter(void const *p) {
cotigac 0:c2d52562f36b 97 KW40Z *instance = (KW40Z*)p;
cotigac 0:c2d52562f36b 98 instance->mainTask();
cotigac 0:c2d52562f36b 99 }
cotigac 0:c2d52562f36b 100
cotigac 0:c2d52562f36b 101 void KW40Z::mainTask(void)
cotigac 0:c2d52562f36b 102 {
cotigac 0:c2d52562f36b 103 mainThread.signal_wait(START_THREAD);
cotigac 0:c2d52562f36b 104
cotigac 0:c2d52562f36b 105 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 106 pc.printf("MainTask Stared\r\n");
cotigac 0:c2d52562f36b 107 #endif
cotigac 0:c2d52562f36b 108
khuang 3:9e92f113c671 109
cotigac 2:bb66c19c3c04 110 SendGetActiveTsiGroup();
cotigac 2:bb66c19c3c04 111 SendGetAdvertisementMode();
cotigac 2:bb66c19c3c04 112 SendGetLinkState();
cotigac 2:bb66c19c3c04 113 SendGetVersion();
khuang 3:9e92f113c671 114
cotigac 2:bb66c19c3c04 115
cotigac 0:c2d52562f36b 116 while(1)
cotigac 0:c2d52562f36b 117 {
cotigac 0:c2d52562f36b 118 osEvent evt = queue.get();
cotigac 0:c2d52562f36b 119 if (evt.status == osEventMessage)
cotigac 0:c2d52562f36b 120 {
cotigac 0:c2d52562f36b 121 hostInterface_packet_t *rxPacket = (hostInterface_packet_t*)evt.value.p;
cotigac 0:c2d52562f36b 122 ProcessReceivedPacket(rxPacket);
cotigac 0:c2d52562f36b 123 mpool.free(rxPacket);
cotigac 0:c2d52562f36b 124 }
cotigac 0:c2d52562f36b 125 }
cotigac 0:c2d52562f36b 126 }
cotigac 0:c2d52562f36b 127
cotigac 0:c2d52562f36b 128 void KW40Z::rxTask(void)
cotigac 0:c2d52562f36b 129 {
cotigac 0:c2d52562f36b 130 rxThread.signal_wait(START_THREAD);
cotigac 0:c2d52562f36b 131
cotigac 0:c2d52562f36b 132 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 133 pc.printf("RxTask Stared\r\n");
cotigac 0:c2d52562f36b 134 #endif
cotigac 0:c2d52562f36b 135
cotigac 0:c2d52562f36b 136 while(1)
cotigac 0:c2d52562f36b 137 {
cotigac 0:c2d52562f36b 138 if(device.readable())
cotigac 0:c2d52562f36b 139 {
cotigac 0:c2d52562f36b 140 *rxBuff++ = device.getc();
cotigac 0:c2d52562f36b 141 ProcessBuffer();
cotigac 0:c2d52562f36b 142
cotigac 0:c2d52562f36b 143 /* check for buffer overflow */
cotigac 0:c2d52562f36b 144 if(rxBuff >= ((uint8_t*)&hostInterface_rxPacket + sizeof(hostInterface_rxPacket)))
cotigac 0:c2d52562f36b 145 {
cotigac 0:c2d52562f36b 146 rxBuff = (uint8_t*)&hostInterface_rxPacket;
cotigac 0:c2d52562f36b 147 }
cotigac 0:c2d52562f36b 148 }
cotigac 0:c2d52562f36b 149 }
cotigac 0:c2d52562f36b 150 }
cotigac 0:c2d52562f36b 151
cotigac 0:c2d52562f36b 152 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 153 void KW40Z::DebugPrintTxPacket(hostInterface_packet_t * txPacket)
cotigac 0:c2d52562f36b 154 {
cotigac 0:c2d52562f36b 155 char * txBuff = (char *)txPacket;
cotigac 0:c2d52562f36b 156 uint8_t length = txPacket->length + gHostInterface_headerSize + 1;
cotigac 0:c2d52562f36b 157
cotigac 0:c2d52562f36b 158 pc.printf("Tx: ");
cotigac 0:c2d52562f36b 159 for(uint8_t i = 0; i < length; i++)
cotigac 0:c2d52562f36b 160 {
cotigac 0:c2d52562f36b 161 pc.printf("%02X ",*txBuff);
cotigac 0:c2d52562f36b 162 txBuff++;
cotigac 0:c2d52562f36b 163 }
cotigac 0:c2d52562f36b 164 pc.printf("\r\n");
cotigac 0:c2d52562f36b 165 }
cotigac 0:c2d52562f36b 166
cotigac 0:c2d52562f36b 167 void KW40Z::DebugPrintRxPacket()
cotigac 0:c2d52562f36b 168 {
cotigac 0:c2d52562f36b 169 pc.printf("RX: ");
cotigac 0:c2d52562f36b 170 for(uint8_t * i = (uint8_t*)&hostInterface_rxPacket; i<rxBuff; i++)
cotigac 0:c2d52562f36b 171 {
cotigac 0:c2d52562f36b 172 pc.printf("%02X ",*i);
cotigac 0:c2d52562f36b 173 }
cotigac 0:c2d52562f36b 174 pc.printf("\r\n");
cotigac 0:c2d52562f36b 175 }
cotigac 0:c2d52562f36b 176 #endif
cotigac 0:c2d52562f36b 177
cotigac 2:bb66c19c3c04 178
cotigac 2:bb66c19c3c04 179 void KW40Z::SendPacket(hostInterface_packet_t * txPacket, bool confirmRequested)
cotigac 2:bb66c19c3c04 180 {
cotigac 2:bb66c19c3c04 181 uint8_t retries = 0;
cotigac 2:bb66c19c3c04 182 confirmReceived = false;
cotigac 2:bb66c19c3c04 183
cotigac 2:bb66c19c3c04 184 do
cotigac 2:bb66c19c3c04 185 {
cotigac 2:bb66c19c3c04 186 char * txBuff = (char *)txPacket;
cotigac 2:bb66c19c3c04 187 uint8_t length = txPacket->length + gHostInterface_headerSize + 1;
cotigac 2:bb66c19c3c04 188
cotigac 2:bb66c19c3c04 189 if(confirmRequested == true)
cotigac 2:bb66c19c3c04 190 {
cotigac 2:bb66c19c3c04 191 txPacket->start2 |= 0x01;
cotigac 2:bb66c19c3c04 192 }
cotigac 2:bb66c19c3c04 193
cotigac 2:bb66c19c3c04 194 for(uint8_t i = 0; i < length; i++)
cotigac 2:bb66c19c3c04 195 {
cotigac 2:bb66c19c3c04 196 device.putc(*txBuff);
cotigac 2:bb66c19c3c04 197 txBuff++;
cotigac 2:bb66c19c3c04 198 }
cotigac 2:bb66c19c3c04 199
cotigac 2:bb66c19c3c04 200 #if defined (LIB_DEBUG)
cotigac 2:bb66c19c3c04 201 DebugPrintTxPacket(txPacket);
cotigac 2:bb66c19c3c04 202 #endif
cotigac 2:bb66c19c3c04 203
cotigac 2:bb66c19c3c04 204 retries++;
cotigac 2:bb66c19c3c04 205
cotigac 2:bb66c19c3c04 206 #if defined (gHostInterface_RxConfirmationEnable)
cotigac 2:bb66c19c3c04 207 if((confirmRequested == true) && (confirmReceived == false))
cotigac 2:bb66c19c3c04 208 {
cotigac 2:bb66c19c3c04 209 Thread::wait(gHostInterface_retransmitTimeout);
cotigac 2:bb66c19c3c04 210 }
cotigac 2:bb66c19c3c04 211 #endif
cotigac 2:bb66c19c3c04 212 }
cotigac 2:bb66c19c3c04 213 while((confirmRequested == true) &&
cotigac 2:bb66c19c3c04 214 (confirmReceived == false) &&
cotigac 2:bb66c19c3c04 215 (retries < gHostInterface_retransmitCount));
cotigac 2:bb66c19c3c04 216 }
cotigac 2:bb66c19c3c04 217
cotigac 0:c2d52562f36b 218 void KW40Z::ProcessBuffer()
cotigac 0:c2d52562f36b 219 {
cotigac 0:c2d52562f36b 220 /* check if header has been received */
cotigac 0:c2d52562f36b 221 if(rxBuff > ((uint8_t*)&hostInterface_rxPacket + gHostInterface_headerSize))
cotigac 0:c2d52562f36b 222 {
cotigac 0:c2d52562f36b 223 /* check packet header */
cotigac 0:c2d52562f36b 224 if((gHostInterface_startByte1 != hostInterface_rxPacket.start1)||
cotigac 0:c2d52562f36b 225 (gHostInterface_startByte2 != (hostInterface_rxPacket.start2 & 0xFE))||
cotigac 0:c2d52562f36b 226 (hostInterface_rxPacket.length > gHostInterface_dataSize))
cotigac 0:c2d52562f36b 227 {
cotigac 0:c2d52562f36b 228 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 229 DebugPrintRxPacket();
cotigac 0:c2d52562f36b 230 pc.printf("check header failed\r\n");
cotigac 0:c2d52562f36b 231 #endif
cotigac 0:c2d52562f36b 232
cotigac 0:c2d52562f36b 233 SearchStartByte();
cotigac 0:c2d52562f36b 234 }
cotigac 0:c2d52562f36b 235 else
cotigac 0:c2d52562f36b 236 {
cotigac 0:c2d52562f36b 237 /* check data length */
cotigac 0:c2d52562f36b 238 if(rxBuff > ((uint8_t*)&hostInterface_rxPacket + gHostInterface_headerSize + hostInterface_rxPacket.length))
cotigac 0:c2d52562f36b 239 {
cotigac 0:c2d52562f36b 240 /* check trailer byte */
cotigac 0:c2d52562f36b 241 if(gHostInterface_trailerByte != hostInterface_rxPacket.data[hostInterface_rxPacket.length])
cotigac 0:c2d52562f36b 242 {
cotigac 0:c2d52562f36b 243 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 244 DebugPrintRxPacket();
cotigac 0:c2d52562f36b 245 pc.printf("trailer byte failed\r\n");
cotigac 0:c2d52562f36b 246 #endif
cotigac 0:c2d52562f36b 247
cotigac 0:c2d52562f36b 248 SearchStartByte();
cotigac 0:c2d52562f36b 249 }
cotigac 0:c2d52562f36b 250 else
cotigac 0:c2d52562f36b 251 {
cotigac 0:c2d52562f36b 252
cotigac 0:c2d52562f36b 253 #if defined (gHostInterface_RxConfirmationEnable)
cotigac 0:c2d52562f36b 254 if(hostInterface_rxPacket.type == packetType_OK)
cotigac 0:c2d52562f36b 255 {
cotigac 0:c2d52562f36b 256 confirmReceived = true;
cotigac 0:c2d52562f36b 257 }
cotigac 0:c2d52562f36b 258 #endif
cotigac 0:c2d52562f36b 259
cotigac 0:c2d52562f36b 260 /* send message to main task */
cotigac 0:c2d52562f36b 261 hostInterface_packet_t *rxPacket = mpool.alloc();
cotigac 0:c2d52562f36b 262 memcpy(rxPacket, &hostInterface_rxPacket, sizeof(hostInterface_packet_t));
cotigac 0:c2d52562f36b 263 queue.put(rxPacket);
cotigac 0:c2d52562f36b 264
cotigac 0:c2d52562f36b 265 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 266 DebugPrintRxPacket();
cotigac 0:c2d52562f36b 267 #endif
cotigac 0:c2d52562f36b 268 /* reset buffer position */
cotigac 0:c2d52562f36b 269 rxBuff = (uint8_t*)&hostInterface_rxPacket;
cotigac 0:c2d52562f36b 270 }
cotigac 0:c2d52562f36b 271 }
cotigac 0:c2d52562f36b 272 }
cotigac 0:c2d52562f36b 273 }
cotigac 0:c2d52562f36b 274 }
cotigac 0:c2d52562f36b 275
cotigac 0:c2d52562f36b 276 void KW40Z::SearchStartByte()
cotigac 0:c2d52562f36b 277 {
cotigac 0:c2d52562f36b 278 bool found = false;
cotigac 0:c2d52562f36b 279 uint8_t * rdIdx = (uint8_t*)&hostInterface_rxPacket + 1;
cotigac 0:c2d52562f36b 280
cotigac 0:c2d52562f36b 281 while(rdIdx < rxBuff)
cotigac 0:c2d52562f36b 282 {
cotigac 0:c2d52562f36b 283 if(*rdIdx == gHostInterface_startByte1)
cotigac 0:c2d52562f36b 284 {
cotigac 0:c2d52562f36b 285 uint32_t len = rxBuff - rdIdx;
cotigac 0:c2d52562f36b 286
cotigac 0:c2d52562f36b 287 memcpy(&hostInterface_rxPacket,rdIdx,len);
cotigac 0:c2d52562f36b 288 rxBuff -= len;
cotigac 0:c2d52562f36b 289 found = true;
cotigac 0:c2d52562f36b 290
cotigac 0:c2d52562f36b 291 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 292 pc.printf("moving ");
cotigac 0:c2d52562f36b 293 #endif
cotigac 0:c2d52562f36b 294 break;
cotigac 0:c2d52562f36b 295 }
cotigac 0:c2d52562f36b 296 rdIdx++;
cotigac 0:c2d52562f36b 297 }
cotigac 0:c2d52562f36b 298
cotigac 0:c2d52562f36b 299 if(!found)
cotigac 0:c2d52562f36b 300 {
cotigac 0:c2d52562f36b 301 /* reset buffer position */
cotigac 0:c2d52562f36b 302 rxBuff = (uint8_t*)&hostInterface_rxPacket;
cotigac 0:c2d52562f36b 303 }
cotigac 0:c2d52562f36b 304
cotigac 0:c2d52562f36b 305 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 306 pc.printf("search done\r\n");
cotigac 0:c2d52562f36b 307 DebugPrintRxPacket();
cotigac 0:c2d52562f36b 308 #endif
cotigac 0:c2d52562f36b 309 }
cotigac 0:c2d52562f36b 310
cotigac 0:c2d52562f36b 311 void KW40Z::ProcessReceivedPacket(hostInterface_packet_t * rxPacket)
cotigac 0:c2d52562f36b 312 {
cotigac 0:c2d52562f36b 313 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 314 pc.printf("packet found %d\r\n", rxPacket->type);
cotigac 0:c2d52562f36b 315 #endif
cotigac 0:c2d52562f36b 316
cotigac 0:c2d52562f36b 317 #ifdef gHostInterface_TxConfirmationEnable
cotigac 0:c2d52562f36b 318 // acknowledge the packet reception
cotigac 0:c2d52562f36b 319 if ( 1 == ( rxPacket->start2 & 0x01 ) )
cotigac 0:c2d52562f36b 320 {
cotigac 0:c2d52562f36b 321 SendPacketOK();
cotigac 0:c2d52562f36b 322 }
cotigac 0:c2d52562f36b 323 #endif
cotigac 0:c2d52562f36b 324
cotigac 0:c2d52562f36b 325 switch(rxPacket->type)
cotigac 0:c2d52562f36b 326 {
cotigac 0:c2d52562f36b 327 /* button presses */
cotigac 0:c2d52562f36b 328 case packetType_pressUp:
cotigac 1:f6f9b24aea57 329 if(buttonUpCb != NULL) buttonUpCb();
cotigac 1:f6f9b24aea57 330 break;
cotigac 1:f6f9b24aea57 331
cotigac 0:c2d52562f36b 332 case packetType_pressDown:
cotigac 1:f6f9b24aea57 333 if(buttonDownCb != NULL) buttonDownCb();
cotigac 1:f6f9b24aea57 334 break;
cotigac 1:f6f9b24aea57 335
cotigac 0:c2d52562f36b 336 case packetType_pressLeft:
cotigac 1:f6f9b24aea57 337 if(buttonLeftCb != NULL) buttonLeftCb();
cotigac 1:f6f9b24aea57 338 break;
cotigac 1:f6f9b24aea57 339
cotigac 0:c2d52562f36b 340 case packetType_pressRight:
cotigac 1:f6f9b24aea57 341 if(buttonRightCb != NULL) buttonRightCb();
cotigac 1:f6f9b24aea57 342 break;
cotigac 1:f6f9b24aea57 343
cotigac 0:c2d52562f36b 344 case packetType_slide:
cotigac 1:f6f9b24aea57 345 if(buttonSlideCb != NULL) buttonSlideCb();
cotigac 0:c2d52562f36b 346 break;
cotigac 0:c2d52562f36b 347
cotigac 0:c2d52562f36b 348 /* Alert Service */
cotigac 0:c2d52562f36b 349 case packetType_alertIn:
cotigac 1:f6f9b24aea57 350 if(alertCb != NULL) alertCb(&rxPacket->data[0], rxPacket->length);
cotigac 0:c2d52562f36b 351 break;
cotigac 0:c2d52562f36b 352
cotigac 0:c2d52562f36b 353 /* Passkey for pairing received */
cotigac 0:c2d52562f36b 354 case packetType_passDisplay:
khuang 3:9e92f113c671 355 if(passkeyCb != NULL)
khuang 3:9e92f113c671 356 {
khuang 3:9e92f113c671 357 memcpy((uint8_t *)&bondPassKey,&rxPacket->data[0], 3);
khuang 3:9e92f113c671 358 passkeyCb();
khuang 3:9e92f113c671 359 }
cotigac 0:c2d52562f36b 360 break;
cotigac 0:c2d52562f36b 361
cotigac 0:c2d52562f36b 362 /* OTAP messages */
cotigac 0:c2d52562f36b 363 case packetType_otapCompleted:
cotigac 0:c2d52562f36b 364 case packetType_otapFailed:
cotigac 0:c2d52562f36b 365 break;
cotigac 0:c2d52562f36b 366
cotigac 0:c2d52562f36b 367 /* TSI Status */
cotigac 0:c2d52562f36b 368 case packetType_buttonsGroupSendActive:
cotigac 2:bb66c19c3c04 369 activeTsiGroup = rxPacket->data[0];
cotigac 0:c2d52562f36b 370 break;
cotigac 0:c2d52562f36b 371
cotigac 0:c2d52562f36b 372 /* Advertisement Mode Info */
cotigac 0:c2d52562f36b 373 case packetType_advModeSend:
cotigac 2:bb66c19c3c04 374 advertisementMode = rxPacket->data[0];
cotigac 0:c2d52562f36b 375 break;
cotigac 0:c2d52562f36b 376
cotigac 0:c2d52562f36b 377 /* Link State */
cotigac 0:c2d52562f36b 378 case packetType_linkStateSend:
cotigac 2:bb66c19c3c04 379 linkState = rxPacket->data[0];
cotigac 0:c2d52562f36b 380 break;
cotigac 0:c2d52562f36b 381
cotigac 0:c2d52562f36b 382 /* ANCS Service Notification Received */
cotigac 0:c2d52562f36b 383 case packetType_notification:
cotigac 1:f6f9b24aea57 384 if(notificationsCb != NULL) notificationsCb(rxPacket->data[0], rxPacket->data[1]);
cotigac 0:c2d52562f36b 385 break;
cotigac 0:c2d52562f36b 386
cotigac 0:c2d52562f36b 387 /* Build version */
cotigac 0:c2d52562f36b 388 case packetType_buildVersion:
cotigac 2:bb66c19c3c04 389 kw40_version.ver_patchNumber = rxPacket->data[2];
cotigac 2:bb66c19c3c04 390 kw40_version.ver_minorNumber = rxPacket->data[1];
cotigac 2:bb66c19c3c04 391 kw40_version.ver_majorNumber = rxPacket->data[0];
cotigac 0:c2d52562f36b 392 break;
cotigac 0:c2d52562f36b 393
cotigac 0:c2d52562f36b 394 case packetType_OK:
cotigac 0:c2d52562f36b 395 /* do nothing, the flag is set in the RxTask */
cotigac 0:c2d52562f36b 396 break;
cotigac 0:c2d52562f36b 397
cotigac 0:c2d52562f36b 398 default:
cotigac 0:c2d52562f36b 399 break;
cotigac 0:c2d52562f36b 400 }
cotigac 0:c2d52562f36b 401 }
cotigac 2:bb66c19c3c04 402
cotigac 2:bb66c19c3c04 403 void KW40Z::SendBatteryLevel(uint8_t percentage)
cotigac 2:bb66c19c3c04 404 {
cotigac 2:bb66c19c3c04 405 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 406
cotigac 2:bb66c19c3c04 407 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 408 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 409 txPacket.type = packetType_batteryLevel;
cotigac 2:bb66c19c3c04 410 txPacket.length = 1;
cotigac 2:bb66c19c3c04 411 txPacket.data[0] = percentage;
cotigac 2:bb66c19c3c04 412 txPacket.data[1] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 413
cotigac 2:bb66c19c3c04 414 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 415 }
cotigac 2:bb66c19c3c04 416
cotigac 2:bb66c19c3c04 417 void KW40Z::SendAccel(uint8_t x, uint8_t y, uint8_t z)
cotigac 2:bb66c19c3c04 418 {
cotigac 2:bb66c19c3c04 419 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 420
cotigac 2:bb66c19c3c04 421 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 422 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 423 txPacket.type = packetType_accel;
cotigac 2:bb66c19c3c04 424 txPacket.length = 3;
cotigac 2:bb66c19c3c04 425 txPacket.data[0] = x;
cotigac 2:bb66c19c3c04 426 txPacket.data[1] = y;
cotigac 2:bb66c19c3c04 427 txPacket.data[2] = z;
cotigac 2:bb66c19c3c04 428 txPacket.data[3] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 429
cotigac 2:bb66c19c3c04 430 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 431 }
cotigac 2:bb66c19c3c04 432
cotigac 2:bb66c19c3c04 433 void KW40Z::SendGyro(uint8_t x, uint8_t y, uint8_t z)
cotigac 2:bb66c19c3c04 434 {
cotigac 2:bb66c19c3c04 435 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 436
cotigac 2:bb66c19c3c04 437 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 438 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 439 txPacket.type = packetType_gyro;
cotigac 2:bb66c19c3c04 440 txPacket.length = 3;
cotigac 2:bb66c19c3c04 441 txPacket.data[0] = x;
cotigac 2:bb66c19c3c04 442 txPacket.data[1] = y;
cotigac 2:bb66c19c3c04 443 txPacket.data[2] = z;
cotigac 2:bb66c19c3c04 444 txPacket.data[3] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 445
cotigac 2:bb66c19c3c04 446 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 447 }
cotigac 2:bb66c19c3c04 448
cotigac 2:bb66c19c3c04 449 void KW40Z::SendMag(uint8_t x, uint8_t y, uint8_t z)
cotigac 2:bb66c19c3c04 450 {
cotigac 2:bb66c19c3c04 451 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 452
cotigac 2:bb66c19c3c04 453 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 454 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 455 txPacket.type = packetType_magnet;
cotigac 2:bb66c19c3c04 456 txPacket.length = 3;
cotigac 2:bb66c19c3c04 457 txPacket.data[0] = x;
cotigac 2:bb66c19c3c04 458 txPacket.data[1] = y;
cotigac 2:bb66c19c3c04 459 txPacket.data[2] = z;
cotigac 2:bb66c19c3c04 460 txPacket.data[3] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 461
cotigac 2:bb66c19c3c04 462 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 463 }
cotigac 2:bb66c19c3c04 464
cotigac 2:bb66c19c3c04 465 void KW40Z::SendAmbientLight(uint8_t percentage)
cotigac 2:bb66c19c3c04 466 {
cotigac 2:bb66c19c3c04 467 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 468
cotigac 2:bb66c19c3c04 469 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 470 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 471 txPacket.type = packetType_ambiLight;
cotigac 2:bb66c19c3c04 472 txPacket.length = 1;
cotigac 2:bb66c19c3c04 473 txPacket.data[0] = percentage;
cotigac 2:bb66c19c3c04 474 txPacket.data[1] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 475
cotigac 2:bb66c19c3c04 476 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 477 }
cotigac 2:bb66c19c3c04 478
cotigac 2:bb66c19c3c04 479 void KW40Z::SendTemperature(uint16_t celsius)
cotigac 2:bb66c19c3c04 480 {
cotigac 2:bb66c19c3c04 481 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 482
cotigac 2:bb66c19c3c04 483 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 484 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 485 txPacket.type = packetType_temperature;
cotigac 2:bb66c19c3c04 486 txPacket.length = 2;
cotigac 2:bb66c19c3c04 487 memcpy(&txPacket.data[0],(uint8_t*)&celsius,txPacket.length);
cotigac 2:bb66c19c3c04 488 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 489
cotigac 2:bb66c19c3c04 490 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 491 }
cotigac 2:bb66c19c3c04 492
cotigac 2:bb66c19c3c04 493 void KW40Z::SendHumidity(uint16_t percentage)
cotigac 2:bb66c19c3c04 494 {
cotigac 2:bb66c19c3c04 495 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 496
cotigac 2:bb66c19c3c04 497 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 498 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 499 txPacket.type = packetType_humidity;
cotigac 2:bb66c19c3c04 500 txPacket.length = 2;
cotigac 2:bb66c19c3c04 501 memcpy(&txPacket.data[0],(uint8_t*)&percentage,txPacket.length);
cotigac 2:bb66c19c3c04 502 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 503
cotigac 2:bb66c19c3c04 504 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 505 }
cotigac 2:bb66c19c3c04 506
cotigac 2:bb66c19c3c04 507 void KW40Z::SendPressure(uint16_t pascal)
cotigac 2:bb66c19c3c04 508 {
cotigac 2:bb66c19c3c04 509 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 510
cotigac 2:bb66c19c3c04 511 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 512 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 513 txPacket.type = packetType_pressure;
cotigac 2:bb66c19c3c04 514 txPacket.length = 2;
cotigac 2:bb66c19c3c04 515 memcpy(&txPacket.data[0],(uint8_t*)&pascal,txPacket.length);
cotigac 2:bb66c19c3c04 516 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 517
cotigac 2:bb66c19c3c04 518 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 519 }
cotigac 2:bb66c19c3c04 520
khuang 3:9e92f113c671 521 void KW40Z::SendHeartRate(uint8_t rate)
cotigac 2:bb66c19c3c04 522 {
cotigac 2:bb66c19c3c04 523 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 524
cotigac 2:bb66c19c3c04 525 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 526 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 527 txPacket.type = packetType_steps;
cotigac 2:bb66c19c3c04 528 txPacket.length = 1;
cotigac 2:bb66c19c3c04 529 txPacket.data[0] = rate;
cotigac 2:bb66c19c3c04 530 txPacket.data[1] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 531
cotigac 2:bb66c19c3c04 532 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 533 }
cotigac 2:bb66c19c3c04 534
cotigac 2:bb66c19c3c04 535 void KW40Z::SendSteps(uint16_t steps)
cotigac 2:bb66c19c3c04 536 {
cotigac 2:bb66c19c3c04 537 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 538
cotigac 2:bb66c19c3c04 539 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 540 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 541 txPacket.type = packetType_steps;
cotigac 2:bb66c19c3c04 542 txPacket.length = 2;
cotigac 2:bb66c19c3c04 543 memcpy(&txPacket.data[0],(uint8_t*)&steps,txPacket.length);
cotigac 2:bb66c19c3c04 544 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 545
cotigac 2:bb66c19c3c04 546 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 547 }
cotigac 2:bb66c19c3c04 548
cotigac 2:bb66c19c3c04 549 void KW40Z::SendCalories(uint16_t calories)
cotigac 2:bb66c19c3c04 550 {
cotigac 2:bb66c19c3c04 551 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 552
cotigac 2:bb66c19c3c04 553 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 554 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 555 txPacket.type = packetType_calories;
cotigac 2:bb66c19c3c04 556 txPacket.length = 2;
cotigac 2:bb66c19c3c04 557 memcpy(&txPacket.data[0],(uint8_t*)&calories,txPacket.length);
cotigac 2:bb66c19c3c04 558 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 559
cotigac 2:bb66c19c3c04 560 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 561 }
cotigac 2:bb66c19c3c04 562
cotigac 2:bb66c19c3c04 563 void KW40Z::SendAlert(uint8_t *pData, uint8_t length)
cotigac 2:bb66c19c3c04 564 {
cotigac 2:bb66c19c3c04 565 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 566
cotigac 2:bb66c19c3c04 567 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 568 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 569 txPacket.type = packetType_alertOut;
cotigac 2:bb66c19c3c04 570 txPacket.length = length;
cotigac 2:bb66c19c3c04 571 memcpy(&txPacket.data[0],pData,length);
cotigac 2:bb66c19c3c04 572 txPacket.data[length] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 573
cotigac 2:bb66c19c3c04 574 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 575 }
cotigac 2:bb66c19c3c04 576
cotigac 2:bb66c19c3c04 577 void KW40Z::ToggleTsiGroup(void)
cotigac 2:bb66c19c3c04 578 {
cotigac 2:bb66c19c3c04 579 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 580
cotigac 2:bb66c19c3c04 581 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 582 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 583 txPacket.type = packetType_buttonsGroupToggleActive;
cotigac 2:bb66c19c3c04 584 txPacket.length = 0;
cotigac 2:bb66c19c3c04 585 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 586
cotigac 2:bb66c19c3c04 587 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 588 }
cotigac 2:bb66c19c3c04 589
cotigac 2:bb66c19c3c04 590 void KW40Z::ToggleAdvertisementMode(void)
cotigac 2:bb66c19c3c04 591 {
cotigac 2:bb66c19c3c04 592 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 593
cotigac 2:bb66c19c3c04 594 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 595 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 596 txPacket.type = packetType_advModeToggle;
cotigac 2:bb66c19c3c04 597 txPacket.length = 0;
cotigac 2:bb66c19c3c04 598 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 599
cotigac 2:bb66c19c3c04 600 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 601 }
cotigac 2:bb66c19c3c04 602
cotigac 2:bb66c19c3c04 603 void KW40Z::SendSetApplicationMode(gui_current_app_t mode)
cotigac 2:bb66c19c3c04 604 {
cotigac 2:bb66c19c3c04 605 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 606
cotigac 2:bb66c19c3c04 607 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 608 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 609 txPacket.type = packetType_appMode;
cotigac 2:bb66c19c3c04 610 txPacket.length = 1;
cotigac 2:bb66c19c3c04 611 txPacket.data[0] = (uint8_t)mode;
cotigac 2:bb66c19c3c04 612 txPacket.data[1] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 613
cotigac 2:bb66c19c3c04 614 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 615 }
cotigac 2:bb66c19c3c04 616
cotigac 2:bb66c19c3c04 617 void KW40Z::SendGetActiveTsiGroup(void)
cotigac 2:bb66c19c3c04 618 {
cotigac 2:bb66c19c3c04 619 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 620
cotigac 2:bb66c19c3c04 621 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 622 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 623 txPacket.type = packetType_buttonsGroupGetActive;
cotigac 2:bb66c19c3c04 624 txPacket.length = 0;
cotigac 2:bb66c19c3c04 625 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 626
cotigac 2:bb66c19c3c04 627 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 628 }
cotigac 2:bb66c19c3c04 629
cotigac 2:bb66c19c3c04 630 void KW40Z::SendGetAdvertisementMode(void)
cotigac 2:bb66c19c3c04 631 {
cotigac 2:bb66c19c3c04 632 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 633
cotigac 2:bb66c19c3c04 634 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 635 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 636 txPacket.type = packetType_advModeGet;
cotigac 2:bb66c19c3c04 637 txPacket.length = 0;
cotigac 2:bb66c19c3c04 638 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 639
cotigac 2:bb66c19c3c04 640 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 641 }
cotigac 2:bb66c19c3c04 642
cotigac 2:bb66c19c3c04 643 void KW40Z::SendGetLinkState(void)
cotigac 2:bb66c19c3c04 644 {
cotigac 2:bb66c19c3c04 645 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 646
cotigac 2:bb66c19c3c04 647 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 648 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 649 txPacket.type = packetType_linkStateGet;
cotigac 2:bb66c19c3c04 650 txPacket.length = 0;
cotigac 2:bb66c19c3c04 651 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 652
cotigac 2:bb66c19c3c04 653 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 654 }
cotigac 2:bb66c19c3c04 655
cotigac 2:bb66c19c3c04 656 void KW40Z::SendGetVersion(void)
cotigac 2:bb66c19c3c04 657 {
cotigac 2:bb66c19c3c04 658 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 659
cotigac 2:bb66c19c3c04 660 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 661 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 662 txPacket.type = packetType_buildVersion;
cotigac 2:bb66c19c3c04 663 txPacket.length = 3;
cotigac 2:bb66c19c3c04 664 txPacket.data[0] = HEXIWEAR_VERSION_MAJOR;
cotigac 2:bb66c19c3c04 665 txPacket.data[1] = HEXIWEAR_VERSION_MINOR;
cotigac 2:bb66c19c3c04 666 txPacket.data[2] = HEXIWEAR_VERSION_PATCH;
cotigac 2:bb66c19c3c04 667 txPacket.data[3] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 668
cotigac 2:bb66c19c3c04 669 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 670 }
cotigac 2:bb66c19c3c04 671
cotigac 2:bb66c19c3c04 672 void KW40Z::SendPacketOK(void)
cotigac 2:bb66c19c3c04 673 {
cotigac 2:bb66c19c3c04 674 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 675
cotigac 2:bb66c19c3c04 676 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 677 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 678 txPacket.type = packetType_OK;
cotigac 2:bb66c19c3c04 679 txPacket.length = 0;
cotigac 2:bb66c19c3c04 680 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 681
cotigac 2:bb66c19c3c04 682 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 683 }
khuang 3:9e92f113c671 684
khuang 3:9e92f113c671 685 uint8_t KW40Z::GetAdvertisementMode(void)
khuang 3:9e92f113c671 686 {
khuang 3:9e92f113c671 687 return advertisementMode;
khuang 3:9e92f113c671 688 }
khuang 3:9e92f113c671 689
khuang 3:9e92f113c671 690 uint32_t KW40Z::GetPassKey(void)
khuang 3:9e92f113c671 691 {
khuang 3:9e92f113c671 692 return bondPassKey;
khuang 3:9e92f113c671 693 }
khuang 3:9e92f113c671 694