Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HelloWorld_IDS01A4 by
main.cpp
00001 /** 00002 ****************************************************************************** 00003 * @file main.cpp 00004 * @author JMHong, Cubebite 00005 * @version V1.0.0 00006 * @date June 19th, 2018 00007 * @brief mbed test application for the STMicroelectronics X-NUCLEO-IDB01A4/5 00008 * Spirit1 Module(SPSGRFC-433) 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2018 Cubebite</center></h2> 00013 * 00014 ****************************************************************************** 00015 */ 00016 00017 00018 00019 //************************************************************************************* 00020 //Define : Test, Compile 00021 //************************************************************************************* 00022 /* 180108 cubebite HJM : cubebite Testing define, 1개씩만 켜야 함. */ 00023 #define CUBEBITE_RF_SPEED_TEST_SEND_ON 00024 //#define CUBEBITE_RF_SPEED_TEST_RECV_ON 00025 00026 00027 /* 180109 cubebite HJM : cubebite Compile define, 1개씩만 켜야 함. */ 00028 //#define CUBEBITE_BOARD_F746ZG 00029 #define CUBEBITE_BOARD_F401RE 00030 00031 00032 #define CUBEBITE_RF_SETTING_VALUE_PRINT 00033 //************************************************************************************* 00034 00035 00036 00037 00038 //************************************************************************************* 00039 //Define : Debug 00040 //************************************************************************************* 00041 /* 180108 cubebite HJM : SimpleSpirit1 Debug define */ 00042 #define NDEBUG 00043 #define HEAVY_DEBUG 00044 #define DEBUG_IRQ 00045 00046 00047 /* 180108 cubebite HJM : cubebite Debug define */ 00048 //#define CUBEBITE_DEBUG 00049 //************************************************************************************* 00050 00051 00052 00053 00054 //************************************************************************************* 00055 //Include 00056 //************************************************************************************* 00057 #ifndef __MAIN_H__ 00058 #define __MAIN_H__ 00059 #include "main.h" 00060 #endif //__MAIN_H__ 00061 //************************************************************************************* 00062 00063 00064 00065 00066 enum RecvReturnValue 00067 { 00068 CUBEBITE_RECV_OK = 0, CUBEBITE_RECV_ERROR_READ_NOTHING, CUBEBITE_RECV_ERROR_READ_NOT_MATCH 00069 }; 00070 00071 enum SendReturnValue 00072 { 00073 CUBEBITE_SEND_OK = 0, CUBEBITE_SEND_ERROR, CUBEBITE_SEND_COLLISION, CUBEBITE_SEND_NOACK, CUBEBITE_SEND_ERROR_UNKNOWN 00074 }; 00075 00076 00077 00078 00079 00080 static void callback_func(int event); 00081 00082 static int ReadRcvdData(SimpleSpirit1& myspirit); 00083 static int ReadRcvdData_ClockMeasure_AckEnd(SimpleSpirit1& myspirit); 00084 00085 static int SendData(SimpleSpirit1& myspirit); 00086 static int SendData_ClockMeasure_AckStart(SimpleSpirit1& myspirit); 00087 00088 00089 00090 00091 00092 /* 00093 <RF 설정 값> 00094 황무지 -> 전파 00095 고속도로 -> 주파수 00096 차선 -> 채널 00097 00098 #define POWER_DBM 11.6 00099 #define CHANNEL_SPACE 100e3 00100 #define FREQ_DEVIATION 20e3 00101 #define BANDWIDTH 100.5e3 00102 #define MODULATION_SELECT GFSK_BT1 00103 #define DATARATE 38400 00104 #define XTAL_OFFSET_PPM 0 00105 #define SYNC_WORD 0x88888888 00106 #define LENGTH_WIDTH 8 // betzw - NOTE: only 255 bytes for payload!!! 00107 #define CRC_MODE PKT_CRC_MODE_16BITS_2 00108 #define EN_WHITENING S_DISABLE 00109 #define INFINITE_TIMEOUT 0.0 00110 00111 #define BASE_FREQUENCY 433.0e6 00112 00113 */ 00114 00115 00116 /** 00117 * @brief main routine 00118 * @param None 00119 * @retval int 00120 */ 00121 int main() 00122 { 00123 /* 180108 cubebite HJM : function return value print */ 00124 int iReturn = 0; 00125 00126 //************************************************************************************* 00127 //Global variable : Create an instance by board 00128 //************************************************************************************* 00129 /* 180108 cubebite HJM : orignal code, backup */ 00130 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(D11, D12, D3, D9, D10, D2); /* (SPI_CLK) = (D13:PA5:resistorR7 --> D3:PB3:resistorR4)*/ 00131 00132 #ifdef CUBEBITE_BOARD_F401RE 00133 /* 180108 cubebite HJM : F401re borad, AnalogIn PIN Info, A0(PA_0) A1(PA_1) A2(PA_4) A3(PB_0) A4(PC_1) A5(PC_0) */ 00134 /* RF Module 과 상관 관계 => A0(PA_0)[SPI GPIO 3] A1(PA_1)[CSN] A2(PA_4)[SPI1 GPIO 2] A3(PB_0)[SPI1 GPIO 1] A4(PC_1)[SPI1_GPIO 0] */ 00135 /* 180108 cubebite HJM : F401re borad Init code */ 00136 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(PA_7, PA_6, PA_5, PC_7, PB_6, PA_10); //F401re borad 00137 static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(PA_7, PA_6, PA_5, PA_0, PB_6, PA_10); //F401re borad, IRQ Testing, GPIO 3 -> IRQ 00138 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance_RSSI_negative_OneHundredTwenty(PA_7, PA_6, PA_5, PA_0, PB_6, PA_10); //F401re borad, IRQ Testing, GPIO 3 -> IRQ 00139 #endif 00140 00141 00142 00143 #ifdef CUBEBITE_BOARD_F746ZG 00144 /* 180108 cubebite HJM : F746zg borad, AnalogIn PIN Info, A0(PA_3) A1(PC_0) A2(PC_3) A3(PF_3) A4(PF_5) A5(PF_10) */ 00145 /* RF Module 과 상관 관계 => A0(PA_3)[SPI GPIO 3] A1(PC_0)[CSN] A2(PC_3)[SPI1 GPIO 2] A3(PF_3)[SPI1 GPIO 1] A4(PF_5)[SPI1_GPIO 0] */ 00146 /* 180108 cubebite HJM : F746zg borad Init code */ 00147 //static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(PB_5, PB_4, PB_3, PD_14, PD_5, PD_6); //F746zg borad 00148 static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(PB_5, PB_4, PB_3, PA_3, PD_5, PD_6); //F746zg borad, IRQ Testing, GPIO 3 -> IRQ 00149 //static SimpleSpirit1 &myspirit2 = SimpleSpirit1::CreateInstance2(PB_5, PB_4, PB_3, PA_3, PD_5, PD_6); //F746zg borad, IRQ Testing, GPIO 3 -> IRQ 00150 #endif 00151 //************************************************************************************* 00152 00153 00154 00155 00156 /* 180108 cubebite HJM : spirit module, init code */ 00157 printf("[CUBEBITE] Init "); 00158 /* LED off */ 00159 TestLED = 0; 00160 myspirit.attach_irq_callback(callback_func); 00161 iReturn = myspirit.on(); 00162 if ( 0 == iReturn ) 00163 { 00164 printf("OK.\n"); 00165 } 00166 else 00167 { 00168 printf("ERROR.\n"); 00169 } 00170 00171 #ifdef CUBEBITE_DEBUG 00172 printf("[CUBEBITE] CUBEBITE_DEBUG ON. \n"); 00173 #endif //CUBEBITE_DEBUG 00174 00175 00176 #ifdef CUBEBITE_RF_SETTING_VALUE_PRINT 00177 printf("Xtal offset in ppm : [%d]\n", XTAL_OFFSET_PPM); 00178 printf("base frequency : [%d]\n", (uint32_t)BASE_FREQUENCY); 00179 printf("channel space : [%d]\n", (uint32_t)CHANNEL_SPACE); 00180 printf("channel number : [%d]\n", CHANNEL_NUMBER); 00181 printf("modulation select : [%d]\n", MODULATION_SELECT); 00182 printf("data rate : [%d]\n", DATARATE); 00183 printf("frequency deviation : [%d]\n", (uint32_t)FREQ_DEVIATION); 00184 printf("channel filter bandwidth : [%d]\n", (uint32_t)BANDWIDTH); 00185 #ifdef CUBEBITE_RF_SPEED_TEST_SEND_ON 00186 // printf("\nOutput Power(dBm) : [%f]\n", POWER_DBM); 00187 printf("\nOutput Power(dBm) : [%f]\n", (float)CUBEBITE_OUTPUT_POWER_DBM_TEST); 00188 00189 #endif //CUBEBITE_RF_SPEED_TEST_SEND_ON 00190 00191 #ifdef CUBEBITE_RF_SPEED_TEST_RECV_ON 00192 printf("\nRSSI threshold Setting value : [%d]\n", (int)CCA_THRESHOLD); 00193 #endif //CUBEBITE_RF_SPEED_TEST_RECV_ON 00194 00195 wait(2); 00196 #endif //CUBEBITE_RF_SETTING_VALUE_PRINT 00197 00198 while(1) 00199 { 00200 /* low power in idle condition., waiting for an event */ 00201 __WFE(); 00202 00203 #ifdef CUBEBITE_RF_SPEED_TEST_SEND_ON 00204 iReturn = SendData(myspirit); 00205 if (CUBEBITE_SEND_OK == iReturn) 00206 { 00207 printf("[DEBUG] send OK.\n"); 00208 } 00209 else if (CUBEBITE_SEND_ERROR == iReturn) 00210 { 00211 printf("[DEBUG] send ERROR.\n"); 00212 } 00213 00214 iReturn = (int)myspirit.get_last_sqi(); //HJM : LQI, 현재 주변 통신 품질 값, 높을수록 좋은 것. 00215 printf("get_last_sqi() return : [%d]\n", iReturn); 00216 #endif 00217 00218 #ifdef CUBEBITE_RF_SPEED_TEST_RECV_ON 00219 if (bRxDoneFlag) 00220 { 00221 iReturn = ReadRcvdData(myspirit); 00222 if (CUBEBITE_RECV_OK == iReturn) 00223 { 00224 //통신 속도 체크시, 응답 send code. 00225 printf("[DEBUG] recv OK.\n"); 00226 00227 float fReturn1 = myspirit.get_last_rssi_dbm(); 00228 printf("get_last_rssi_dbm() return : [%f]\n", fReturn1); //HJM : 위의 값과 같을 거라고 예상 됨. 나중에 테스트. 00229 if (-50 < fReturn1) //-80 < fReturn1 00230 { 00231 TestLED3 = !TestLED3; /* Toggle LED at the receiver */ 00232 } 00233 else if (-50 >= fReturn1) 00234 { 00235 // TestLED = !TestLED; /* Toggle LED at the receiver */ 00236 TestLED2 = !TestLED2; /* Toggle LED at the receiver */ 00237 // TestLED3 = !TestLED3; /* Toggle LED at the receiver */ 00238 } 00239 else if (-70 >= fReturn1) //-100 >= fReturn1 00240 { 00241 TestLED = !TestLED; /* Toggle LED at the receiver */ 00242 } 00243 } 00244 bRxDoneFlag = 0; 00245 } 00246 #endif 00247 00248 } 00249 /* unreachable */ 00250 // myspirit.off(); 00251 // return 0; 00252 } 00253 00254 00255 00256 00257 00258 /** 00259 * @brief callback_func 00260 * @param callback event 00261 * @retval None. 00262 */ 00263 static void callback_func(int event) 00264 { 00265 #ifdef CUBEBITE_DEBUG 00266 printf("[CUBEBITE] callback_func(int event) \n"); 00267 #endif 00268 00269 00270 if(event == SimpleSpirit1::RX_DONE) 00271 { 00272 bRxDoneFlag = 1; 00273 } 00274 else if (event == SimpleSpirit1::TX_DONE) 00275 { 00276 bTxDoneFlag = 1; 00277 } 00278 } 00279 00280 00281 00282 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00283 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00284 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00285 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00286 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00287 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00288 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00289 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00290 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00291 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00292 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00293 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00294 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00295 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00296 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00297 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00298 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00299 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00300 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00301 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00302 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00303 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00304 //recv 00305 00306 00307 00308 00309 00310 00311 /** 00312 * @brief ReadRcvdData 00313 * @param None 00314 * @retval None 00315 */ 00316 static int ReadRcvdData(SimpleSpirit1& myspirit) 00317 { 00318 #ifdef CUBEBITE_DEBUG 00319 printf("[CUBEBITE] ReadRcvdData() 호출 됨. \n"); 00320 #endif 00321 00322 for(unsigned int flush_count = 0; flush_count < TEST_STR_LEN; flush_count++) uiRendBuf[flush_count] = 0 ;/* clear the read buffer */ 00323 00324 00325 int ret = myspirit.read(uiRendBuf, sizeof(uiRendBuf)); 00326 if (ret == 0) 00327 { 00328 printf("[CUBEBITE] Read() Error : Nothing to read\n"); 00329 return CUBEBITE_RECV_ERROR_READ_NOTHING; 00330 } 00331 printf("ReadRcvdData() 1"); 00332 00333 printf("[DEBUG]recv -> %s ", uiRendBuf); 00334 00335 ret = strcmp((const char *)uiRendBuf, (const char *)uiSendBuf); 00336 printf(" 3"); 00337 if (0 == ret) 00338 { 00339 // set_ack_bSendDataFlag(); //180118 HJM : 다시 바로 보내는 걸로 수정 00340 // printf("read, send buf collect!!\n"); 00341 // TestLED = !TestLED; /* Toggle LED at the receiver */ 00342 printf(" 4"); 00343 // bIsAckSended = true; 00344 // printf("[DEBUG]recv -> %s\n", uiRendBuf); 00345 #ifdef CUBEBITE_DEBUG 00346 printf("[DEBUG]recv -> %s\n", uiRendBuf); 00347 #endif 00348 00349 //746zg 보드 00350 // wait(1.0); 00351 /* 00352 int iRet = myspirit.send(uiSendAckBuf, sizetCurrAckBufLen); 00353 if (iRet == RADIO_TX_OK) 00354 { 00355 #ifdef CUBEBITE_DEBUG 00356 printf("ACK : [RADIO_TX_OK]\n"); 00357 #endif 00358 } 00359 else if (iRet == RADIO_TX_ERR) 00360 { 00361 #ifdef CUBEBITE_DEBUG 00362 printf("ACK : [RADIO_TX_ERR]\n"); 00363 #endif 00364 } 00365 else if (iRet == RADIO_TX_COLLISION) 00366 { 00367 #ifdef CUBEBITE_DEBUG 00368 printf("ACK : [RADIO_TX_COLLISION]\n"); 00369 #endif 00370 } 00371 else if (iRet == RADIO_TX_NOACK) 00372 { 00373 #ifdef CUBEBITE_DEBUG 00374 printf("ACK : [RADIO_TX_NOACK]\n"); 00375 #endif 00376 } 00377 */ 00378 00379 return CUBEBITE_RECV_OK; 00380 printf(" 5 ok\n"); 00381 } 00382 00383 00384 #ifdef CUBEBITE_DEBUG 00385 printf("[CUBEBITE] ReadRcvdData() 호출 끝. \n"); 00386 #endif 00387 00388 return CUBEBITE_RECV_ERROR_READ_NOT_MATCH; 00389 printf(" 6 error\n"); 00390 } 00391 00392 00393 00394 static int ReadRcvdData_ClockMeasure_AckEnd(SimpleSpirit1& myspirit) 00395 { 00396 #ifdef CUBEBITE_DEBUG 00397 printf("[CUBEBITE] ReadRcvdData() 호출 됨. \n"); 00398 #endif 00399 00400 for(unsigned int flush_count = 0; flush_count < TEST_STR_LEN; flush_count++) uiRendBuf[flush_count] = 0 ;/* clear the read buffer */ 00401 00402 int ret = myspirit.read(uiRendBuf, sizeof(uiRendBuf)); 00403 if (ret == 0) 00404 { 00405 printf("[CUBEBITE] Read() Error : Nothing to read\n"); 00406 return CUBEBITE_RECV_ERROR_READ_NOTHING; 00407 } 00408 #ifdef CUBEBITE_RF_SPEED_TEST_RECV_ON 00409 ret = strcmp((const char *)uiRendBuf, (const char *)uiSendBuf); 00410 if (0 == ret) 00411 { 00412 // set_ack_bSendDataFlag(); //180118 HJM : 다시 바로 보내는 걸로 수정 00413 // printf("read, send buf collect!!\n"); 00414 TestLED = !TestLED; /* Toggle LED at the receiver */ 00415 // bIsAckSended = true; 00416 #ifdef CUBEBITE_DEBUG 00417 printf("[DEBUG]recv -> %s\n", uiRendBuf); 00418 #endif 00419 00420 //746zg 보드 00421 // wait(1.0); 00422 /* 00423 int iRet = myspirit.send(uiSendAckBuf, sizetCurrAckBufLen); 00424 if (iRet == RADIO_TX_OK) 00425 { 00426 #ifdef CUBEBITE_DEBUG 00427 printf("ACK : [RADIO_TX_OK]\n"); 00428 #endif 00429 } 00430 else if (iRet == RADIO_TX_ERR) 00431 { 00432 #ifdef CUBEBITE_DEBUG 00433 printf("ACK : [RADIO_TX_ERR]\n"); 00434 #endif 00435 } 00436 else if (iRet == RADIO_TX_COLLISION) 00437 { 00438 #ifdef CUBEBITE_DEBUG 00439 printf("ACK : [RADIO_TX_COLLISION]\n"); 00440 #endif 00441 } 00442 else if (iRet == RADIO_TX_NOACK) 00443 { 00444 #ifdef CUBEBITE_DEBUG 00445 printf("ACK : [RADIO_TX_NOACK]\n"); 00446 #endif 00447 } 00448 */ 00449 00450 return CUBEBITE_RECV_OK; 00451 } 00452 #endif 00453 00454 #ifdef CUBEBITE_RF_SPEED_TEST_SEND_ON 00455 //401re 보드 00456 if (true == bIsSendFirstClockFunctionStarted) 00457 { 00458 clocktimeRFSpeedTestEnd = clock(); 00459 } 00460 //printf("[DEBUG]recv -> %s\n", uiRendBuf); 00461 #endif 00462 00463 00464 #ifdef CUBEBITE_DEBUG 00465 printf("[CUBEBITE] ReadRcvdData() 호출 끝. \n"); 00466 #endif 00467 00468 return CUBEBITE_RECV_ERROR_READ_NOT_MATCH; 00469 } 00470 00471 00472 00473 00474 00475 00476 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00477 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00478 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00479 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00480 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00481 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00482 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00483 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00484 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00485 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00486 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00487 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00488 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00489 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00490 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00491 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00492 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00493 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00494 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00495 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00496 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00497 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00498 //send 00499 00500 00501 00502 00503 00504 00505 /** 00506 * @brief SendData 00507 * @param None 00508 * @retval None 00509 */ 00510 static int SendData(SimpleSpirit1& myspirit) 00511 { 00512 #ifdef CUBEBITE_DEBUG 00513 printf("[CUBEBITE] SendData() 호출 됨.\n"); 00514 #endif 00515 while(myspirit.is_receiving()); /* wait for ongoing RX ends 180110 HJM 아마 이 전에 보내던 거 마저 다 보내려고 하는 거 같다. */ 00516 00517 size_t curr_len = strlen((const char*)uiSendBuf) + 1; 00518 int iRet = 0; 00519 00520 printf("SendData() uiSendBuf -> [%s]\n", uiSendBuf); 00521 iRet = myspirit.send(uiSendBuf, curr_len); 00522 if (iRet == RADIO_TX_OK) 00523 { 00524 #ifdef CUBEBITE_DEBUG 00525 printf("[RADIO_TX_OK]\n"); 00526 #endif 00527 return CUBEBITE_SEND_OK; 00528 } 00529 else if (iRet == RADIO_TX_ERR) 00530 { 00531 #ifdef CUBEBITE_DEBUG 00532 printf("[RADIO_TX_ERR]\n"); 00533 #endif 00534 return CUBEBITE_SEND_ERROR; 00535 } 00536 else if (iRet == RADIO_TX_COLLISION) 00537 { 00538 #ifdef CUBEBITE_DEBUG 00539 printf("[RADIO_TX_COLLISION]\n"); 00540 #endif 00541 return CUBEBITE_SEND_COLLISION; 00542 } 00543 else if (iRet == RADIO_TX_NOACK) 00544 { 00545 #ifdef CUBEBITE_DEBUG 00546 printf("[RADIO_TX_NOACK]\n"); 00547 #endif 00548 return CUBEBITE_SEND_NOACK; 00549 } 00550 00551 #ifdef CUBEBITE_DEBUG 00552 printf("[CUBEBITE] SendData() 호출 끝.\n"); 00553 #endif 00554 00555 return CUBEBITE_SEND_ERROR_UNKNOWN; 00556 } 00557 00558 00559 static int SendData_ClockMeasure_AckStart(SimpleSpirit1& myspirit) 00560 { 00561 #ifdef CUBEBITE_DEBUG 00562 printf("[CUBEBITE] SendData() 호출 됨.\n"); 00563 #endif 00564 while(myspirit.is_receiving()); /* wait for ongoing RX ends 180110 HJM 아마 이 전에 보내던 거 마저 다 보내려고 하는 거 같다. */ 00565 00566 size_t curr_len = strlen((const char*)uiSendBuf) + 1; 00567 int iRet = 0; 00568 00569 iRet = myspirit.send(uiSendBuf, curr_len); 00570 if (iRet == RADIO_TX_OK) 00571 { 00572 #ifdef CUBEBITE_DEBUG 00573 printf("[RADIO_TX_OK]\n"); 00574 #endif 00575 00576 #ifdef CUBEBITE_RF_SPEED_TEST_SEND_ON 00577 if (false == bIsSendFirstClockFunctionStarted) 00578 { 00579 clocktimeRFSpeedTestStart = clock(); 00580 bIsSendFirstClockFunctionStarted = true; 00581 } 00582 #endif 00583 00584 return CUBEBITE_SEND_OK; 00585 } 00586 else if (iRet == RADIO_TX_ERR) 00587 { 00588 #ifdef CUBEBITE_DEBUG 00589 printf("[RADIO_TX_ERR]\n"); 00590 #endif 00591 return CUBEBITE_SEND_ERROR; 00592 } 00593 else if (iRet == RADIO_TX_COLLISION) 00594 { 00595 #ifdef CUBEBITE_DEBUG 00596 printf("[RADIO_TX_COLLISION]\n"); 00597 #endif 00598 return CUBEBITE_SEND_COLLISION; 00599 } 00600 else if (iRet == RADIO_TX_NOACK) 00601 { 00602 #ifdef CUBEBITE_DEBUG 00603 printf("[RADIO_TX_NOACK]\n"); 00604 #endif 00605 return CUBEBITE_SEND_NOACK; 00606 } 00607 00608 #ifdef CUBEBITE_DEBUG 00609 printf("[CUBEBITE] SendData() 호출 끝.\n"); 00610 #endif 00611 00612 return CUBEBITE_SEND_ERROR_UNKNOWN; 00613 } 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623
Generated on Wed Jul 13 2022 10:41:04 by
1.7.2
