aboutsummaryrefslogtreecommitdiff
path: root/services.h
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-07-26 18:06:29 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-07-26 19:27:13 +0200
commitafd694f05178c22b4f71f65143c4647ce912d980 (patch)
treebde5b59098c453a4355f63eaaabdf95f9e2679bb /services.h
parenta64156388fc92da1d151a1094e25d9d89240bb38 (diff)
downloadtrygvisio_soil_moisture-afd694f05178c22b4f71f65143c4647ce912d980.tar.gz
trygvisio_soil_moisture-afd694f05178c22b4f71f65143c4647ce912d980.tar.bz2
trygvisio_soil_moisture-afd694f05178c22b4f71f65143c4647ce912d980.tar.xz
trygvisio_soil_moisture-afd694f05178c22b4f71f65143c4647ce912d980.zip
o Much improved Debug class.
- Inlining all definitions to make everything shorter and easier to read. - More const so even more can be inlined. o Adding some support for ATTiny85, still more work to be done. o Removing two unused battery characteristics. o Dynamically adding battery and temperature characteristics if their pipes are defined.
Diffstat (limited to 'services.h')
-rw-r--r--services.h145
1 files changed, 91 insertions, 54 deletions
diff --git a/services.h b/services.h
index 94efd74..b2b1853 100644
--- a/services.h
+++ b/services.h
@@ -11,7 +11,7 @@
#define SETUP_ID 0
#define SETUP_FORMAT 3 /** nRF8001 D */
-#define ACI_DYNAMIC_DATA_SIZE 180
+#define ACI_DYNAMIC_DATA_SIZE 166
/* Service: Gap - Characteristic: Device name - Pipe: SET */
#define PIPE_GAP_DEVICE_NAME_SET 1
@@ -21,42 +21,32 @@
#define PIPE_BATTERY_BATTERY_LEVEL_SET 2
#define PIPE_BATTERY_BATTERY_LEVEL_SET_MAX_SIZE 1
-/* Service: Battery - Characteristic: Battery Power State - Pipe: SET */
-#define PIPE_BATTERY_BATTERY_POWER_STATE_SET 3
-#define PIPE_BATTERY_BATTERY_POWER_STATE_SET_MAX_SIZE 1
-
-/* Service: Battery - Characteristic: Battery Level State - Pipe: SET */
-#define PIPE_BATTERY_BATTERY_LEVEL_STATE_SET 4
-#define PIPE_BATTERY_BATTERY_LEVEL_STATE_SET_MAX_SIZE 2
-
/* Service: Soil Moisture - Characteristic: Soil Moisture Control - Pipe: TX */
-#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX 5
+#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX 3
#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX_MAX_SIZE 20
/* Service: Soil Moisture - Characteristic: Soil Moisture Control - Pipe: SET */
-#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET 6
+#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET 4
#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET_MAX_SIZE 20
/* Service: Soil Moisture - Characteristic: Soil Moisture Control - Pipe: RX_ACK_AUTO */
-#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_RX_ACK_AUTO 7
+#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_RX_ACK_AUTO 5
#define PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_RX_ACK_AUTO_MAX_SIZE 20
/* Service: Soil Moisture - Characteristic: Intermediate Temperature - Pipe: TX */
-#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX 8
-#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX_MAX_SIZE 10
+#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX 6
+#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX_MAX_SIZE 5
/* Service: Soil Moisture - Characteristic: Intermediate Temperature - Pipe: SET */
-#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET 9
-#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET_MAX_SIZE 10
+#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET 7
+#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET_MAX_SIZE 5
-#define NUMBER_OF_PIPES 9
+#define NUMBER_OF_PIPES 7
#define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\
{ACI_STORE_LOCAL, ACI_SET}, \
{ACI_STORE_LOCAL, ACI_SET}, \
- {ACI_STORE_LOCAL, ACI_SET}, \
- {ACI_STORE_LOCAL, ACI_SET}, \
{ACI_STORE_LOCAL, ACI_TX}, \
{ACI_STORE_LOCAL, ACI_SET}, \
{ACI_STORE_LOCAL, ACI_RX_ACK_AUTO}, \
@@ -69,7 +59,73 @@
#define GAP_PPCP_SLAVE_LATENCY 0
#define GAP_PPCP_CONN_TIMEOUT 0xffff /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */
-#define NB_SETUP_MESSAGES 23
+/** @brief do a set_local_data for PIPE_GAP_DEVICE_NAME_SET
+ * @param src source buffer to send data from
+ * @param size the number of bytes to send. Maximum size is 10
+ * @details use this function to do a set_local_data for PIPE_GAP_DEVICE_NAME_SET. If no transaction are currently
+ * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
+ * when services_update_pipes will be called.
+ */
+void services_set_gap_device_name(void *src, int size);
+
+/** @brief do a set_local_data for PIPE_BATTERY_BATTERY_LEVEL_SET
+ * @param src the value to send
+ * @details use this function to do a set_local_data for PIPE_BATTERY_BATTERY_LEVEL_SET. If no transaction are currently
+ * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
+ * when services_update_pipes will be called.
+ */
+void services_set_battery_battery_level(uint8_t src);
+
+/** @brief send a new value for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX
+ * @param src source buffer to send data from
+ * @param size the number of bytes to send. Maximum size is 20
+ * @param is_freshest_sample set it to true if you want to overwrite an eventual pending transaction on this pipe.
+ * @details use this function to send a new value for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX. If no transaction are currently
+ * running, the send will be immediate, otherwise, it will be done at the end of the current transaction
+ * when services_update_pipes will be called. If a transaction on this pipe is already pending, then this function
+ * will not overwrite the data of the previous transaction and return false.
+ * @return : true if is_freshest_sample true, otherwise return false if a transaction on this pipe is already pending, true otherwise.
+ */
+bool services_send_soil_moisture_soil_moisture_control(void *src, int size, bool is_freshest_sample);
+
+/** @brief do a set_local_data for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET
+ * @param src source buffer to send data from
+ * @param size the number of bytes to send. Maximum size is 20
+ * @details use this function to do a set_local_data for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET. If no transaction are currently
+ * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
+ * when services_update_pipes will be called.
+ */
+void services_set_soil_moisture_soil_moisture_control(void *src, int size);
+
+/** @brief send a new value for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX
+ * @param src source buffer to send data from
+ * @param size the number of bytes to send. Maximum size is 5
+ * @param is_freshest_sample set it to true if you want to overwrite an eventual pending transaction on this pipe.
+ * @details use this function to send a new value for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX. If no transaction are currently
+ * running, the send will be immediate, otherwise, it will be done at the end of the current transaction
+ * when services_update_pipes will be called. If a transaction on this pipe is already pending, then this function
+ * will not overwrite the data of the previous transaction and return false.
+ * @return : true if is_freshest_sample true, otherwise return false if a transaction on this pipe is already pending, true otherwise.
+ */
+bool services_send_soil_moisture_intermediate_temperature(void *src, int size, bool is_freshest_sample);
+
+/** @brief do a set_local_data for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET
+ * @param src source buffer to send data from
+ * @param size the number of bytes to send. Maximum size is 5
+ * @details use this function to do a set_local_data for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET. If no transaction are currently
+ * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
+ * when services_update_pipes will be called.
+ */
+void services_set_soil_moisture_intermediate_temperature(void *src, int size);
+
+/** @brief function to trig pending transaction on pipes
+ * @details This function check for each pipe if it has a pending transaction (send/rx_request/ack)
+ * and if so executes this transaction.
+ * This function should be called in the APP_RUN state of the process function of the application.
+ */
+void services_update_pipes(void);
+
+#define NB_SETUP_MESSAGES 20
#define SETUP_MESSAGES_CONTENT {\
{0x00,\
{\
@@ -78,7 +134,7 @@
},\
{0x00,\
{\
- 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x09,0x01,0x01,0x00,0x00,0x06,0x00,0x01,\
+ 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x07,0x01,0x01,0x00,0x00,0x06,0x00,0x01,\
0xd1,0x0f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
},\
},\
@@ -131,61 +187,43 @@
},\
{0x00,\
{\
- 0x1f,0x06,0x20,0x8c,0x00,0x0b,0x2a,0x19,0x01,0x10,0x04,0x04,0x05,0x05,0x00,0x0c,0x28,0x03,0x01,0x02,\
- 0x0d,0x00,0x1a,0x2a,0x06,0x04,0x02,0x01,0x00,0x0d,0x2a,0x1a,\
+ 0x1f,0x06,0x20,0x8c,0x00,0x0b,0x2a,0x19,0x01,0x10,0x04,0x04,0x10,0x10,0x00,0x0c,0x28,0x00,0x01,0x3f,\
+ 0xd8,0x1f,0x4a,0x8e,0xbc,0xd3,0x70,0xc5,0x59,0x5d,0x03,0x10,\
},\
},\
{0x00,\
{\
- 0x1f,0x06,0x20,0xa8,0x01,0x00,0x04,0x04,0x05,0x05,0x00,0x0e,0x28,0x03,0x01,0x02,0x0f,0x00,0x1b,0x2a,\
- 0x06,0x04,0x03,0x02,0x00,0x0f,0x2a,0x1b,0x01,0x00,0x00,0x04,\
+ 0x1f,0x06,0x20,0xa8,0x00,0xd0,0x32,0x04,0x04,0x13,0x13,0x00,0x0d,0x28,0x03,0x01,0x1a,0x0e,0x00,0x3f,\
+ 0xd8,0x1f,0x4a,0x8e,0xbc,0xd3,0x70,0xc5,0x59,0x5d,0x03,0x11,\
},\
},\
{0x00,\
{\
- 0x1f,0x06,0x20,0xc4,0x04,0x10,0x10,0x00,0x10,0x28,0x00,0x01,0x3f,0xd8,0x1f,0x4a,0x8e,0xbc,0xd3,0x70,\
- 0xc5,0x59,0x5d,0x03,0x10,0x00,0xd0,0x32,0x04,0x04,0x13,0x13,\
- },\
- },\
- {0x00,\
- {\
- 0x1f,0x06,0x20,0xe0,0x00,0x11,0x28,0x03,0x01,0x1a,0x12,0x00,0x3f,0xd8,0x1f,0x4a,0x8e,0xbc,0xd3,0x70,\
- 0xc5,0x59,0x5d,0x03,0x11,0x00,0xd0,0x32,0x54,0x14,0x14,0x00,\
- },\
- },\
- {0x00,\
- {\
- 0x1f,0x06,0x20,0xfc,0x00,0x12,0x00,0x11,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x14,0x03,\
+ 0x1f,0x06,0x20,0xc4,0x00,0xd0,0x32,0x54,0x14,0x14,0x00,0x00,0x0e,0x00,0x11,0x02,0x00,0x00,0x00,0x00,\
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
},\
},\
{0x00,\
{\
- 0x1f,0x06,0x21,0x18,0x02,0x00,0x13,0x29,0x02,0x01,0x00,0x00,0x04,0x04,0x05,0x05,0x00,0x14,0x28,0x03,\
- 0x01,0x12,0x15,0x00,0x1e,0x2a,0x16,0x04,0x0b,0x0a,0x00,0x15,\
+ 0x1f,0x06,0x20,0xe0,0x00,0x00,0x00,0x00,0x46,0x14,0x03,0x02,0x00,0x0f,0x29,0x02,0x01,0x00,0x00,0x04,\
+ 0x04,0x05,0x05,0x00,0x10,0x28,0x03,0x01,0x12,0x11,0x00,0x1e,\
},\
},\
{0x00,\
{\
- 0x1c,0x06,0x21,0x34,0x2a,0x1e,0x01,0xaa,0xbb,0xcc,0xdd,0xee,0xff,0x99,0x88,0x77,0x66,0x46,0x14,0x03,\
- 0x02,0x00,0x16,0x29,0x02,0x01,0x00,0x00,0x00,\
+ 0x1e,0x06,0x20,0xfc,0x2a,0x16,0x04,0x06,0x05,0x00,0x11,0x2a,0x1e,0x01,0x00,0x00,0x00,0x00,0x00,0x46,\
+ 0x14,0x03,0x02,0x00,0x12,0x29,0x02,0x01,0x00,0x00,0x00,\
},\
},\
{0x00,\
{\
0x1f,0x06,0x40,0x00,0x2a,0x00,0x01,0x00,0x80,0x04,0x00,0x03,0x00,0x00,0x2a,0x19,0x01,0x00,0x80,0x04,\
- 0x00,0x0b,0x00,0x00,0x2a,0x1a,0x01,0x00,0x80,0x04,0x00,0x0d,\
- },\
- },\
- {0x00,\
- {\
- 0x1f,0x06,0x40,0x1c,0x00,0x00,0x2a,0x1b,0x01,0x00,0x80,0x04,0x00,0x0f,0x00,0x00,0x00,0x11,0x02,0x04,\
- 0x82,0x04,0x00,0x12,0x00,0x13,0x2a,0x1e,0x01,0x00,0x82,0x04,\
+ 0x00,0x0b,0x00,0x00,0x00,0x11,0x02,0x04,0x82,0x04,0x00,0x0e,\
},\
},\
{0x00,\
{\
- 0x07,0x06,0x40,0x38,0x00,0x15,0x00,0x16,\
+ 0x0f,0x06,0x40,0x1c,0x00,0x0f,0x2a,0x1e,0x01,0x00,0x82,0x04,0x00,0x11,0x00,0x12,\
},\
},\
{0x00,\
@@ -195,13 +233,12 @@
},\
{0x00,\
{\
- 0x15,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
- 0x00,0x00,\
+ 0x0f,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
},\
},\
{0x00,\
{\
- 0x06,0x06,0xf0,0x00,0x03,0xb7,0x68,\
+ 0x06,0x06,0xf0,0x00,0x03,0xb7,0x22,\
},\
},\
}