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:
khuang
Date:
Sun Sep 25 05:50:22 2016 +0000
Revision:
8:2b9b24f3154d
Parent:
6:23323e8aeda4
Child:
9:8058541a8e2d
SendAccel, SendGyro,SendMag functions changed to accept int16_t instead of uint8_t. UART Messaging API has error. mag,accel and gyro should be 6 bytes instead of 3.

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