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

Dependents:   Hexi_Buttons_Example Hexi_Click_Relay-v2_Example Hexi_Click_Relay-v3_Example Hexi_Catch-the-dot_Game ... more

Committer:
cotigac
Date:
Mon Sep 19 05:45:31 2016 +0000
Revision:
2:bb66c19c3c04
Parent:
1:f6f9b24aea57
Child:
3:9e92f113c671
Added BLE primitives -- not tested yet

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;
cotigac 0:c2d52562f36b 71
cotigac 0:c2d52562f36b 72 /* intialization finalized, signal to start the threads */
cotigac 0:c2d52562f36b 73 mainThread.signal_set(START_THREAD);
cotigac 0:c2d52562f36b 74 rxThread.signal_set(START_THREAD);
cotigac 0:c2d52562f36b 75 }
cotigac 0:c2d52562f36b 76
cotigac 0:c2d52562f36b 77 KW40Z::~KW40Z(void)
cotigac 0:c2d52562f36b 78 {
cotigac 0:c2d52562f36b 79 }
cotigac 0:c2d52562f36b 80
cotigac 2:bb66c19c3c04 81 void KW40Z::attach_buttonUp(button_t btnFct) { buttonUpCb = btnFct; }
cotigac 2:bb66c19c3c04 82 void KW40Z::attach_buttonDown(button_t btnFct) { buttonDownCb = btnFct; }
cotigac 2:bb66c19c3c04 83 void KW40Z::attach_buttonLeft(button_t btnFct) { buttonLeftCb = btnFct; }
cotigac 2:bb66c19c3c04 84 void KW40Z::attach_buttonRight(button_t btnFct) { buttonRightCb = btnFct; }
cotigac 2:bb66c19c3c04 85 void KW40Z::attach_buttonSlide(button_t btnFct) { buttonSlideCb = btnFct; }
cotigac 2:bb66c19c3c04 86 void KW40Z::attach_alert(alert_t alertFct) { alertCb = alertFct; }
cotigac 2:bb66c19c3c04 87 void KW40Z::attach_passkey(passkey_t passkeyFct){ passkeyCb = passkeyFct; }
cotigac 2:bb66c19c3c04 88 void KW40Z::attach_notifications(notifications_t notFct) { notificationsCb = notFct; }
cotigac 0:c2d52562f36b 89
cotigac 0:c2d52562f36b 90 void KW40Z::rxStarter(void const *p) {
cotigac 0:c2d52562f36b 91 KW40Z *instance = (KW40Z*)p;
cotigac 0:c2d52562f36b 92 instance->rxTask();
cotigac 0:c2d52562f36b 93 }
cotigac 0:c2d52562f36b 94
cotigac 0:c2d52562f36b 95 void KW40Z::mainStarter(void const *p) {
cotigac 0:c2d52562f36b 96 KW40Z *instance = (KW40Z*)p;
cotigac 0:c2d52562f36b 97 instance->mainTask();
cotigac 0:c2d52562f36b 98 }
cotigac 0:c2d52562f36b 99
cotigac 0:c2d52562f36b 100 void KW40Z::mainTask(void)
cotigac 0:c2d52562f36b 101 {
cotigac 0:c2d52562f36b 102 mainThread.signal_wait(START_THREAD);
cotigac 0:c2d52562f36b 103
cotigac 0:c2d52562f36b 104 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 105 pc.printf("MainTask Stared\r\n");
cotigac 0:c2d52562f36b 106 #endif
cotigac 0:c2d52562f36b 107
cotigac 2:bb66c19c3c04 108 #if 0
cotigac 2:bb66c19c3c04 109 SendGetActiveTsiGroup();
cotigac 2:bb66c19c3c04 110 SendGetAdvertisementMode();
cotigac 2:bb66c19c3c04 111 SendGetLinkState();
cotigac 2:bb66c19c3c04 112 SendGetVersion();
cotigac 2:bb66c19c3c04 113 #endif
cotigac 2:bb66c19c3c04 114
cotigac 0:c2d52562f36b 115 while(1)
cotigac 0:c2d52562f36b 116 {
cotigac 0:c2d52562f36b 117 osEvent evt = queue.get();
cotigac 0:c2d52562f36b 118 if (evt.status == osEventMessage)
cotigac 0:c2d52562f36b 119 {
cotigac 0:c2d52562f36b 120 hostInterface_packet_t *rxPacket = (hostInterface_packet_t*)evt.value.p;
cotigac 0:c2d52562f36b 121 ProcessReceivedPacket(rxPacket);
cotigac 0:c2d52562f36b 122 mpool.free(rxPacket);
cotigac 0:c2d52562f36b 123 }
cotigac 0:c2d52562f36b 124 }
cotigac 0:c2d52562f36b 125 }
cotigac 0:c2d52562f36b 126
cotigac 0:c2d52562f36b 127 void KW40Z::rxTask(void)
cotigac 0:c2d52562f36b 128 {
cotigac 0:c2d52562f36b 129 rxThread.signal_wait(START_THREAD);
cotigac 0:c2d52562f36b 130
cotigac 0:c2d52562f36b 131 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 132 pc.printf("RxTask Stared\r\n");
cotigac 0:c2d52562f36b 133 #endif
cotigac 0:c2d52562f36b 134
cotigac 0:c2d52562f36b 135 while(1)
cotigac 0:c2d52562f36b 136 {
cotigac 0:c2d52562f36b 137 if(device.readable())
cotigac 0:c2d52562f36b 138 {
cotigac 0:c2d52562f36b 139 *rxBuff++ = device.getc();
cotigac 0:c2d52562f36b 140 ProcessBuffer();
cotigac 0:c2d52562f36b 141
cotigac 0:c2d52562f36b 142 /* check for buffer overflow */
cotigac 0:c2d52562f36b 143 if(rxBuff >= ((uint8_t*)&hostInterface_rxPacket + sizeof(hostInterface_rxPacket)))
cotigac 0:c2d52562f36b 144 {
cotigac 0:c2d52562f36b 145 rxBuff = (uint8_t*)&hostInterface_rxPacket;
cotigac 0:c2d52562f36b 146 }
cotigac 0:c2d52562f36b 147 }
cotigac 0:c2d52562f36b 148 }
cotigac 0:c2d52562f36b 149 }
cotigac 0:c2d52562f36b 150
cotigac 0:c2d52562f36b 151 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 152 void KW40Z::DebugPrintTxPacket(hostInterface_packet_t * txPacket)
cotigac 0:c2d52562f36b 153 {
cotigac 0:c2d52562f36b 154 char * txBuff = (char *)txPacket;
cotigac 0:c2d52562f36b 155 uint8_t length = txPacket->length + gHostInterface_headerSize + 1;
cotigac 0:c2d52562f36b 156
cotigac 0:c2d52562f36b 157 pc.printf("Tx: ");
cotigac 0:c2d52562f36b 158 for(uint8_t i = 0; i < length; i++)
cotigac 0:c2d52562f36b 159 {
cotigac 0:c2d52562f36b 160 pc.printf("%02X ",*txBuff);
cotigac 0:c2d52562f36b 161 txBuff++;
cotigac 0:c2d52562f36b 162 }
cotigac 0:c2d52562f36b 163 pc.printf("\r\n");
cotigac 0:c2d52562f36b 164 }
cotigac 0:c2d52562f36b 165
cotigac 0:c2d52562f36b 166 void KW40Z::DebugPrintRxPacket()
cotigac 0:c2d52562f36b 167 {
cotigac 0:c2d52562f36b 168 pc.printf("RX: ");
cotigac 0:c2d52562f36b 169 for(uint8_t * i = (uint8_t*)&hostInterface_rxPacket; i<rxBuff; i++)
cotigac 0:c2d52562f36b 170 {
cotigac 0:c2d52562f36b 171 pc.printf("%02X ",*i);
cotigac 0:c2d52562f36b 172 }
cotigac 0:c2d52562f36b 173 pc.printf("\r\n");
cotigac 0:c2d52562f36b 174 }
cotigac 0:c2d52562f36b 175 #endif
cotigac 0:c2d52562f36b 176
cotigac 2:bb66c19c3c04 177
cotigac 2:bb66c19c3c04 178 void KW40Z::SendPacket(hostInterface_packet_t * txPacket, bool confirmRequested)
cotigac 2:bb66c19c3c04 179 {
cotigac 2:bb66c19c3c04 180 uint8_t retries = 0;
cotigac 2:bb66c19c3c04 181 confirmReceived = false;
cotigac 2:bb66c19c3c04 182
cotigac 2:bb66c19c3c04 183 do
cotigac 2:bb66c19c3c04 184 {
cotigac 2:bb66c19c3c04 185 char * txBuff = (char *)txPacket;
cotigac 2:bb66c19c3c04 186 uint8_t length = txPacket->length + gHostInterface_headerSize + 1;
cotigac 2:bb66c19c3c04 187
cotigac 2:bb66c19c3c04 188 if(confirmRequested == true)
cotigac 2:bb66c19c3c04 189 {
cotigac 2:bb66c19c3c04 190 txPacket->start2 |= 0x01;
cotigac 2:bb66c19c3c04 191 }
cotigac 2:bb66c19c3c04 192
cotigac 2:bb66c19c3c04 193 for(uint8_t i = 0; i < length; i++)
cotigac 2:bb66c19c3c04 194 {
cotigac 2:bb66c19c3c04 195 device.putc(*txBuff);
cotigac 2:bb66c19c3c04 196 txBuff++;
cotigac 2:bb66c19c3c04 197 }
cotigac 2:bb66c19c3c04 198
cotigac 2:bb66c19c3c04 199 #if defined (LIB_DEBUG)
cotigac 2:bb66c19c3c04 200 DebugPrintTxPacket(txPacket);
cotigac 2:bb66c19c3c04 201 #endif
cotigac 2:bb66c19c3c04 202
cotigac 2:bb66c19c3c04 203 retries++;
cotigac 2:bb66c19c3c04 204
cotigac 2:bb66c19c3c04 205 #if defined (gHostInterface_RxConfirmationEnable)
cotigac 2:bb66c19c3c04 206 if((confirmRequested == true) && (confirmReceived == false))
cotigac 2:bb66c19c3c04 207 {
cotigac 2:bb66c19c3c04 208 Thread::wait(gHostInterface_retransmitTimeout);
cotigac 2:bb66c19c3c04 209 }
cotigac 2:bb66c19c3c04 210 #endif
cotigac 2:bb66c19c3c04 211 }
cotigac 2:bb66c19c3c04 212 while((confirmRequested == true) &&
cotigac 2:bb66c19c3c04 213 (confirmReceived == false) &&
cotigac 2:bb66c19c3c04 214 (retries < gHostInterface_retransmitCount));
cotigac 2:bb66c19c3c04 215 }
cotigac 2:bb66c19c3c04 216
cotigac 0:c2d52562f36b 217 void KW40Z::ProcessBuffer()
cotigac 0:c2d52562f36b 218 {
cotigac 0:c2d52562f36b 219 /* check if header has been received */
cotigac 0:c2d52562f36b 220 if(rxBuff > ((uint8_t*)&hostInterface_rxPacket + gHostInterface_headerSize))
cotigac 0:c2d52562f36b 221 {
cotigac 0:c2d52562f36b 222 /* check packet header */
cotigac 0:c2d52562f36b 223 if((gHostInterface_startByte1 != hostInterface_rxPacket.start1)||
cotigac 0:c2d52562f36b 224 (gHostInterface_startByte2 != (hostInterface_rxPacket.start2 & 0xFE))||
cotigac 0:c2d52562f36b 225 (hostInterface_rxPacket.length > gHostInterface_dataSize))
cotigac 0:c2d52562f36b 226 {
cotigac 0:c2d52562f36b 227 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 228 DebugPrintRxPacket();
cotigac 0:c2d52562f36b 229 pc.printf("check header failed\r\n");
cotigac 0:c2d52562f36b 230 #endif
cotigac 0:c2d52562f36b 231
cotigac 0:c2d52562f36b 232 SearchStartByte();
cotigac 0:c2d52562f36b 233 }
cotigac 0:c2d52562f36b 234 else
cotigac 0:c2d52562f36b 235 {
cotigac 0:c2d52562f36b 236 /* check data length */
cotigac 0:c2d52562f36b 237 if(rxBuff > ((uint8_t*)&hostInterface_rxPacket + gHostInterface_headerSize + hostInterface_rxPacket.length))
cotigac 0:c2d52562f36b 238 {
cotigac 0:c2d52562f36b 239 /* check trailer byte */
cotigac 0:c2d52562f36b 240 if(gHostInterface_trailerByte != hostInterface_rxPacket.data[hostInterface_rxPacket.length])
cotigac 0:c2d52562f36b 241 {
cotigac 0:c2d52562f36b 242 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 243 DebugPrintRxPacket();
cotigac 0:c2d52562f36b 244 pc.printf("trailer byte failed\r\n");
cotigac 0:c2d52562f36b 245 #endif
cotigac 0:c2d52562f36b 246
cotigac 0:c2d52562f36b 247 SearchStartByte();
cotigac 0:c2d52562f36b 248 }
cotigac 0:c2d52562f36b 249 else
cotigac 0:c2d52562f36b 250 {
cotigac 0:c2d52562f36b 251
cotigac 0:c2d52562f36b 252 #if defined (gHostInterface_RxConfirmationEnable)
cotigac 0:c2d52562f36b 253 if(hostInterface_rxPacket.type == packetType_OK)
cotigac 0:c2d52562f36b 254 {
cotigac 0:c2d52562f36b 255 confirmReceived = true;
cotigac 0:c2d52562f36b 256 }
cotigac 0:c2d52562f36b 257 #endif
cotigac 0:c2d52562f36b 258
cotigac 0:c2d52562f36b 259 /* send message to main task */
cotigac 0:c2d52562f36b 260 hostInterface_packet_t *rxPacket = mpool.alloc();
cotigac 0:c2d52562f36b 261 memcpy(rxPacket, &hostInterface_rxPacket, sizeof(hostInterface_packet_t));
cotigac 0:c2d52562f36b 262 queue.put(rxPacket);
cotigac 0:c2d52562f36b 263
cotigac 0:c2d52562f36b 264 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 265 DebugPrintRxPacket();
cotigac 0:c2d52562f36b 266 #endif
cotigac 0:c2d52562f36b 267 /* reset buffer position */
cotigac 0:c2d52562f36b 268 rxBuff = (uint8_t*)&hostInterface_rxPacket;
cotigac 0:c2d52562f36b 269 }
cotigac 0:c2d52562f36b 270 }
cotigac 0:c2d52562f36b 271 }
cotigac 0:c2d52562f36b 272 }
cotigac 0:c2d52562f36b 273 }
cotigac 0:c2d52562f36b 274
cotigac 0:c2d52562f36b 275 void KW40Z::SearchStartByte()
cotigac 0:c2d52562f36b 276 {
cotigac 0:c2d52562f36b 277 bool found = false;
cotigac 0:c2d52562f36b 278 uint8_t * rdIdx = (uint8_t*)&hostInterface_rxPacket + 1;
cotigac 0:c2d52562f36b 279
cotigac 0:c2d52562f36b 280 while(rdIdx < rxBuff)
cotigac 0:c2d52562f36b 281 {
cotigac 0:c2d52562f36b 282 if(*rdIdx == gHostInterface_startByte1)
cotigac 0:c2d52562f36b 283 {
cotigac 0:c2d52562f36b 284 uint32_t len = rxBuff - rdIdx;
cotigac 0:c2d52562f36b 285
cotigac 0:c2d52562f36b 286 memcpy(&hostInterface_rxPacket,rdIdx,len);
cotigac 0:c2d52562f36b 287 rxBuff -= len;
cotigac 0:c2d52562f36b 288 found = true;
cotigac 0:c2d52562f36b 289
cotigac 0:c2d52562f36b 290 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 291 pc.printf("moving ");
cotigac 0:c2d52562f36b 292 #endif
cotigac 0:c2d52562f36b 293 break;
cotigac 0:c2d52562f36b 294 }
cotigac 0:c2d52562f36b 295 rdIdx++;
cotigac 0:c2d52562f36b 296 }
cotigac 0:c2d52562f36b 297
cotigac 0:c2d52562f36b 298 if(!found)
cotigac 0:c2d52562f36b 299 {
cotigac 0:c2d52562f36b 300 /* reset buffer position */
cotigac 0:c2d52562f36b 301 rxBuff = (uint8_t*)&hostInterface_rxPacket;
cotigac 0:c2d52562f36b 302 }
cotigac 0:c2d52562f36b 303
cotigac 0:c2d52562f36b 304 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 305 pc.printf("search done\r\n");
cotigac 0:c2d52562f36b 306 DebugPrintRxPacket();
cotigac 0:c2d52562f36b 307 #endif
cotigac 0:c2d52562f36b 308 }
cotigac 0:c2d52562f36b 309
cotigac 0:c2d52562f36b 310 void KW40Z::ProcessReceivedPacket(hostInterface_packet_t * rxPacket)
cotigac 0:c2d52562f36b 311 {
cotigac 0:c2d52562f36b 312 #if defined (LIB_DEBUG)
cotigac 0:c2d52562f36b 313 pc.printf("packet found %d\r\n", rxPacket->type);
cotigac 0:c2d52562f36b 314 #endif
cotigac 0:c2d52562f36b 315
cotigac 0:c2d52562f36b 316 #ifdef gHostInterface_TxConfirmationEnable
cotigac 0:c2d52562f36b 317 // acknowledge the packet reception
cotigac 0:c2d52562f36b 318 if ( 1 == ( rxPacket->start2 & 0x01 ) )
cotigac 0:c2d52562f36b 319 {
cotigac 0:c2d52562f36b 320 SendPacketOK();
cotigac 0:c2d52562f36b 321 }
cotigac 0:c2d52562f36b 322 #endif
cotigac 0:c2d52562f36b 323
cotigac 0:c2d52562f36b 324 switch(rxPacket->type)
cotigac 0:c2d52562f36b 325 {
cotigac 0:c2d52562f36b 326 /* button presses */
cotigac 0:c2d52562f36b 327 case packetType_pressUp:
cotigac 1:f6f9b24aea57 328 if(buttonUpCb != NULL) buttonUpCb();
cotigac 1:f6f9b24aea57 329 break;
cotigac 1:f6f9b24aea57 330
cotigac 0:c2d52562f36b 331 case packetType_pressDown:
cotigac 1:f6f9b24aea57 332 if(buttonDownCb != NULL) buttonDownCb();
cotigac 1:f6f9b24aea57 333 break;
cotigac 1:f6f9b24aea57 334
cotigac 0:c2d52562f36b 335 case packetType_pressLeft:
cotigac 1:f6f9b24aea57 336 if(buttonLeftCb != NULL) buttonLeftCb();
cotigac 1:f6f9b24aea57 337 break;
cotigac 1:f6f9b24aea57 338
cotigac 0:c2d52562f36b 339 case packetType_pressRight:
cotigac 1:f6f9b24aea57 340 if(buttonRightCb != NULL) buttonRightCb();
cotigac 1:f6f9b24aea57 341 break;
cotigac 1:f6f9b24aea57 342
cotigac 0:c2d52562f36b 343 case packetType_slide:
cotigac 1:f6f9b24aea57 344 if(buttonSlideCb != NULL) buttonSlideCb();
cotigac 0:c2d52562f36b 345 break;
cotigac 0:c2d52562f36b 346
cotigac 0:c2d52562f36b 347 /* Alert Service */
cotigac 0:c2d52562f36b 348 case packetType_alertIn:
cotigac 1:f6f9b24aea57 349 if(alertCb != NULL) alertCb(&rxPacket->data[0], rxPacket->length);
cotigac 0:c2d52562f36b 350 break;
cotigac 0:c2d52562f36b 351
cotigac 0:c2d52562f36b 352 /* Passkey for pairing received */
cotigac 0:c2d52562f36b 353 case packetType_passDisplay:
cotigac 1:f6f9b24aea57 354 if(passkeyCb != NULL) passkeyCb(&rxPacket->data[0]);
cotigac 0:c2d52562f36b 355 break;
cotigac 0:c2d52562f36b 356
cotigac 0:c2d52562f36b 357 /* OTAP messages */
cotigac 0:c2d52562f36b 358 case packetType_otapCompleted:
cotigac 0:c2d52562f36b 359 case packetType_otapFailed:
cotigac 0:c2d52562f36b 360 break;
cotigac 0:c2d52562f36b 361
cotigac 0:c2d52562f36b 362 /* TSI Status */
cotigac 0:c2d52562f36b 363 case packetType_buttonsGroupSendActive:
cotigac 2:bb66c19c3c04 364 activeTsiGroup = rxPacket->data[0];
cotigac 0:c2d52562f36b 365 break;
cotigac 0:c2d52562f36b 366
cotigac 0:c2d52562f36b 367 /* Advertisement Mode Info */
cotigac 0:c2d52562f36b 368 case packetType_advModeSend:
cotigac 2:bb66c19c3c04 369 advertisementMode = rxPacket->data[0];
cotigac 0:c2d52562f36b 370 break;
cotigac 0:c2d52562f36b 371
cotigac 0:c2d52562f36b 372 /* Link State */
cotigac 0:c2d52562f36b 373 case packetType_linkStateSend:
cotigac 2:bb66c19c3c04 374 linkState = rxPacket->data[0];
cotigac 0:c2d52562f36b 375 break;
cotigac 0:c2d52562f36b 376
cotigac 0:c2d52562f36b 377 /* ANCS Service Notification Received */
cotigac 0:c2d52562f36b 378 case packetType_notification:
cotigac 1:f6f9b24aea57 379 if(notificationsCb != NULL) notificationsCb(rxPacket->data[0], rxPacket->data[1]);
cotigac 0:c2d52562f36b 380 break;
cotigac 0:c2d52562f36b 381
cotigac 0:c2d52562f36b 382 /* Build version */
cotigac 0:c2d52562f36b 383 case packetType_buildVersion:
cotigac 2:bb66c19c3c04 384 kw40_version.ver_patchNumber = rxPacket->data[2];
cotigac 2:bb66c19c3c04 385 kw40_version.ver_minorNumber = rxPacket->data[1];
cotigac 2:bb66c19c3c04 386 kw40_version.ver_majorNumber = rxPacket->data[0];
cotigac 0:c2d52562f36b 387 break;
cotigac 0:c2d52562f36b 388
cotigac 0:c2d52562f36b 389 case packetType_OK:
cotigac 0:c2d52562f36b 390 /* do nothing, the flag is set in the RxTask */
cotigac 0:c2d52562f36b 391 break;
cotigac 0:c2d52562f36b 392
cotigac 0:c2d52562f36b 393 default:
cotigac 0:c2d52562f36b 394 break;
cotigac 0:c2d52562f36b 395 }
cotigac 0:c2d52562f36b 396 }
cotigac 2:bb66c19c3c04 397
cotigac 2:bb66c19c3c04 398 void KW40Z::SendBatteryLevel(uint8_t percentage)
cotigac 2:bb66c19c3c04 399 {
cotigac 2:bb66c19c3c04 400 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 401
cotigac 2:bb66c19c3c04 402 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 403 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 404 txPacket.type = packetType_batteryLevel;
cotigac 2:bb66c19c3c04 405 txPacket.length = 1;
cotigac 2:bb66c19c3c04 406 txPacket.data[0] = percentage;
cotigac 2:bb66c19c3c04 407 txPacket.data[1] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 408
cotigac 2:bb66c19c3c04 409 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 410 }
cotigac 2:bb66c19c3c04 411
cotigac 2:bb66c19c3c04 412 void KW40Z::SendAccel(uint8_t x, uint8_t y, uint8_t z)
cotigac 2:bb66c19c3c04 413 {
cotigac 2:bb66c19c3c04 414 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 415
cotigac 2:bb66c19c3c04 416 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 417 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 418 txPacket.type = packetType_accel;
cotigac 2:bb66c19c3c04 419 txPacket.length = 3;
cotigac 2:bb66c19c3c04 420 txPacket.data[0] = x;
cotigac 2:bb66c19c3c04 421 txPacket.data[1] = y;
cotigac 2:bb66c19c3c04 422 txPacket.data[2] = z;
cotigac 2:bb66c19c3c04 423 txPacket.data[3] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 424
cotigac 2:bb66c19c3c04 425 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 426 }
cotigac 2:bb66c19c3c04 427
cotigac 2:bb66c19c3c04 428 void KW40Z::SendGyro(uint8_t x, uint8_t y, uint8_t z)
cotigac 2:bb66c19c3c04 429 {
cotigac 2:bb66c19c3c04 430 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 431
cotigac 2:bb66c19c3c04 432 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 433 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 434 txPacket.type = packetType_gyro;
cotigac 2:bb66c19c3c04 435 txPacket.length = 3;
cotigac 2:bb66c19c3c04 436 txPacket.data[0] = x;
cotigac 2:bb66c19c3c04 437 txPacket.data[1] = y;
cotigac 2:bb66c19c3c04 438 txPacket.data[2] = z;
cotigac 2:bb66c19c3c04 439 txPacket.data[3] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 440
cotigac 2:bb66c19c3c04 441 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 442 }
cotigac 2:bb66c19c3c04 443
cotigac 2:bb66c19c3c04 444 void KW40Z::SendMag(uint8_t x, uint8_t y, uint8_t z)
cotigac 2:bb66c19c3c04 445 {
cotigac 2:bb66c19c3c04 446 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 447
cotigac 2:bb66c19c3c04 448 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 449 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 450 txPacket.type = packetType_magnet;
cotigac 2:bb66c19c3c04 451 txPacket.length = 3;
cotigac 2:bb66c19c3c04 452 txPacket.data[0] = x;
cotigac 2:bb66c19c3c04 453 txPacket.data[1] = y;
cotigac 2:bb66c19c3c04 454 txPacket.data[2] = z;
cotigac 2:bb66c19c3c04 455 txPacket.data[3] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 456
cotigac 2:bb66c19c3c04 457 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 458 }
cotigac 2:bb66c19c3c04 459
cotigac 2:bb66c19c3c04 460 void KW40Z::SendAmbientLight(uint8_t percentage)
cotigac 2:bb66c19c3c04 461 {
cotigac 2:bb66c19c3c04 462 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 463
cotigac 2:bb66c19c3c04 464 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 465 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 466 txPacket.type = packetType_ambiLight;
cotigac 2:bb66c19c3c04 467 txPacket.length = 1;
cotigac 2:bb66c19c3c04 468 txPacket.data[0] = percentage;
cotigac 2:bb66c19c3c04 469 txPacket.data[1] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 470
cotigac 2:bb66c19c3c04 471 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 472 }
cotigac 2:bb66c19c3c04 473
cotigac 2:bb66c19c3c04 474 void KW40Z::SendTemperature(uint16_t celsius)
cotigac 2:bb66c19c3c04 475 {
cotigac 2:bb66c19c3c04 476 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 477
cotigac 2:bb66c19c3c04 478 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 479 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 480 txPacket.type = packetType_temperature;
cotigac 2:bb66c19c3c04 481 txPacket.length = 2;
cotigac 2:bb66c19c3c04 482 memcpy(&txPacket.data[0],(uint8_t*)&celsius,txPacket.length);
cotigac 2:bb66c19c3c04 483 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 484
cotigac 2:bb66c19c3c04 485 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 486 }
cotigac 2:bb66c19c3c04 487
cotigac 2:bb66c19c3c04 488 void KW40Z::SendHumidity(uint16_t percentage)
cotigac 2:bb66c19c3c04 489 {
cotigac 2:bb66c19c3c04 490 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 491
cotigac 2:bb66c19c3c04 492 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 493 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 494 txPacket.type = packetType_humidity;
cotigac 2:bb66c19c3c04 495 txPacket.length = 2;
cotigac 2:bb66c19c3c04 496 memcpy(&txPacket.data[0],(uint8_t*)&percentage,txPacket.length);
cotigac 2:bb66c19c3c04 497 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 498
cotigac 2:bb66c19c3c04 499 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 500 }
cotigac 2:bb66c19c3c04 501
cotigac 2:bb66c19c3c04 502 void KW40Z::SendPressure(uint16_t pascal)
cotigac 2:bb66c19c3c04 503 {
cotigac 2:bb66c19c3c04 504 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 505
cotigac 2:bb66c19c3c04 506 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 507 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 508 txPacket.type = packetType_pressure;
cotigac 2:bb66c19c3c04 509 txPacket.length = 2;
cotigac 2:bb66c19c3c04 510 memcpy(&txPacket.data[0],(uint8_t*)&pascal,txPacket.length);
cotigac 2:bb66c19c3c04 511 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 512
cotigac 2:bb66c19c3c04 513 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 514 }
cotigac 2:bb66c19c3c04 515
cotigac 2:bb66c19c3c04 516 void KW40Z::SendHearRate(uint8_t rate)
cotigac 2:bb66c19c3c04 517 {
cotigac 2:bb66c19c3c04 518 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 519
cotigac 2:bb66c19c3c04 520 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 521 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 522 txPacket.type = packetType_steps;
cotigac 2:bb66c19c3c04 523 txPacket.length = 1;
cotigac 2:bb66c19c3c04 524 txPacket.data[0] = rate;
cotigac 2:bb66c19c3c04 525 txPacket.data[1] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 526
cotigac 2:bb66c19c3c04 527 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 528 }
cotigac 2:bb66c19c3c04 529
cotigac 2:bb66c19c3c04 530 void KW40Z::SendSteps(uint16_t steps)
cotigac 2:bb66c19c3c04 531 {
cotigac 2:bb66c19c3c04 532 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 533
cotigac 2:bb66c19c3c04 534 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 535 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 536 txPacket.type = packetType_steps;
cotigac 2:bb66c19c3c04 537 txPacket.length = 2;
cotigac 2:bb66c19c3c04 538 memcpy(&txPacket.data[0],(uint8_t*)&steps,txPacket.length);
cotigac 2:bb66c19c3c04 539 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 540
cotigac 2:bb66c19c3c04 541 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 542 }
cotigac 2:bb66c19c3c04 543
cotigac 2:bb66c19c3c04 544 void KW40Z::SendCalories(uint16_t calories)
cotigac 2:bb66c19c3c04 545 {
cotigac 2:bb66c19c3c04 546 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 547
cotigac 2:bb66c19c3c04 548 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 549 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 550 txPacket.type = packetType_calories;
cotigac 2:bb66c19c3c04 551 txPacket.length = 2;
cotigac 2:bb66c19c3c04 552 memcpy(&txPacket.data[0],(uint8_t*)&calories,txPacket.length);
cotigac 2:bb66c19c3c04 553 txPacket.data[2] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 554
cotigac 2:bb66c19c3c04 555 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 556 }
cotigac 2:bb66c19c3c04 557
cotigac 2:bb66c19c3c04 558 void KW40Z::SendAlert(uint8_t *pData, uint8_t length)
cotigac 2:bb66c19c3c04 559 {
cotigac 2:bb66c19c3c04 560 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 561
cotigac 2:bb66c19c3c04 562 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 563 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 564 txPacket.type = packetType_alertOut;
cotigac 2:bb66c19c3c04 565 txPacket.length = length;
cotigac 2:bb66c19c3c04 566 memcpy(&txPacket.data[0],pData,length);
cotigac 2:bb66c19c3c04 567 txPacket.data[length] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 568
cotigac 2:bb66c19c3c04 569 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 570 }
cotigac 2:bb66c19c3c04 571
cotigac 2:bb66c19c3c04 572 void KW40Z::ToggleTsiGroup(void)
cotigac 2:bb66c19c3c04 573 {
cotigac 2:bb66c19c3c04 574 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 575
cotigac 2:bb66c19c3c04 576 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 577 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 578 txPacket.type = packetType_buttonsGroupToggleActive;
cotigac 2:bb66c19c3c04 579 txPacket.length = 0;
cotigac 2:bb66c19c3c04 580 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 581
cotigac 2:bb66c19c3c04 582 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 583 }
cotigac 2:bb66c19c3c04 584
cotigac 2:bb66c19c3c04 585 void KW40Z::ToggleAdvertisementMode(void)
cotigac 2:bb66c19c3c04 586 {
cotigac 2:bb66c19c3c04 587 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 588
cotigac 2:bb66c19c3c04 589 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 590 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 591 txPacket.type = packetType_advModeToggle;
cotigac 2:bb66c19c3c04 592 txPacket.length = 0;
cotigac 2:bb66c19c3c04 593 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 594
cotigac 2:bb66c19c3c04 595 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 596 }
cotigac 2:bb66c19c3c04 597
cotigac 2:bb66c19c3c04 598 void KW40Z::SendSetApplicationMode(gui_current_app_t mode)
cotigac 2:bb66c19c3c04 599 {
cotigac 2:bb66c19c3c04 600 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 601
cotigac 2:bb66c19c3c04 602 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 603 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 604 txPacket.type = packetType_appMode;
cotigac 2:bb66c19c3c04 605 txPacket.length = 1;
cotigac 2:bb66c19c3c04 606 txPacket.data[0] = (uint8_t)mode;
cotigac 2:bb66c19c3c04 607 txPacket.data[1] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 608
cotigac 2:bb66c19c3c04 609 SendPacket(&txPacket, true);
cotigac 2:bb66c19c3c04 610 }
cotigac 2:bb66c19c3c04 611
cotigac 2:bb66c19c3c04 612 void KW40Z::SendGetActiveTsiGroup(void)
cotigac 2:bb66c19c3c04 613 {
cotigac 2:bb66c19c3c04 614 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 615
cotigac 2:bb66c19c3c04 616 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 617 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 618 txPacket.type = packetType_buttonsGroupGetActive;
cotigac 2:bb66c19c3c04 619 txPacket.length = 0;
cotigac 2:bb66c19c3c04 620 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 621
cotigac 2:bb66c19c3c04 622 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 623 }
cotigac 2:bb66c19c3c04 624
cotigac 2:bb66c19c3c04 625 void KW40Z::SendGetAdvertisementMode(void)
cotigac 2:bb66c19c3c04 626 {
cotigac 2:bb66c19c3c04 627 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 628
cotigac 2:bb66c19c3c04 629 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 630 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 631 txPacket.type = packetType_advModeGet;
cotigac 2:bb66c19c3c04 632 txPacket.length = 0;
cotigac 2:bb66c19c3c04 633 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 634
cotigac 2:bb66c19c3c04 635 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 636 }
cotigac 2:bb66c19c3c04 637
cotigac 2:bb66c19c3c04 638 void KW40Z::SendGetLinkState(void)
cotigac 2:bb66c19c3c04 639 {
cotigac 2:bb66c19c3c04 640 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 641
cotigac 2:bb66c19c3c04 642 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 643 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 644 txPacket.type = packetType_linkStateGet;
cotigac 2:bb66c19c3c04 645 txPacket.length = 0;
cotigac 2:bb66c19c3c04 646 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 647
cotigac 2:bb66c19c3c04 648 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 649 }
cotigac 2:bb66c19c3c04 650
cotigac 2:bb66c19c3c04 651 void KW40Z::SendGetVersion(void)
cotigac 2:bb66c19c3c04 652 {
cotigac 2:bb66c19c3c04 653 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 654
cotigac 2:bb66c19c3c04 655 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 656 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 657 txPacket.type = packetType_buildVersion;
cotigac 2:bb66c19c3c04 658 txPacket.length = 3;
cotigac 2:bb66c19c3c04 659 txPacket.data[0] = HEXIWEAR_VERSION_MAJOR;
cotigac 2:bb66c19c3c04 660 txPacket.data[1] = HEXIWEAR_VERSION_MINOR;
cotigac 2:bb66c19c3c04 661 txPacket.data[2] = HEXIWEAR_VERSION_PATCH;
cotigac 2:bb66c19c3c04 662 txPacket.data[3] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 663
cotigac 2:bb66c19c3c04 664 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 665 }
cotigac 2:bb66c19c3c04 666
cotigac 2:bb66c19c3c04 667 void KW40Z::SendPacketOK(void)
cotigac 2:bb66c19c3c04 668 {
cotigac 2:bb66c19c3c04 669 hostInterface_packet_t txPacket = {0};
cotigac 2:bb66c19c3c04 670
cotigac 2:bb66c19c3c04 671 txPacket.start1 = gHostInterface_startByte1;
cotigac 2:bb66c19c3c04 672 txPacket.start2 = gHostInterface_startByte2;
cotigac 2:bb66c19c3c04 673 txPacket.type = packetType_OK;
cotigac 2:bb66c19c3c04 674 txPacket.length = 0;
cotigac 2:bb66c19c3c04 675 txPacket.data[0] = gHostInterface_trailerByte;
cotigac 2:bb66c19c3c04 676
cotigac 2:bb66c19c3c04 677 SendPacket(&txPacket, false);
cotigac 2:bb66c19c3c04 678 }