7676#include "embARC_debug.h"
7777#include "lwip/netif.h"
7878#include "coap.h"
79+
80+ #if defined(BOARD_EMSK )
7981#include "adt7420.h"
82+ #endif
8083
8184#define min (x ,y ) ((x) < (y) ? (x) : (y))
8285
8386#define TSKPRI_COAP_SERVER (configMAX_PRIORITIES-2) /**< coap server task priority */
84- #define TSKPRI_TEMPTX (configMAX_PRIORITIES-3)
8587
8688static void task_coap_server (void * par );
87- static void task_temp_tx (void * par );
8889
8990static TaskHandle_t task_coap_server_handle = NULL ;
90- static TaskHandle_t task_temptx_handle = NULL ;
91-
9291static coap_resource_t * temp_resource = NULL ;
92+
93+ #if defined(BOARD_EMSK )
94+ #define TSKPRI_TEMPTX (configMAX_PRIORITIES-3)
95+ static TaskHandle_t task_temptx_handle = NULL ;
96+ static void task_temp_tx (void * par );
9397static ADT7420_DEFINE (temp , BOARD_TEMP_SENSOR_IIC_ID , TEMP_I2C_SLAVE_ADDRESS ) ;
98+ #endif
9499
95100int main (void )
96101{
@@ -132,7 +137,7 @@ static void hnd_get_temp(coap_context_t *ctx, struct coap_resource_t *resource,
132137 coap_opt_iterator_t opt_iter ;
133138 unsigned char buf [40 ];
134139 size_t len ;
135- float temp_val ;
140+ float temp_val = 10.0 ;
136141 coap_subscription_t * subscription ;
137142
138143 response -> hdr -> code = COAP_RESPONSE_CODE (205 );
@@ -159,9 +164,11 @@ static void hnd_get_temp(coap_context_t *ctx, struct coap_resource_t *resource,
159164 coap_add_option (response , COAP_OPTION_MAXAGE ,
160165 coap_encode_var_bytes (buf , 60 ), buf );
161166
167+ #if defined(BOARD_EMSK )
162168 if (adt7420_sensor_read (temp , & temp_val ) != E_OK ) {
163169 temp_val = 0.0f ;
164170 }
171+ #endif
165172
166173 len = snprintf ((char * )buf ,
167174 min (sizeof (buf ), response -> max_size - response -> length ),
@@ -243,12 +250,15 @@ static void task_coap_server(void *par)
243250
244251 init_resources (ctx );
245252
253+ #if defined(BOARD_EMSK )
246254 if (xTaskCreate (task_temp_tx , "temperature update task" , 128 , (void * )1 ,
247255 TSKPRI_TEMPTX , & task_temptx_handle ) != pdPASS ) {
248256 EMBARC_PRINTF ("create temperature update task failed\r\n" );
249257 vTaskDelete (NULL );
250258 return ;
251259 }
260+ #endif
261+
252262 /**
253263 * every 100 ticks, the server will the incoming data.
254264 * FIXME: add semaphore post in received_package(coap/net.c) to
@@ -262,7 +272,7 @@ static void task_coap_server(void *par)
262272 coap_free_context (ctx );
263273}
264274
265-
275+ #if defined( BOARD_EMSK )
266276static void task_temp_tx (void * par )
267277{
268278 adt7420_sensor_init (temp );
@@ -272,5 +282,6 @@ static void task_temp_tx(void *par)
272282 vTaskDelay (2000 );
273283 }
274284}
285+ #endif
275286
276287/** @} */
0 commit comments