SAKURA Internet IoT Communication Module Library for mbed
Dependents: patlite_sakuraio sakuraio_lte_firmwareupdater shownet2017-iinebutton patlite_sakuraio_stack ... more
SAKURA Internet IoT Communication Module Library for mbed
Sakura Communication Module (with sakura.io) library for mbed.
Support
This library supports following products.
- SCM-LTE-01 (sakura.io Module (LTE) )
- SCM-LTE-Beta (Sakura Communication Module (LTE) β)
Reference
Please see the datasheet.
License
The MIT License (MIT)
Copyright (c) SAKURA Internet Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SakuraIO.h@6:34a0233cdf04, 2017-01-06 (annotated)
- Committer:
- chibiegg
- Date:
- Fri Jan 06 18:03:02 2017 +0900
- Revision:
- 6:34a0233cdf04
- Parent:
- 3:c54a1eba22c4
- Child:
- 7:9feee88e7cbc
Follow SakuraIOArduino v1.0.3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chibiegg | 3:c54a1eba22c4 | 1 | /* SAKURA Internet IoT Communication Module Library for mbed |
chibiegg | 6:34a0233cdf04 | 2 | * |
chibiegg | 3:c54a1eba22c4 | 3 | * The MIT License (MIT) |
chibiegg | 6:34a0233cdf04 | 4 | * |
chibiegg | 3:c54a1eba22c4 | 5 | * Copyright (c) SAKURA Internet Inc. |
chibiegg | 6:34a0233cdf04 | 6 | * |
chibiegg | 3:c54a1eba22c4 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
chibiegg | 3:c54a1eba22c4 | 8 | * of this software and associated documentation files (the "Software"), |
chibiegg | 3:c54a1eba22c4 | 9 | * to deal in the Software without restriction, including without limitation |
chibiegg | 3:c54a1eba22c4 | 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
chibiegg | 3:c54a1eba22c4 | 11 | * and/or sell copies of the Software, and to permit persons to whom the Software |
chibiegg | 3:c54a1eba22c4 | 12 | * is furnished to do so, subject to the following conditions: |
chibiegg | 6:34a0233cdf04 | 13 | * |
chibiegg | 3:c54a1eba22c4 | 14 | * The above copyright notice and this permission notice shall be included |
chibiegg | 3:c54a1eba22c4 | 15 | * in all copies or substantial portions of the Software. |
chibiegg | 6:34a0233cdf04 | 16 | * |
chibiegg | 3:c54a1eba22c4 | 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
chibiegg | 3:c54a1eba22c4 | 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
chibiegg | 3:c54a1eba22c4 | 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
chibiegg | 3:c54a1eba22c4 | 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
chibiegg | 3:c54a1eba22c4 | 21 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
chibiegg | 3:c54a1eba22c4 | 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
chibiegg | 3:c54a1eba22c4 | 23 | */ |
chibiegg | 3:c54a1eba22c4 | 24 | |
spiralray | 0:8d34375d954c | 25 | #ifndef _SAKURAIO_H_ |
spiralray | 0:8d34375d954c | 26 | #define _SAKURAIO_H_ |
spiralray | 0:8d34375d954c | 27 | |
spiralray | 1:20e1dfe45dab | 28 | #include "mbed.h" |
spiralray | 0:8d34375d954c | 29 | #include <SakuraIO/commands.h> |
spiralray | 0:8d34375d954c | 30 | |
spiralray | 0:8d34375d954c | 31 | class SakuraIO |
spiralray | 0:8d34375d954c | 32 | { |
spiralray | 0:8d34375d954c | 33 | protected: |
spiralray | 0:8d34375d954c | 34 | virtual void begin(){} |
spiralray | 0:8d34375d954c | 35 | virtual void end(){} |
spiralray | 0:8d34375d954c | 36 | |
spiralray | 0:8d34375d954c | 37 | virtual void sendByte(uint8_t data){} |
spiralray | 0:8d34375d954c | 38 | //virtual void finishSending(){} |
spiralray | 0:8d34375d954c | 39 | |
spiralray | 0:8d34375d954c | 40 | virtual uint8_t startReceive(uint8_t length){return length;}; |
spiralray | 0:8d34375d954c | 41 | virtual uint8_t receiveByte(){return 0x00;} |
spiralray | 0:8d34375d954c | 42 | virtual uint8_t receiveByte(bool stop){return 0x00;} |
spiralray | 0:8d34375d954c | 43 | //virtual void finishReceiving(){} |
spiralray | 0:8d34375d954c | 44 | |
spiralray | 0:8d34375d954c | 45 | uint8_t executeCommand(uint8_t cmd,uint8_t requestLength, uint8_t *request, uint8_t *responseLength, uint8_t *response); |
spiralray | 0:8d34375d954c | 46 | |
spiralray | 0:8d34375d954c | 47 | uint8_t enqueueTxRaw(uint8_t ch, uint8_t type, uint8_t length, uint8_t *data, uint64_t offset); |
spiralray | 0:8d34375d954c | 48 | |
spiralray | 0:8d34375d954c | 49 | public: |
spiralray | 0:8d34375d954c | 50 | uint8_t getConnectionStatus(); |
chibiegg | 6:34a0233cdf04 | 51 | uint8_t getSignalQuarity(); // Deprecated |
chibiegg | 6:34a0233cdf04 | 52 | uint8_t getSignalQuality(); |
spiralray | 0:8d34375d954c | 53 | uint64_t getUnixtime(); |
spiralray | 0:8d34375d954c | 54 | uint8_t echoback(uint8_t length, uint8_t *data, uint8_t *response); |
spiralray | 0:8d34375d954c | 55 | uint16_t getADC(uint8_t channel); |
spiralray | 0:8d34375d954c | 56 | uint8_t enqueueTx(uint8_t ch, int32_t value, uint64_t offset); |
spiralray | 0:8d34375d954c | 57 | uint8_t enqueueTx(uint8_t ch, uint32_t value, uint64_t offset); |
spiralray | 0:8d34375d954c | 58 | uint8_t enqueueTx(uint8_t ch, int64_t value, uint64_t offset); |
spiralray | 0:8d34375d954c | 59 | uint8_t enqueueTx(uint8_t ch, uint64_t value, uint64_t offset); |
spiralray | 0:8d34375d954c | 60 | uint8_t enqueueTx(uint8_t ch, float value, uint64_t offset); |
spiralray | 0:8d34375d954c | 61 | uint8_t enqueueTx(uint8_t ch, double value, uint64_t offset); |
spiralray | 0:8d34375d954c | 62 | uint8_t enqueueTx(uint8_t ch, uint8_t value[8], uint64_t offset); |
spiralray | 0:8d34375d954c | 63 | uint8_t enqueueTx(uint8_t ch, int32_t value); |
spiralray | 0:8d34375d954c | 64 | uint8_t enqueueTx(uint8_t ch, uint32_t value); |
spiralray | 0:8d34375d954c | 65 | uint8_t enqueueTx(uint8_t ch, int64_t value); |
spiralray | 0:8d34375d954c | 66 | uint8_t enqueueTx(uint8_t ch, uint64_t value); |
spiralray | 0:8d34375d954c | 67 | uint8_t enqueueTx(uint8_t ch, float value); |
spiralray | 0:8d34375d954c | 68 | uint8_t enqueueTx(uint8_t ch, double value); |
spiralray | 0:8d34375d954c | 69 | uint8_t enqueueTx(uint8_t ch, uint8_t value[8]); |
spiralray | 0:8d34375d954c | 70 | uint8_t getTxQueueLength(uint8_t *available, uint8_t *queued); |
spiralray | 0:8d34375d954c | 71 | uint8_t clearTx(); |
spiralray | 0:8d34375d954c | 72 | uint8_t getTxStatus(uint8_t *queue, uint8_t *immediate); |
spiralray | 0:8d34375d954c | 73 | uint8_t send(); |
spiralray | 0:8d34375d954c | 74 | uint8_t dequeueRx(uint8_t *ch, uint8_t *type, uint8_t *value, int64_t *offset); |
spiralray | 0:8d34375d954c | 75 | uint8_t peekRx(uint8_t *ch, uint8_t *type, uint8_t *value, int64_t *offset); |
spiralray | 0:8d34375d954c | 76 | uint8_t getRxQueueLength(uint8_t *available, uint8_t *queued); |
spiralray | 0:8d34375d954c | 77 | uint8_t clearRx(); |
spiralray | 0:8d34375d954c | 78 | uint16_t getProductID(); |
spiralray | 0:8d34375d954c | 79 | uint8_t getUniqueID(char *data); |
spiralray | 0:8d34375d954c | 80 | uint8_t getFirmwareVersion(char *data); |
spiralray | 0:8d34375d954c | 81 | uint8_t unlock(); |
spiralray | 0:8d34375d954c | 82 | uint8_t updateFirmware(); |
spiralray | 0:8d34375d954c | 83 | uint8_t getFirmwareUpdateStatus(); |
spiralray | 0:8d34375d954c | 84 | uint8_t reset(); |
spiralray | 0:8d34375d954c | 85 | }; |
spiralray | 0:8d34375d954c | 86 | |
spiralray | 0:8d34375d954c | 87 | class SakuraIO_SPI : public SakuraIO |
spiralray | 0:8d34375d954c | 88 | { |
spiralray | 0:8d34375d954c | 89 | protected: |
spiralray | 0:8d34375d954c | 90 | SPI &spi; |
spiralray | 0:8d34375d954c | 91 | DigitalOut &cs; |
spiralray | 2:6f8e51a42a7d | 92 | virtual void begin(); |
spiralray | 2:6f8e51a42a7d | 93 | virtual void end(); |
spiralray | 2:6f8e51a42a7d | 94 | virtual void sendByte(uint8_t data); |
spiralray | 2:6f8e51a42a7d | 95 | virtual uint8_t receiveByte(bool stop); |
spiralray | 2:6f8e51a42a7d | 96 | virtual uint8_t receiveByte(); |
spiralray | 0:8d34375d954c | 97 | public: |
spiralray | 0:8d34375d954c | 98 | SakuraIO_SPI(SPI &_spi, DigitalOut &_cs); |
spiralray | 0:8d34375d954c | 99 | }; |
spiralray | 0:8d34375d954c | 100 | |
spiralray | 0:8d34375d954c | 101 | class SakuraIO_I2C : public SakuraIO |
spiralray | 0:8d34375d954c | 102 | { |
spiralray | 0:8d34375d954c | 103 | protected: |
spiralray | 1:20e1dfe45dab | 104 | I2C i2c; |
spiralray | 1:20e1dfe45dab | 105 | int _length; |
chibiegg | 6:34a0233cdf04 | 106 | |
spiralray | 1:20e1dfe45dab | 107 | virtual void begin(); |
spiralray | 1:20e1dfe45dab | 108 | virtual void end(); |
spiralray | 1:20e1dfe45dab | 109 | virtual void sendByte(uint8_t data); |
spiralray | 1:20e1dfe45dab | 110 | virtual uint8_t startReceive(uint8_t length); |
spiralray | 1:20e1dfe45dab | 111 | virtual uint8_t receiveByte(bool stop); |
spiralray | 1:20e1dfe45dab | 112 | virtual uint8_t receiveByte(); |
spiralray | 0:8d34375d954c | 113 | uint8_t mode; |
spiralray | 0:8d34375d954c | 114 | public: |
spiralray | 1:20e1dfe45dab | 115 | SakuraIO_I2C (I2C &_i2c); |
spiralray | 1:20e1dfe45dab | 116 | SakuraIO_I2C (PinName sda, PinName scl); |
spiralray | 0:8d34375d954c | 117 | }; |
spiralray | 0:8d34375d954c | 118 | |
spiralray | 0:8d34375d954c | 119 | #endif // _SAKURAIO_H_ |