This library provides data update method to Fastsensing.

Dependents:   SCP1000_Fastsensing

Committer:
AkiraK
Date:
Sun Jul 02 08:40:05 2017 +0000
Revision:
11:caefbbb4eca8
Parent:
10:a7e8d865c53d
Add Environment condition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AkiraK 8:21b39074c0f5 1 /*
AkiraK 8:21b39074c0f5 2 MIT License
AkiraK 8:21b39074c0f5 3
AkiraK 8:21b39074c0f5 4 Copyright (c) 2017 Fast Sensing Inc.
AkiraK 8:21b39074c0f5 5
AkiraK 8:21b39074c0f5 6 Permission is hereby granted, free of charge, to any person obtaining a copy
AkiraK 8:21b39074c0f5 7 of this software and associated documentation files (the "Software"), to deal
AkiraK 8:21b39074c0f5 8 in the Software without restriction, including without limitation the rights
AkiraK 8:21b39074c0f5 9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
AkiraK 8:21b39074c0f5 10 copies of the Software, and to permit persons to whom the Software is
AkiraK 8:21b39074c0f5 11 furnished to do so, subject to the following conditions:
AkiraK 8:21b39074c0f5 12
AkiraK 8:21b39074c0f5 13 The above copyright notice and this permission notice shall be included in all
AkiraK 8:21b39074c0f5 14 copies or substantial portions of the Software.
AkiraK 8:21b39074c0f5 15
AkiraK 8:21b39074c0f5 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
AkiraK 8:21b39074c0f5 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
AkiraK 8:21b39074c0f5 18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AkiraK 8:21b39074c0f5 19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
AkiraK 8:21b39074c0f5 20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AkiraK 8:21b39074c0f5 21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
AkiraK 8:21b39074c0f5 22 SOFTWARE.
AkiraK 8:21b39074c0f5 23 */
AkiraK 8:21b39074c0f5 24
AkiraK 0:f26c02be48f9 25 #ifndef FASTSENSING_H
AkiraK 0:f26c02be48f9 26 #define FASTSENSING_H
AkiraK 0:f26c02be48f9 27
AkiraK 0:f26c02be48f9 28 #include "mbed.h"
AkiraK 0:f26c02be48f9 29 #include "EthernetInterface.h"
AkiraK 0:f26c02be48f9 30
AkiraK 9:313790e8b56d 31 /** Fastsensing Data Update class.
AkiraK 11:caefbbb4eca8 32 * You can update data to your Fastsensing account used this class. This Liberary is tested on mbedOS 5.3.
AkiraK 9:313790e8b56d 33 *
AkiraK 9:313790e8b56d 34 * Example:
AkiraK 9:313790e8b56d 35 * @code
AkiraK 9:313790e8b56d 36 * #include "mbed.h"
AkiraK 9:313790e8b56d 37 * #include "Fastsensing.h"
AkiraK 9:313790e8b56d 38 *
AkiraK 9:313790e8b56d 39 * Fastsensing fast;
AkiraK 9:313790e8b56d 40 * AnalogIn illu(p20);
AkiraK 9:313790e8b56d 41 * DigitalOut myled(LED1);
AkiraK 9:313790e8b56d 42 *
AkiraK 9:313790e8b56d 43 * int main()
AkiraK 9:313790e8b56d 44 * {
AkiraK 9:313790e8b56d 45 * float lx = illu * 3.3 / 3 * 1000;
AkiraK 9:313790e8b56d 46 * printf("lx : %f\n", lx);
AkiraK 9:313790e8b56d 47 * for(int i = 0; i < 5; i++) {
AkiraK 9:313790e8b56d 48 * fast.updateData("UIYCOQAATQAO5AF7", channel[0], lx,1 );
AkiraK 9:313790e8b56d 49 * wait(5.0);
AkiraK 9:313790e8b56d 50 * }
AkiraK 9:313790e8b56d 51 * while(1) {
AkiraK 9:313790e8b56d 52 * myled = 1;
AkiraK 9:313790e8b56d 53 * wait(0.5);
AkiraK 9:313790e8b56d 54 * myled = 0;
AkiraK 9:313790e8b56d 55 * wait(0.5);
AkiraK 9:313790e8b56d 56 * }
AkiraK 10:a7e8d865c53d 57 * }
AkiraK 9:313790e8b56d 58 * @endcode
AkiraK 9:313790e8b56d 59 */
AkiraK 9:313790e8b56d 60 class Fastsensing {
AkiraK 9:313790e8b56d 61 private:
AkiraK 9:313790e8b56d 62 EthernetInterface eth; //create eth instance from Ethernet
AkiraK 9:313790e8b56d 63
AkiraK 9:313790e8b56d 64 public:
AkiraK 9:313790e8b56d 65 /**
AkiraK 9:313790e8b56d 66 * Only one data update.
AkiraK 9:313790e8b56d 67 * @param *deviceId It is issued your dashboard on fastsening. Device ID length is 16 characters.
AkiraK 9:313790e8b56d 68 * @param *channelId It is issued your dashboard on fastsensing. Channel ID length is 8characters.
AkiraK 9:313790e8b56d 69 * @param data It is the data you want to update.
AkiraK 9:313790e8b56d 70 * @param display 1 is display your sent data and recieve data. 0 is not.
AkiraK 9:313790e8b56d 71 * @return
AkiraK 9:313790e8b56d 72 * 0 on success, -1 on deviceId length error, -2 on channelId length error
AkiraK 9:313790e8b56d 73 */
AkiraK 9:313790e8b56d 74 int updateData(char *deviceId, char *channelId, double data, int display);
AkiraK 9:313790e8b56d 75 /**
AkiraK 9:313790e8b56d 76 * Only one data update.
AkiraK 9:313790e8b56d 77 * @param *deviceId It is issued your dashboard on fastsening. Device ID length is 16 characters.
AkiraK 9:313790e8b56d 78 * @param *channelId[3] These are issued your dashboard on fastsensing. Channel ID length is 8characters.
AkiraK 9:313790e8b56d 79 * @param data[3] These are the data you want to update.
AkiraK 9:313790e8b56d 80 * @param display 1 is display your sent data and recieve data. 0 is not.
AkiraK 9:313790e8b56d 81 * @return
AkiraK 9:313790e8b56d 82 * 0 on success, -1 on deviceId length error, -2 on channelId length error
AkiraK 9:313790e8b56d 83 */
AkiraK 9:313790e8b56d 84 int updateDataAll(char *deviceId, char *channelId[3], float data[3], int display);
AkiraK 9:313790e8b56d 85
AkiraK 0:f26c02be48f9 86 };
AkiraK 0:f26c02be48f9 87
AkiraK 0:f26c02be48f9 88 #endif