Test Ethernet, SD card and BLE of Arch Link

Dependencies:   BLE_API SDFileSystem WIZnet_Library mbed nRF51822

Committer:
yihui
Date:
Wed Aug 05 05:33:52 2015 +0000
Revision:
0:e1d4ac4e1c78
Initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 0:e1d4ac4e1c78 1 /*
yihui 0:e1d4ac4e1c78 2 Arch Link Test Program for BLE
yihui 0:e1d4ac4e1c78 3 Jacky Zhang @ 20150526
yihui 0:e1d4ac4e1c78 4 */
yihui 0:e1d4ac4e1c78 5
yihui 0:e1d4ac4e1c78 6
yihui 0:e1d4ac4e1c78 7 #define TEST_W5500
yihui 0:e1d4ac4e1c78 8 #define TEST_SD
yihui 0:e1d4ac4e1c78 9 //#define TEST_I2C
yihui 0:e1d4ac4e1c78 10 #define TEST_BLE
yihui 0:e1d4ac4e1c78 11
yihui 0:e1d4ac4e1c78 12
yihui 0:e1d4ac4e1c78 13 #include "mbed.h"
yihui 0:e1d4ac4e1c78 14 #include "BLE.h"
yihui 0:e1d4ac4e1c78 15 #include "HealthThermometerService.h"
yihui 0:e1d4ac4e1c78 16 #include "WIZnetInterface.h"
yihui 0:e1d4ac4e1c78 17 #include "SDFileSystem.h"
yihui 0:e1d4ac4e1c78 18
yihui 0:e1d4ac4e1c78 19 #ifdef TEST_I2C
yihui 0:e1d4ac4e1c78 20 #include "TSL2561.h"
yihui 0:e1d4ac4e1c78 21 #endif
yihui 0:e1d4ac4e1c78 22
yihui 0:e1d4ac4e1c78 23 //Arch Link
yihui 0:e1d4ac4e1c78 24 Serial pc(USBTX, USBRX);
yihui 0:e1d4ac4e1c78 25 DigitalOut led1(LED1);
yihui 0:e1d4ac4e1c78 26
yihui 0:e1d4ac4e1c78 27 #ifdef TEST_SD
yihui 0:e1d4ac4e1c78 28 //SD Card
yihui 0:e1d4ac4e1c78 29 int SD_Test(void);
yihui 0:e1d4ac4e1c78 30 SDFileSystem sd(SPI_PSELMOSI0, SPI_PSELMISO0, SPI_PSELSCK0, p11, "sd"); // MOSI, MISO, SCK, CS
yihui 0:e1d4ac4e1c78 31 DirHandle *dir;
yihui 0:e1d4ac4e1c78 32 FILE *fp;
yihui 0:e1d4ac4e1c78 33 #endif
yihui 0:e1d4ac4e1c78 34
yihui 0:e1d4ac4e1c78 35 #ifdef TEST_W5500
yihui 0:e1d4ac4e1c78 36 //W5500
yihui 0:e1d4ac4e1c78 37 #define USE_DHCP 1
yihui 0:e1d4ac4e1c78 38 #define LOOPBACKPORT 5000
yihui 0:e1d4ac4e1c78 39 int W5500_Test(void);
yihui 0:e1d4ac4e1c78 40 SPI spi(SPI_PSELMOSI0, SPI_PSELMISO0, SPI_PSELSCK0); // mosi, miso, sclk
yihui 0:e1d4ac4e1c78 41 WIZnetInterface ethernet(&spi, p24, p17); // spi, cs, reset
yihui 0:e1d4ac4e1c78 42 int ret;
yihui 0:e1d4ac4e1c78 43 const unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x1C,0xAA,0xCA};
yihui 0:e1d4ac4e1c78 44 #endif
yihui 0:e1d4ac4e1c78 45
yihui 0:e1d4ac4e1c78 46 #ifdef TEST_BLE
yihui 0:e1d4ac4e1c78 47 //BLE
yihui 0:e1d4ac4e1c78 48 void periodicCallback(void);
yihui 0:e1d4ac4e1c78 49 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason);
yihui 0:e1d4ac4e1c78 50 int BLE_Test(void);
yihui 0:e1d4ac4e1c78 51 BLEDevice ble;
yihui 0:e1d4ac4e1c78 52 static volatile bool triggerSensorPolling = false;
yihui 0:e1d4ac4e1c78 53 const static char DEVICE_NAME[] = "Arch Link Test";
yihui 0:e1d4ac4e1c78 54 static const uint16_t uuid16_list[] = {GattService::UUID_HEALTH_THERMOMETER_SERVICE};
yihui 0:e1d4ac4e1c78 55 #endif
yihui 0:e1d4ac4e1c78 56
yihui 0:e1d4ac4e1c78 57 #ifdef TEST_I2C
yihui 0:e1d4ac4e1c78 58 //TSL2561
yihui 0:e1d4ac4e1c78 59 int I2C_Test(void);
yihui 0:e1d4ac4e1c78 60 TSL2561 tsl2561(p5, p6);
yihui 0:e1d4ac4e1c78 61 #endif
yihui 0:e1d4ac4e1c78 62
yihui 0:e1d4ac4e1c78 63 int main(void)
yihui 0:e1d4ac4e1c78 64 {
yihui 0:e1d4ac4e1c78 65 dir = (DirHandle *)malloc(sizeof(DirHandle));
yihui 0:e1d4ac4e1c78 66
yihui 0:e1d4ac4e1c78 67 wait(0.2);
yihui 0:e1d4ac4e1c78 68 pc.baud(115200);
yihui 0:e1d4ac4e1c78 69 wait(0.2);
yihui 0:e1d4ac4e1c78 70 pc.printf("hello\r\n");
yihui 0:e1d4ac4e1c78 71
yihui 0:e1d4ac4e1c78 72 // while(1)
yihui 0:e1d4ac4e1c78 73 // {
yihui 0:e1d4ac4e1c78 74 // led1 = 1;
yihui 0:e1d4ac4e1c78 75 // wait(0.5);
yihui 0:e1d4ac4e1c78 76 // led1 = 0;
yihui 0:e1d4ac4e1c78 77 // wait(0.5);
yihui 0:e1d4ac4e1c78 78 // pc.printf("hello\r\n");
yihui 0:e1d4ac4e1c78 79 // }
yihui 0:e1d4ac4e1c78 80
yihui 0:e1d4ac4e1c78 81
yihui 0:e1d4ac4e1c78 82
yihui 0:e1d4ac4e1c78 83 #ifdef TEST_W5500
yihui 0:e1d4ac4e1c78 84 if(W5500_Test() == 0)
yihui 0:e1d4ac4e1c78 85 {
yihui 0:e1d4ac4e1c78 86 pc.printf("W5500 tested OK\r\n\r\n");
yihui 0:e1d4ac4e1c78 87 }
yihui 0:e1d4ac4e1c78 88 else
yihui 0:e1d4ac4e1c78 89 {
yihui 0:e1d4ac4e1c78 90 pc.printf("W5500 tested NOT OK!\r\n\r\n");
yihui 0:e1d4ac4e1c78 91 }
yihui 0:e1d4ac4e1c78 92 #endif
yihui 0:e1d4ac4e1c78 93
yihui 0:e1d4ac4e1c78 94 #ifdef TEST_SD
yihui 0:e1d4ac4e1c78 95 if(SD_Test() == 0)
yihui 0:e1d4ac4e1c78 96 {
yihui 0:e1d4ac4e1c78 97 pc.printf("SD Card tested OK\r\n\r\n");
yihui 0:e1d4ac4e1c78 98 }
yihui 0:e1d4ac4e1c78 99 else
yihui 0:e1d4ac4e1c78 100 {
yihui 0:e1d4ac4e1c78 101 pc.printf("SD Card tested NOT OK!\r\n\r\n");
yihui 0:e1d4ac4e1c78 102 }
yihui 0:e1d4ac4e1c78 103 #endif
yihui 0:e1d4ac4e1c78 104
yihui 0:e1d4ac4e1c78 105 #ifdef TEST_I2C
yihui 0:e1d4ac4e1c78 106 if(I2C_Test() == 0)
yihui 0:e1d4ac4e1c78 107 {
yihui 0:e1d4ac4e1c78 108 pc.printf("I2C tested OK\r\n\r\n");
yihui 0:e1d4ac4e1c78 109 }
yihui 0:e1d4ac4e1c78 110 else
yihui 0:e1d4ac4e1c78 111 {
yihui 0:e1d4ac4e1c78 112 pc.printf("I2C tested NOT OK!\r\n\r\n");
yihui 0:e1d4ac4e1c78 113 }
yihui 0:e1d4ac4e1c78 114 #endif
yihui 0:e1d4ac4e1c78 115
yihui 0:e1d4ac4e1c78 116 #ifdef TEST_BLE
yihui 0:e1d4ac4e1c78 117 BLE_Test();
yihui 0:e1d4ac4e1c78 118 #endif
yihui 0:e1d4ac4e1c78 119
yihui 0:e1d4ac4e1c78 120 while (true)
yihui 0:e1d4ac4e1c78 121 {
yihui 0:e1d4ac4e1c78 122 wait(0.5);
yihui 0:e1d4ac4e1c78 123 }
yihui 0:e1d4ac4e1c78 124 }
yihui 0:e1d4ac4e1c78 125
yihui 0:e1d4ac4e1c78 126 #ifdef TEST_SD
yihui 0:e1d4ac4e1c78 127 int SD_Test(void)
yihui 0:e1d4ac4e1c78 128 {
yihui 0:e1d4ac4e1c78 129 int result;
yihui 0:e1d4ac4e1c78 130
yihui 0:e1d4ac4e1c78 131 pc.printf("checking SD Card...\r\n");
yihui 0:e1d4ac4e1c78 132 result = sd.disk_initialize();
yihui 0:e1d4ac4e1c78 133 if(result != 0)
yihui 0:e1d4ac4e1c78 134 {
yihui 0:e1d4ac4e1c78 135 pc.printf("SD Card initialized failed...\r\n");
yihui 0:e1d4ac4e1c78 136 return -1;
yihui 0:e1d4ac4e1c78 137 }
yihui 0:e1d4ac4e1c78 138 else
yihui 0:e1d4ac4e1c78 139 {
yihui 0:e1d4ac4e1c78 140 pc.printf("SD Card initialized OK\r\n");
yihui 0:e1d4ac4e1c78 141 }
yihui 0:e1d4ac4e1c78 142
yihui 0:e1d4ac4e1c78 143 uint64_t sectors = sd.disk_sectors();
yihui 0:e1d4ac4e1c78 144 unsigned int capacity = sectors / 2 / 1024;
yihui 0:e1d4ac4e1c78 145 pc.printf("SD card capacity is: %dMB\r\n", capacity);
yihui 0:e1d4ac4e1c78 146
yihui 0:e1d4ac4e1c78 147 dir = opendir("/sd/testdir");
yihui 0:e1d4ac4e1c78 148 if(dir == NULL)
yihui 0:e1d4ac4e1c78 149 {
yihui 0:e1d4ac4e1c78 150 pc.printf("the folder is not exist, let us create one\r\n");
yihui 0:e1d4ac4e1c78 151 result = mkdir("/sd/testdir", 0777);
yihui 0:e1d4ac4e1c78 152 if(result != 0)
yihui 0:e1d4ac4e1c78 153 {
yihui 0:e1d4ac4e1c78 154 pc.printf("mkdir WRONG, %d\r\n", result);
yihui 0:e1d4ac4e1c78 155 return -3;
yihui 0:e1d4ac4e1c78 156 }
yihui 0:e1d4ac4e1c78 157 pc.printf("the folder was created\r\n");
yihui 0:e1d4ac4e1c78 158 }
yihui 0:e1d4ac4e1c78 159
yihui 0:e1d4ac4e1c78 160 pc.printf("open file: sdtest.txt\r\n");
yihui 0:e1d4ac4e1c78 161 //w+ 打开可读写文件,若文件存在则文件长度清为零,即该文件内容会消失。若文件不存在则建立该文件
yihui 0:e1d4ac4e1c78 162 //a 以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。(EOF符保留)
yihui 0:e1d4ac4e1c78 163 fp = fopen("/sd/testdir/sdtest.txt", "w+");
yihui 0:e1d4ac4e1c78 164 pc.printf("opened\r\n");
yihui 0:e1d4ac4e1c78 165 if(fp == NULL)
yihui 0:e1d4ac4e1c78 166 {
yihui 0:e1d4ac4e1c78 167 pc.printf("Could not open file for write\r\n");
yihui 0:e1d4ac4e1c78 168 return -2;
yihui 0:e1d4ac4e1c78 169 }
yihui 0:e1d4ac4e1c78 170
yihui 0:e1d4ac4e1c78 171 int num = fprintf(fp, "Hello fun SD Card World!\r\n");
yihui 0:e1d4ac4e1c78 172 if(num != strlen("Hello fun SD Card World!\r\n"))
yihui 0:e1d4ac4e1c78 173 {
yihui 0:e1d4ac4e1c78 174 pc.printf("can't write into sdtested.txt\r\n");
yihui 0:e1d4ac4e1c78 175 //fclose(fp);
yihui 0:e1d4ac4e1c78 176 //free(dir);
yihui 0:e1d4ac4e1c78 177 return -4;
yihui 0:e1d4ac4e1c78 178 }
yihui 0:e1d4ac4e1c78 179 pc.printf("%d characters was wrote into sdtested.txt\r\n", num);
yihui 0:e1d4ac4e1c78 180
yihui 0:e1d4ac4e1c78 181 //fclose(fp);
yihui 0:e1d4ac4e1c78 182 //free(dir);
yihui 0:e1d4ac4e1c78 183
yihui 0:e1d4ac4e1c78 184 return 0;
yihui 0:e1d4ac4e1c78 185 }
yihui 0:e1d4ac4e1c78 186
yihui 0:e1d4ac4e1c78 187 #endif
yihui 0:e1d4ac4e1c78 188
yihui 0:e1d4ac4e1c78 189 #ifdef TEST_W5500
yihui 0:e1d4ac4e1c78 190 int W5500_Test(void)
yihui 0:e1d4ac4e1c78 191 {
yihui 0:e1d4ac4e1c78 192 mbed_mac_address((char *)MAC_Addr); //Use mbed mac addres
yihui 0:e1d4ac4e1c78 193 wait(1);
yihui 0:e1d4ac4e1c78 194 pc.printf("Start to test ethernet!\r\n");
yihui 0:e1d4ac4e1c78 195
yihui 0:e1d4ac4e1c78 196 #if USE_DHCP
yihui 0:e1d4ac4e1c78 197 pc.printf("use DHCP\r\n");
yihui 0:e1d4ac4e1c78 198 ret = ethernet.init((unsigned char *)MAC_Addr);
yihui 0:e1d4ac4e1c78 199 #else
yihui 0:e1d4ac4e1c78 200 pc.printf("do NOT use DHCP\r\n");
yihui 0:e1d4ac4e1c78 201 int ret = ethernet.init(MAC_Addr,IP_Addr,IP_Subnet,IP_Gateway);
yihui 0:e1d4ac4e1c78 202 #endif
yihui 0:e1d4ac4e1c78 203
yihui 0:e1d4ac4e1c78 204 if (!ret) {
yihui 0:e1d4ac4e1c78 205 pc.printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress());
yihui 0:e1d4ac4e1c78 206 ret = ethernet.connect();
yihui 0:e1d4ac4e1c78 207 if (!ret) {
yihui 0:e1d4ac4e1c78 208 pc.printf("IP: %s, MASK: %s, GW: %s\r\n",
yihui 0:e1d4ac4e1c78 209 ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway());
yihui 0:e1d4ac4e1c78 210 return 0;
yihui 0:e1d4ac4e1c78 211 } else {
yihui 0:e1d4ac4e1c78 212 pc.printf("Error ethernet.connect() - ret = %d\r\n", ret);
yihui 0:e1d4ac4e1c78 213 //exit(0);
yihui 0:e1d4ac4e1c78 214 return -1;
yihui 0:e1d4ac4e1c78 215 }
yihui 0:e1d4ac4e1c78 216 } else {
yihui 0:e1d4ac4e1c78 217 pc.printf("Error ethernet.init() - ret = %d\r\n", ret);
yihui 0:e1d4ac4e1c78 218 //exit(0);
yihui 0:e1d4ac4e1c78 219 return -1;
yihui 0:e1d4ac4e1c78 220 }
yihui 0:e1d4ac4e1c78 221 /*
yihui 0:e1d4ac4e1c78 222 TCPSocketServer server;
yihui 0:e1d4ac4e1c78 223 server.bind(LOOPBACKPORT);
yihui 0:e1d4ac4e1c78 224 server.listen();
yihui 0:e1d4ac4e1c78 225
yihui 0:e1d4ac4e1c78 226 while (1) {
yihui 0:e1d4ac4e1c78 227 pc.printf("\nWait for new connection...\r\n");
yihui 0:e1d4ac4e1c78 228 TCPSocketConnection client;
yihui 0:e1d4ac4e1c78 229 server.accept(client);
yihui 0:e1d4ac4e1c78 230 client.set_blocking(false, 0); // Timeout=0.
yihui 0:e1d4ac4e1c78 231 pc.printf("Connection from: %s\r\n", client.get_address());
yihui 0:e1d4ac4e1c78 232 while (client.is_connected() == true) {
yihui 0:e1d4ac4e1c78 233 int n = client.receive(buffer, sizeof(buffer));
yihui 0:e1d4ac4e1c78 234 if(n > 0)
yihui 0:e1d4ac4e1c78 235 client.send_all(buffer, n);
yihui 0:e1d4ac4e1c78 236 if(client.is_fin_received())
yihui 0:e1d4ac4e1c78 237 client.close();
yihui 0:e1d4ac4e1c78 238 }
yihui 0:e1d4ac4e1c78 239 pc.printf("Disconnected.\r\n");
yihui 0:e1d4ac4e1c78 240 }*/
yihui 0:e1d4ac4e1c78 241 }
yihui 0:e1d4ac4e1c78 242 #endif
yihui 0:e1d4ac4e1c78 243
yihui 0:e1d4ac4e1c78 244 #ifdef TEST_I2C
yihui 0:e1d4ac4e1c78 245 int I2C_Test(void)
yihui 0:e1d4ac4e1c78 246 {
yihui 0:e1d4ac4e1c78 247 uint16_t light_sensor_id = 0;
yihui 0:e1d4ac4e1c78 248
yihui 0:e1d4ac4e1c78 249 light_sensor_id = tsl2561.read_ID();
yihui 0:e1d4ac4e1c78 250 pc.printf("check id: %d\r\n", light_sensor_id);
yihui 0:e1d4ac4e1c78 251 if(light_sensor_id != 0)
yihui 0:e1d4ac4e1c78 252 {
yihui 0:e1d4ac4e1c78 253 for(int i = 0; i < 10; i++)
yihui 0:e1d4ac4e1c78 254 {
yihui 0:e1d4ac4e1c78 255 pc.printf("lux = %f\r\n", tsl2561.lux());
yihui 0:e1d4ac4e1c78 256 wait(0.2);
yihui 0:e1d4ac4e1c78 257 }
yihui 0:e1d4ac4e1c78 258 return 0;
yihui 0:e1d4ac4e1c78 259 }
yihui 0:e1d4ac4e1c78 260 else
yihui 0:e1d4ac4e1c78 261 {
yihui 0:e1d4ac4e1c78 262 return -1;
yihui 0:e1d4ac4e1c78 263 }
yihui 0:e1d4ac4e1c78 264 }
yihui 0:e1d4ac4e1c78 265 #endif
yihui 0:e1d4ac4e1c78 266
yihui 0:e1d4ac4e1c78 267 #ifdef TEST_BLE
yihui 0:e1d4ac4e1c78 268 /* Restart Advertising on disconnection*/
yihui 0:e1d4ac4e1c78 269 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
yihui 0:e1d4ac4e1c78 270 {
yihui 0:e1d4ac4e1c78 271 ble.startAdvertising();
yihui 0:e1d4ac4e1c78 272 }
yihui 0:e1d4ac4e1c78 273
yihui 0:e1d4ac4e1c78 274 void periodicCallback(void)
yihui 0:e1d4ac4e1c78 275 {
yihui 0:e1d4ac4e1c78 276 led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
yihui 0:e1d4ac4e1c78 277
yihui 0:e1d4ac4e1c78 278 /* Note that the periodicCallback() executes in interrupt context, so it is safer to do
yihui 0:e1d4ac4e1c78 279 * heavy-weight sensor polling from the main thread. */
yihui 0:e1d4ac4e1c78 280 triggerSensorPolling = true;
yihui 0:e1d4ac4e1c78 281 }
yihui 0:e1d4ac4e1c78 282
yihui 0:e1d4ac4e1c78 283 int BLE_Test(void)
yihui 0:e1d4ac4e1c78 284 {
yihui 0:e1d4ac4e1c78 285 pc.printf("begin to test BLE\r\n");
yihui 0:e1d4ac4e1c78 286
yihui 0:e1d4ac4e1c78 287 Ticker ticker;
yihui 0:e1d4ac4e1c78 288 ticker.attach(periodicCallback, 1);
yihui 0:e1d4ac4e1c78 289
yihui 0:e1d4ac4e1c78 290 ble.init();
yihui 0:e1d4ac4e1c78 291 ble.onDisconnection(disconnectionCallback);
yihui 0:e1d4ac4e1c78 292 //return 0;
yihui 0:e1d4ac4e1c78 293 /* Setup primary service. */
yihui 0:e1d4ac4e1c78 294 float currentTemperature = 39.6;
yihui 0:e1d4ac4e1c78 295 HealthThermometerService thermometerService(ble, currentTemperature, HealthThermometerService::LOCATION_EAR);
yihui 0:e1d4ac4e1c78 296
yihui 0:e1d4ac4e1c78 297 /* setup advertising */
yihui 0:e1d4ac4e1c78 298 ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
yihui 0:e1d4ac4e1c78 299 ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
yihui 0:e1d4ac4e1c78 300 ble.accumulateAdvertisingPayload(GapAdvertisingData::THERMOMETER_EAR);
yihui 0:e1d4ac4e1c78 301 ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
yihui 0:e1d4ac4e1c78 302 ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
yihui 0:e1d4ac4e1c78 303 ble.setAdvertisingInterval(1000); /* 1000ms */
yihui 0:e1d4ac4e1c78 304 ble.startAdvertising();
yihui 0:e1d4ac4e1c78 305
yihui 0:e1d4ac4e1c78 306 pc.printf("BLE initialized OK\r\n");
yihui 0:e1d4ac4e1c78 307
yihui 0:e1d4ac4e1c78 308 while(1)
yihui 0:e1d4ac4e1c78 309 {
yihui 0:e1d4ac4e1c78 310 if (triggerSensorPolling && ble.getGapState().connected) {
yihui 0:e1d4ac4e1c78 311 triggerSensorPolling = false;
yihui 0:e1d4ac4e1c78 312
yihui 0:e1d4ac4e1c78 313 /* Do blocking calls or whatever is necessary for sensor polling. */
yihui 0:e1d4ac4e1c78 314 // error = sensor.readData();
yihui 0:e1d4ac4e1c78 315 // if (!error) {
yihui 0:e1d4ac4e1c78 316 // thermometerService.updateTemperature(c);
yihui 0:e1d4ac4e1c78 317 // }
yihui 0:e1d4ac4e1c78 318
yihui 0:e1d4ac4e1c78 319 /* In our case, we simply update the dummy temperature measurement. */
yihui 0:e1d4ac4e1c78 320 currentTemperature += 0.1;
yihui 0:e1d4ac4e1c78 321 thermometerService.updateTemperature(currentTemperature);
yihui 0:e1d4ac4e1c78 322 pc.printf("data updated\r\n");
yihui 0:e1d4ac4e1c78 323 } else {
yihui 0:e1d4ac4e1c78 324 ble.waitForEvent();
yihui 0:e1d4ac4e1c78 325 }
yihui 0:e1d4ac4e1c78 326 }
yihui 0:e1d4ac4e1c78 327
yihui 0:e1d4ac4e1c78 328 //return 0;
yihui 0:e1d4ac4e1c78 329 }
yihui 0:e1d4ac4e1c78 330 #endif
yihui 0:e1d4ac4e1c78 331