diff --git a/Project/applications/smartcities/adc.c b/Project/applications/smartcities/adc.c index 821863f..38f5da1 100644 --- a/Project/applications/smartcities/adc.c +++ b/Project/applications/smartcities/adc.c @@ -91,7 +91,7 @@ uint32_t adc_sound_process() * 2. analogValue Range is [ADC_VREF_MINUS, ADC_VREF_PLUS] */ analogValue = ADCsound_VREF_MINUS + (((adcRegisterValue - ADCsound_MIN_VALUE)*(ADCsound_VREF_PLUS - ADCsound_VREF_MINUS))/(ADCsound_MAX_VALUE - ADCsound_MIN_VALUE)); - DBG("Register value is %4u [%4u milliVolts are currently given to gpio %s]",adcRegisterValue, analogValue, ADCbatt_GPIO_STR); + DBG("Register value is %4u [%4u milliVolts are currently given to gpio %s]",adcRegisterValue, analogValue, ADCsound_GPIO_STR); return analogValue; } diff --git a/Project/applications/smartcities/adc.h b/Project/applications/smartcities/adc.h index 97c7d07..c9edd93 100644 --- a/Project/applications/smartcities/adc.h +++ b/Project/applications/smartcities/adc.h @@ -12,11 +12,11 @@ #define ADCbatt_MIN_VALUE (0) #define ADCbatt_MAX_VALUE (0xfff) /* 12-bit adc */ #define ADCbatt_VREF_PLUS (3300) /* Vref+ is connected with Vdda (3.3v) */ -#define ADCbatt_VREF_MINUS (2300) /* Vref- is connected with Vssa (2.1v) */ +#define ADCbatt_VREF_MINUS (0) /* Vref- is connected with Vssa (2.1v) */ #define ADCsound_MIN_VALUE (0) #define ADCsound_MAX_VALUE (0xfff) /* 12-bit adc */ -#define ADCsound_VREF_PLUS (2600) /* Vref+ is connected with Vdda (3.3v) */ +#define ADCsound_VREF_PLUS (2800) /* Vref+ is connected with Vdda (3.3v) */ #define ADCsound_VREF_MINUS (0) /* Vref- is connected with Vssa (0v) */ #define ADCbatt ADC1 @@ -32,7 +32,7 @@ #define ADCsound ADC2 #define ADCsound_RCC RCC_APB2Periph_ADC2 /* */ #define ADCsound_DIVIDER RCC_PCLK2_Div4 /* Can be 2/4/6/8. PCLK2 runs at 32Mhz, and max ADC clock is 14Mhz */ -#define ADCsound_CHANNEL ADC_Channel_12 /* 0/17 */ +#define ADCsound_CHANNEL ADC_Channel_11 /* 0/17 */ #define ADCsound_SAMPLETIME ADC_SampleTime_239Cycles5 #define ADCsound_GPIO_PIN GPIO_Pin_2 #define ADCsound_GPIO_PORT GPIOA diff --git a/Project/applications/smartcities/httpClient.c b/Project/applications/smartcities/httpClient.c index 39af085..2a2ab7f 100644 --- a/Project/applications/smartcities/httpClient.c +++ b/Project/applications/smartcities/httpClient.c @@ -85,7 +85,7 @@ int httpRequest(struct httpHeaders head, char* content, int content_size) neocon = netconn_new(NETCONN_TCP); if(neocon == NULL) { - printf("\\->Socket creation FAILED. Have you called liwb\r\n"); + printf("\\->Socket creation FAILED. Have you called libwismart_init_bsd_sockets ?\r\n"); } /*local_ip.addr = 0;//getip netconn_bind(neocon, IP_ADDR_ANY, LOCAL_PORT); //88 is provisional local port.*/ @@ -103,7 +103,7 @@ int httpRequest(struct httpHeaders head, char* content, int content_size) //neocon->recv_timeout = 5000; // for 5s connection_ok = netconn_recv(neocon, &netBufs); printf("res recv= %d\r\n",connection_ok); - + if(connection_ok !=0) { netbuf_delete(netBufs); diff --git a/Project/applications/smartcities/json.c b/Project/applications/smartcities/json.c index 32aff25..3ffd8f9 100644 --- a/Project/applications/smartcities/json.c +++ b/Project/applications/smartcities/json.c @@ -19,7 +19,7 @@ uint8_t register_sensor(sensor sens) } char sensor_ID[3]; sprintf(sensor_ID,"%02x",sens.ID); - result = send_json(statement,strlen(statement),mod.ID,sensor_ID); + result = send_json(statement,strlen(statement),mod.ID,NULL); chHeapFree(statement); return result; } @@ -127,9 +127,9 @@ uint8_t send_json(char* statement, uint32_t length, char* provider_ID, char* sen { URL = (char*) chHeapAlloc(NULL,8+strlen(SERVER_HOSTNAME)); strcpy(URL,SERVER_HOSTNAME); - PATH = (char*) chHeapAlloc(NULL,10+strlen(provider_ID)); - strcpy(PATH,"/catalog/"); - strcpy(PATH+9,provider_ID); + PATH = (char*) chHeapAlloc(NULL,19); + strcpy(PATH,"/catalog/register"); + //strcpy(PATH+9,provider_ID); } else //Post data { diff --git a/Project/applications/smartcities/main2.c b/Project/applications/smartcities/main2.c index d4a0f2a..4e951f1 100644 --- a/Project/applications/smartcities/main2.c +++ b/Project/applications/smartcities/main2.c @@ -186,8 +186,8 @@ void wifi_connect(void) void send_battery_level(unsigned long timestamp) { uint8_t result; - //char *batt_level = battery_value(get_battery_data()); - char *batt_level = battery_value(3300); + char *batt_level = battery_value(get_battery_data()); + //char *batt_level = battery_value(3300); char *batt_data = timestamp_data(batt_level,getDate(timestamp)); chHeapFree(batt_level); char *statement = prepare_json_observation_statement(&batt_data,1); @@ -210,6 +210,8 @@ void send_battery_level(unsigned long timestamp) } void wifi_disconnect(void){ + connected = 0; + timeout = 0; uint8_t res=libwismart_WiFiDisconnect(); if(res) printf("WIFI_DISCONNECT_SUCCESS\r\n"); diff --git a/Project/applications/smartcities/sensors.c b/Project/applications/smartcities/sensors.c index ca7689e..6428034 100644 --- a/Project/applications/smartcities/sensors.c +++ b/Project/applications/smartcities/sensors.c @@ -321,7 +321,7 @@ uint16_t get_humidity_data(void) init_humidity_temp(); printf("HUMIDITY_TEMP: Initialized humidity\r\n"); uint16_t data = 0; - I2C_start(I2C1,PRESSURE_ADDR << 1, I2C_Direction_Receiver); + I2C_start(I2C1,HUMIDITY_TEMP_ADDR << 1, I2C_Direction_Receiver); data = I2C_read_ack(I2C1) & 0x3F; printf("HUMIDITY_TEMP: Got humidity high byte\r\n"); data = data << 8; @@ -335,7 +335,7 @@ uint16_t get_temperature_data(void) init_humidity_temp(); printf("HUMIDITY_TEMP: Initialized temperature\r\n"); uint16_t data = 0; - I2C_start(I2C1,PRESSURE_ADDR << 1, I2C_Direction_Receiver); + I2C_start(I2C1,HUMIDITY_TEMP_ADDR << 1, I2C_Direction_Receiver); I2C_read_ack(I2C1); printf("HUMIDITY_TEMP: Discarded first humidity byte\r\n"); I2C_read_ack(I2C1);