diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c52f4f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,75 @@ +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser +# Project exclude paths +/.gradle/ +/build/ +/build/classes/java/main/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/artifacts/carelink_client_jar.xml b/.idea/artifacts/carelink_client_jar.xml new file mode 100644 index 0000000..fd3e97e --- /dev/null +++ b/.idea/artifacts/carelink_client_jar.xml @@ -0,0 +1,11 @@ + + + $PROJECT_DIR$/out/artifacts/client + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..0510f69 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..2b2fd4f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules/CareLinkJavaClient.iml b/.idea/modules/CareLinkJavaClient.iml new file mode 100644 index 0000000..b392021 --- /dev/null +++ b/.idea/modules/CareLinkJavaClient.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bae94e1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4fd8e4c --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +# CareLinkJavaClient +> Experimental Medtronic CareLink Client in Java + +Java library, which can be used for retrieving data from Medtronic CareLink of online CGM and insulin pump device data uploads (Guardian Connect, MiniMed 7xxG) inside and outside of US. Originally it was started as a Guardian Connect CGM data from CareLink to Nightscout alternative for Nightscout MiniMed Connect, because Medtronic started to block requests from Heroku. Later it turned out that the core Nightscout MiniMed Connect logic can be also used for 7xxG pumps with some modifications based on the US online CareLink Connect webapp (770G is still working). The US data retrieval logic was also working outside the US with the 780G pumps too, although the online CareLink Connect webapp outside US doesn't support the new generation pumps. Finally the code was extended to handle the 7xxG devices too both inside and outside the US. + +## Status +**The development is in a very early stage!** + +## Features +- Login to CareLink and provide access token for CareLink API calls +- Some basic CareLink APIs: get user data, get user profile, get country settings, get last 24 hours, get recent data from CareLink Cloud +- Wrapper method for getting data uploaded by Medtronic BLE devices of the last 24 hours +- CareLink Client CLI + +## Limitations +- **CareLink MFA is not supported!!!** +- Notification messages are in English + +## Requirements +- CareLink account **with MFA NOT ENABLED!**: + - Guardian Connect CGM outside US: patient or care partner account + - Guardian Connect CGM inside US: **not tested yet!** (possibly a care partner account) + - 7xxG pump outside US: care partner account (same as for Medtronic CareLink Connect app) + - 7xxG pump inside US: care partner account (same as for Medtronic CareLink Connect app) +- Runtime: Java 1.8 +- External libraries used: + - Kotlin 1.4 + - OkIO 2.8 + - OkHttp 4.9 + - Gson 2.8 + - Commons CLI 1.4 + +## How to use + +### Download and install [latest release](https://github.com/benceszasz/CareLinkJavaClient/releases) + +### Get data of last 24 hours using Java + CareLinkClient client; + RecentData recentData; + + client = new CareLinkClient("carelink_username", "carelink_password", "carelink_country_code"); + if(client.login()) { + recentData = client.getRecentData(); + } + +### Download last 24 hours using CLI + java -jar carelink-client.jar -u carelink_username -p carelink_password -c carelink_country_code -d + +### Get CLI options + java -jar carelink-client.jar + +## Credits +CareLink data download core logic is based on the [Nightscout MiniMed Connect to Nightscout](https://github.com/nightscout/minimed-connect-to-nightscout) + +## Disclaimer And Warning +This project is intended for educational and informational purposes only. It relies on a series of fragile components and assumptions, any of which may break at any time. It is not FDA approved and should not be used to make medical decisions. It is neither affiliated with nor endorsed by Medtronic, and may violate their Terms of Service. Use of this code is without warranty or formal support of any kind. + +## License + +[agpl-3]: http://www.gnu.org/licenses/agpl-3.0.txt + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..44656e2 --- /dev/null +++ b/build.gradle @@ -0,0 +1,32 @@ +plugins { + id 'java' +} + +group 'info.nightscout' +version '0.1-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + compile 'com.squareup.okhttp3:okhttp:4.9.1' + compile 'com.google.code.gson:gson:2.8.2' + compile 'commons-cli:commons-cli:1.4' +} + +jar { + manifest { + attributes 'Main-Class': 'info.nightscout.medtronic.carelink.cli.CareLinkClientCLI' + } + + from { + configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } + } +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..be52383 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/lib/annotations-13.0-javadoc.jar b/lib/annotations-13.0-javadoc.jar new file mode 100644 index 0000000..2c57f97 Binary files /dev/null and b/lib/annotations-13.0-javadoc.jar differ diff --git a/lib/annotations-13.0.jar b/lib/annotations-13.0.jar new file mode 100644 index 0000000..fb794be Binary files /dev/null and b/lib/annotations-13.0.jar differ diff --git a/lib/commons-cli-1.4-javadoc.jar b/lib/commons-cli-1.4-javadoc.jar new file mode 100644 index 0000000..6b21f98 Binary files /dev/null and b/lib/commons-cli-1.4-javadoc.jar differ diff --git a/lib/commons-cli-1.4-sources.jar b/lib/commons-cli-1.4-sources.jar new file mode 100644 index 0000000..b747279 Binary files /dev/null and b/lib/commons-cli-1.4-sources.jar differ diff --git a/lib/commons-cli-1.4.jar b/lib/commons-cli-1.4.jar new file mode 100644 index 0000000..22deb30 Binary files /dev/null and b/lib/commons-cli-1.4.jar differ diff --git a/lib/gson-2.8.6-javadoc.jar b/lib/gson-2.8.6-javadoc.jar new file mode 100644 index 0000000..e3cce52 Binary files /dev/null and b/lib/gson-2.8.6-javadoc.jar differ diff --git a/lib/gson-2.8.6.jar b/lib/gson-2.8.6.jar new file mode 100644 index 0000000..4765c4a Binary files /dev/null and b/lib/gson-2.8.6.jar differ diff --git a/lib/kotlin-stdlib-1.4.10-javadoc.jar b/lib/kotlin-stdlib-1.4.10-javadoc.jar new file mode 100644 index 0000000..e3f3a95 Binary files /dev/null and b/lib/kotlin-stdlib-1.4.10-javadoc.jar differ diff --git a/lib/kotlin-stdlib-1.4.10.jar b/lib/kotlin-stdlib-1.4.10.jar new file mode 100644 index 0000000..5f24c2e Binary files /dev/null and b/lib/kotlin-stdlib-1.4.10.jar differ diff --git a/lib/kotlin-stdlib-common-1.4.0-javadoc.jar b/lib/kotlin-stdlib-common-1.4.0-javadoc.jar new file mode 100644 index 0000000..e3f3a95 Binary files /dev/null and b/lib/kotlin-stdlib-common-1.4.0-javadoc.jar differ diff --git a/lib/kotlin-stdlib-common-1.4.0.jar b/lib/kotlin-stdlib-common-1.4.0.jar new file mode 100644 index 0000000..2ea93b4 Binary files /dev/null and b/lib/kotlin-stdlib-common-1.4.0.jar differ diff --git a/lib/okhttp-4.9.1-javadoc.jar b/lib/okhttp-4.9.1-javadoc.jar new file mode 100644 index 0000000..a58f583 Binary files /dev/null and b/lib/okhttp-4.9.1-javadoc.jar differ diff --git a/lib/okhttp-4.9.1.jar b/lib/okhttp-4.9.1.jar new file mode 100644 index 0000000..e0f95b2 Binary files /dev/null and b/lib/okhttp-4.9.1.jar differ diff --git a/lib/okio-2.8.0-javadoc.jar b/lib/okio-2.8.0-javadoc.jar new file mode 100644 index 0000000..615ea2e Binary files /dev/null and b/lib/okio-2.8.0-javadoc.jar differ diff --git a/lib/okio-2.8.0.jar b/lib/okio-2.8.0.jar new file mode 100644 index 0000000..bac6c6e Binary files /dev/null and b/lib/okio-2.8.0.jar differ diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..6a9a253 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'CareLinkJavaClient' + diff --git a/src/main/java/info/nightscout/medtronic/carelink/cli/CareLinkClientCLI.java b/src/main/java/info/nightscout/medtronic/carelink/cli/CareLinkClientCLI.java new file mode 100644 index 0000000..9d3c6b5 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/cli/CareLinkClientCLI.java @@ -0,0 +1,325 @@ +package info.nightscout.medtronic.carelink.cli; + +import com.google.gson.GsonBuilder; +import info.nightscout.medtronic.carelink.client.CareLinkClient; +import info.nightscout.medtronic.carelink.message.*; +import org.apache.commons.cli.*; + + +import java.io.FileWriter; +import java.nio.file.Paths; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class CareLinkClientCLI { + + private static final String OPTION_COUNTRY = "c"; + private static final String OPTION_USERNAME = "u"; + private static final String OPTION_PASSWORD = "p"; + private static final String OPTION_OUTPUT = "o"; + private static final String OPTION_REPEAT = "r"; + private static final String OPTION_DATA = "d"; + private static final String OPTION_SESSION = "s"; + private static final String OPTION_WAIT = "w"; + private static final String OPTION_ANONYM = "a"; + private static final String OPTION_VERBOSE = "v"; + + + private static Options generateOptions() { + + final Options options = new Options(); + + //v - Verbose mode + options.addOption( + Option.builder(OPTION_VERBOSE) + .required(false) + .longOpt("verbose") + .hasArg(false) + .desc("Verbose mode.") + .build()); + + //c - CareLink country + options.addOption( + Option.builder(OPTION_COUNTRY) + .required(true) + .hasArg(true) + .longOpt("country") + .desc("CareLink two letter country code.") + .build()); + + //u - CareLink username + options.addOption( + Option.builder(OPTION_USERNAME) + .required(true) + .longOpt("username") + .hasArg(true) + .desc("CareLink username.") + .build()); + + //p - CareLink password + options.addOption( + Option.builder(OPTION_PASSWORD) + .required(true) + .longOpt("password") + .hasArg(true) + .desc("CareLink password.") + .build()); + + //o - Output folder + options.addOption( + Option.builder(OPTION_OUTPUT) + .required(false) + .longOpt("output") + .hasArg(true) + .desc("Output folder.") + .build()); + + //s - Session + options.addOption( + Option.builder(OPTION_SESSION) + .required(false) + .longOpt("session") + .hasArg(false) + .desc("Save session info.") + .build()); + + //d - Data + options.addOption( + Option.builder(OPTION_DATA) + .required(false) + .longOpt("data") + .hasArg(false) + .desc("Save recent data.") + .build()); + + //a - Anonymize data + options.addOption( + Option.builder(OPTION_ANONYM) + .required(false) + .longOpt("anonym") + .hasArg(false) + .desc("Anonymize data") + .build()); + + //r - Repeat times + options.addOption( + Option.builder(OPTION_REPEAT) + .required(false) + .longOpt("repeat") + .hasArg(true) + .desc("Repeat request times.") + .build()); + + //w - Wait minutes + options.addOption( + Option.builder(OPTION_WAIT) + .required(false) + .longOpt("wait") + .hasArg(true) + .desc("Wait minutes between repeated calls.") + .build()); + + return options; + + } + + + public static void main(String[] args) throws ParseException { + + + String folder; + int repeat; + int wait; + boolean downloadSession; + boolean downloadRecentData; + boolean verbose; + boolean anonymize; + + + Options options = generateOptions(); + + //print help if started wo params + if(args.length == 0) { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp("CareLinkClientCLI", options); + + //call client with params + }else { + try { + CommandLineParser parser = new DefaultParser(); + CommandLine cmd = parser.parse(options, args); + //Set params + verbose = (cmd.hasOption(OPTION_VERBOSE)) ? true : false; + downloadSession = (cmd.hasOption(OPTION_SESSION)) ? true : false; + downloadRecentData = (cmd.hasOption(OPTION_DATA)) ? true : false; + anonymize = (cmd.hasOption(OPTION_ANONYM)) ? true : false; + folder = (cmd.hasOption(OPTION_OUTPUT)) ? cmd.getOptionValue(OPTION_OUTPUT) : null; + repeat = (cmd.hasOption(OPTION_REPEAT)) ? Integer.parseInt(cmd.getOptionValue(OPTION_REPEAT)) : 1; + wait = (cmd.hasOption(OPTION_WAIT)) ? Integer.parseInt(cmd.getOptionValue(OPTION_WAIT)) : 1; + //Execute client + callCareLinkClient( + verbose, + cmd.getOptionValue(OPTION_USERNAME), cmd.getOptionValue(OPTION_PASSWORD), cmd.getOptionValue(OPTION_COUNTRY), + downloadSession, downloadRecentData, + anonymize, + folder, + repeat, wait); + } catch (MissingOptionException exMiss) { + System.out.println(exMiss.getMessage()); + System.out.println("Run without options to get usage info!"); + } catch (UnrecognizedOptionException exUnrec) { + System.out.println(exUnrec.getMessage()); + System.out.println("Run without options to get usage info!"); + } catch (Exception ex) { + System.out.println(ex.getMessage()); + } + } + + + } + + private static void callCareLinkClient(boolean verbose, String username, String password, String country, Boolean downloadSessionInfo, Boolean downloadData, boolean anonymize, String folder, int repeat, int wait){ + + CareLinkClient client = null; + + client = new CareLinkClient(username, password, country); + if(verbose)printLog("Client created!"); + + if(client.login()) { + + for(int i = 0; i < repeat; i++) { + if (verbose) printLog("Starting download, count: " + String.valueOf(i + 1)); + //Session info is requested + if (downloadSessionInfo) { + writeJson(client.getSessionUser(), folder, "user", anonymize, verbose); + writeJson(client.getSessionProfile(), folder, "profile", anonymize, verbose); + writeJson(client.getSessionCountrySettings(), folder, "country", anonymize, verbose); + writeJson(client.getSessionMonitorData(), folder, "monitor", anonymize, verbose); + } + //Recent data is requested + if(downloadData) { + try { + for(int j = 0; j < 2; j++) { + writeJson(client.getRecentData(), folder, "data", anonymize, verbose); + //writeResponse(client.getLastResponseBody(), folder, "dataresponse"); + if(client.getLastResponseCode() == 401) { + printLog("GetRecentData login error (response code 401). Trying again in 1 sec!"); + Thread.sleep(1000); + } + else { + break; + } + } + } catch (Exception ex) { + System.out.println(ex.getMessage()); + } + } + try { + if(i < repeat - 1) { + if (verbose) printLog("Waiting " + String.valueOf(wait) + " minutes before next download!"); + Thread.sleep(wait * 60000); + } + } catch (Exception ex){ } + } + } else { + printLog("Client login error! Response code: " + String.valueOf(client.getLastResponseCode()) + " Error message: " + client.getLastErrorMessage()); + } + + + } + + protected static void writeJson(Object object, String folder, String name, boolean anonymize, boolean verbose){ + + FileWriter writer = null; + SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd_HHmmss"); + String filename = name + "-" + sdfDate.format(Calendar.getInstance().getTime()) + ".json"; + + if(anonymize) + anonymizeData(object); + + try { + if(folder == null) + writer = new FileWriter(filename); + else + writer = new FileWriter(Paths.get(folder, filename).toAbsolutePath().toString()); + new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX").setPrettyPrinting().create().toJson(object, writer); + writer.flush(); + writer.close(); + if (verbose) printLog(name + " saved!"); + } catch (Exception ex) { + printLog("Error during save of " + name + " . Details: " + ex.getClass().getName() + " - " + ex.getMessage()); + } + + } + + + protected static void writeResponse(String response, String folder, String name){ + + FileWriter writer = null; + SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd_HHmmss"); + String filename = name + "-" + sdfDate.format(Calendar.getInstance().getTime()) + ".json"; + + try { + if(folder == null) + writer = new FileWriter(filename); + else + writer = new FileWriter(Paths.get(folder, filename).toAbsolutePath().toString()); + writer.write(response); + writer.flush(); + writer.close(); + } catch (Exception ex) { + printLog("Error during save of " + name + " . Details: " + ex.getClass().getName() + " - " + ex.getMessage()); + } + + } + + + protected static void anonymizeData(Object object){ + + User user; + Profile profile; + RecentData recentData; + + if(object != null){ + if(object instanceof User){ + user = (User) object; + user.accountId = 99999999; + user.id = String.valueOf(user.accountId); + user.lastName = "LastName"; + user.firstName = "FirstName"; + } else if(object instanceof Profile){ + profile = (Profile) object; + profile.address = "Address"; + profile.firstName = "FirstName"; + profile.lastName = "LastName"; + profile.middleName = "MiddleName"; + profile.dateOfBirth = "1900-01-01"; + profile.city = "City"; + profile.email = "email@email.email"; + profile.parentFirstName = "ParentFirstName"; + profile.parentLastName = "ParentLastName"; + profile.phone = "+00-00-000000"; + profile.phoneLegacy = "+00-00-000000"; + profile.postalCode = "9999"; + profile.patientNickname = "Nickname"; + profile.stateProvince = "State"; + profile.username = "Username"; + } else if(object instanceof RecentData){ + recentData = (RecentData) object; + recentData.firstName = "FirstName"; + recentData.lastName = "LastName"; + recentData.medicalDeviceSerialNumber = "SN9999999X"; + recentData.conduitSerialNumber = "XXXXXX-XXXX-XXXX-XXXX-9999-9999-9999-9999"; + } + } + + + } + + protected static void printLog(String logText){ + System.out.println(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Calendar.getInstance().getTime()) + " " + logText); + } + + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/client/CareLinkClient.java b/src/main/java/info/nightscout/medtronic/carelink/client/CareLinkClient.java new file mode 100644 index 0000000..ffa542c --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/client/CareLinkClient.java @@ -0,0 +1,553 @@ +package info.nightscout.medtronic.carelink.client; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import info.nightscout.medtronic.carelink.message.*; +import okhttp3.*; + +import java.io.IOException; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class CareLinkClient { + + protected static final String CARELINK_CONNECT_SERVER_EU = "carelink.minimed.eu"; + protected static final String CARELINK_CONNECT_SERVER_US = "carelink.minimed.com"; + protected static final String CARELINK_LANGUAGE_EN = "en"; + protected static final String CARELINK_LOCALE_EN = "en"; + protected static final String CARELINK_AUTH_TOKEN_COOKIE_NAME = "auth_tmp_token"; + protected static final String CARELINK_TOKEN_VALIDTO_COOKIE_NAME = "c_token_valid_to"; + protected static final int AUTH_EXPIRE_DEADLINE_MINUTES = 1; + + //Authentication data + protected String carelinkUsername; + protected String carelinkPassword; + protected String carelinkCountry; + + //Session info + protected boolean loggedIn; + public boolean isLoggedIn(){ + return loggedIn; + } + protected User sessionUser; + public User getSessionUser() { + return getClone(sessionUser, User.class); + } + protected Profile sessionProfile; + public Profile getSessionProfile() { + return getClone(sessionProfile, Profile.class); + } + protected CountrySettings sessionCountrySettings; + public CountrySettings getSessionCountrySettings() { + return getClone(sessionCountrySettings, CountrySettings.class); + } + protected MonitorData sessionMonitorData; + public MonitorData getSessionMonitorData() { + return getClone(sessionMonitorData, MonitorData.class); + } + + protected T getClone(Object origObject, Class origClass){ + + Object clone = null; + + try{ + clone = new GsonBuilder().create().fromJson(new GsonBuilder().create().toJson(origObject), origClass); + }catch (Exception ex){ } + + return clone == null ? null : origClass.cast(clone); + + } + + //Communication info + protected OkHttpClient httpClient = null; + protected boolean loginInProcess = false; + protected String lastResponseBody; + protected void setLastResponseBody(Response response){ + try{ + this.lastResponseBody = response.body().string(); + } catch (Exception ex){} + } + protected void setLastResponseBody(String responseBody){ + this.lastResponseBody = responseBody; + } + public String getLastResponseBody(){ + return lastResponseBody; + } + protected int lastResponseCode; + public int getLastResponseCode() { + return lastResponseCode; + } + protected boolean lastLoginSuccess; + public boolean getLastLoginSuccess() { + return lastLoginSuccess; + } + protected boolean lastDataSuccess; + public boolean getLastDataSuccess() { + return lastDataSuccess; + } + protected String lastErrorMessage; + public String getLastErrorMessage() { + return lastErrorMessage; + } + protected String lastStackTraceString; + public String getLastStackTraceString() { + return lastStackTraceString; + } + + protected enum RequestType { + HtmlGet(), HtmlPost(), Json() + } + + + public CareLinkClient(String carelinkUsername, String carelinkPassword, String carelinkCountry) { + + this.carelinkUsername = carelinkUsername; + this.carelinkPassword = carelinkPassword; + this.carelinkCountry = carelinkCountry; + + // Create main http client with CookieJar + this.httpClient = new OkHttpClient.Builder() + .cookieJar(new SimpleOkHttpCookieJar()) + .connectionPool(new ConnectionPool(5, 10, TimeUnit.MINUTES)) + .build(); + } + + /* + * WRAPPER DATA RETRIEVAL METHODS + */ + public RecentData getRecentData() { + + // Force login to get basic info + if(getAuthorizationToken() != null) { + if (CountryUtils.isUS(carelinkCountry) || sessionMonitorData.isBleX()) + return this.getConnectDisplayMessage(this.sessionProfile.username, this.sessionUser.getUserRole(), + sessionCountrySettings.blePereodicDataEndpoint); + else + return this.getLast24Hours(); + } + else { + return null; + } + + + } + + // Get server URL + protected String careLinkServer() { + return this.carelinkCountry.equals("us") ? CARELINK_CONNECT_SERVER_US : CARELINK_CONNECT_SERVER_EU; + } + + + // Authentication methods + public boolean login(){ + if(!this.loggedIn) + this.executeLoginProcedure(); + return this.loggedIn; + } + + protected boolean executeLoginProcedure() { + + Response loginSessionResponse = null; + Response doLoginResponse = null; + Response consentResponse = null; + + lastLoginSuccess = false; + loginInProcess = true; + + try { + // Clear cookies + ((SimpleOkHttpCookieJar) this.httpClient.cookieJar()).deleteAllCookies(); + + // Clear basic infos + this.sessionUser = null; + this.sessionProfile = null; + this.sessionCountrySettings = null; + this.sessionMonitorData = null; + + // Open login (get SessionId and SessionData) + loginSessionResponse = this.getLoginSession(); + this.lastResponseCode = loginSessionResponse.code(); + + // Login + doLoginResponse = this.doLogin(loginSessionResponse); + this.lastResponseCode = doLoginResponse.code(); + setLastResponseBody(loginSessionResponse); + loginSessionResponse.close(); + + // Consent + consentResponse = this.doConsent(doLoginResponse); + setLastResponseBody(doLoginResponse); + doLoginResponse.close(); + this.lastResponseCode = consentResponse.code(); + setLastResponseBody(consentResponse); + consentResponse.close(); + + // Get sessions infos if required + if(this.sessionUser == null) + this.sessionUser = this.getMyUser(); + if(this.sessionProfile == null) + this.sessionProfile = this.getMyProfile(); + if(this.sessionCountrySettings == null) + this.sessionCountrySettings = this.getCountrySettings(this.carelinkCountry, CARELINK_LANGUAGE_EN); + if(this.sessionMonitorData == null) + this.sessionMonitorData = this.getMonitorData(); + // Set login success if everything was ok: + if(this.sessionUser != null && this.sessionProfile != null && this.sessionCountrySettings != null && this.sessionMonitorData != null) + lastLoginSuccess = true; + + } catch (Exception e) { + lastErrorMessage = e.getMessage(); + // lastStackTraceString = Log.getStackTraceString(e); + } + + loginInProcess = false; + loggedIn = lastLoginSuccess; + + return lastLoginSuccess; + + } + + protected Response getLoginSession() throws IOException { + + HttpUrl url = null; + Request.Builder requestBuilder = null; + + url = new HttpUrl.Builder().scheme("https").host(this.careLinkServer()).addPathSegments("patient/sso/login") + .addQueryParameter("country", this.carelinkCountry).addQueryParameter("lang", CARELINK_LANGUAGE_EN) + .build(); + + requestBuilder = new Request.Builder().url(url); + + this.addHttpHeaders(requestBuilder, RequestType.HtmlGet); + + return this.httpClient.newCall(requestBuilder.build()).execute(); + + } + + protected Response doLogin(Response loginSessionResponse) throws IOException { + + HttpUrl url = null; + Request.Builder requestBuilder = null; + RequestBody form = null; + + form = new FormBody.Builder() + .add("sessionID", loginSessionResponse.request().url().queryParameter("sessionID")) + .add("sessionData", loginSessionResponse.request().url().queryParameter("sessionData")) + .add("locale", CARELINK_LOCALE_EN) + .add("action", "login") + .add("username", this.carelinkUsername) + .add("password", this.carelinkPassword) + .add("actionButton", "Log in") + .build(); + + url = new HttpUrl.Builder().scheme("https").host("mdtlogin.medtronic.com") + .addPathSegments("mmcl/auth/oauth/v2/authorize/login").addQueryParameter("locale", CARELINK_LOCALE_EN) + .addQueryParameter("country", this.carelinkCountry).build(); + + requestBuilder = new Request.Builder().url(url).post(form); + + this.addHttpHeaders(requestBuilder, RequestType.HtmlGet); + + return this.httpClient.newCall(requestBuilder.build()).execute(); + + } + + protected Response doConsent(Response doLoginResponse) throws IOException { + + Request.Builder requestBuilder = null; + RequestBody form = null; + String doLoginRespBody = null; + + doLoginRespBody = doLoginResponse.body().string(); + + // Extract data for consent + String consentUrl = this.extractResponseData(doLoginRespBody, "(form action=\")(.*)(\" method=\"POST\")", 2); + String consentSessionData = this.extractResponseData(doLoginRespBody, + "()", 2); + String consentSessionId = this.extractResponseData(doLoginRespBody, + "()", 2); + + // Send consent + form = new FormBody.Builder().add("action", "consent").add("sessionID", consentSessionId) + .add("sessionData", consentSessionData).add("response_type", "code").add("response_mode", "query") + .build(); + + requestBuilder = new Request.Builder().url(consentUrl).post(form); + + this.addHttpHeaders(requestBuilder, RequestType.HtmlPost); + + return this.httpClient.newCall(requestBuilder.build()).execute(); + + } + + protected String getAuthorizationToken() { + + // New token is needed: + // a) no token or about to expire => execute authentication + // b) last response 401 + if (!((SimpleOkHttpCookieJar) httpClient.cookieJar()).contains(CARELINK_AUTH_TOKEN_COOKIE_NAME) + || !((SimpleOkHttpCookieJar) httpClient.cookieJar()).contains(CARELINK_TOKEN_VALIDTO_COOKIE_NAME) + || !((new Date(Date.parse(((SimpleOkHttpCookieJar) httpClient.cookieJar()) + .getCookies(CARELINK_TOKEN_VALIDTO_COOKIE_NAME).get(0).value()))) + .after(new Date(new Date(System.currentTimeMillis()).getTime() + + AUTH_EXPIRE_DEADLINE_MINUTES * 60000))) + || this.lastResponseCode == 401 + ) { + //execute new login process | null, if error OR already doing login + if(this.loginInProcess || !this.executeLoginProcedure()) + return null; + + } + + // there can be only one + return "Bearer" + " " + ((SimpleOkHttpCookieJar) httpClient.cookieJar()).getCookies(CARELINK_AUTH_TOKEN_COOKIE_NAME).get(0).value(); + + } + + /* + * CareLink APIs + */ + + // My user + public User getMyUser() { + return this.getData(this.careLinkServer(), "patient/users/me", null, null, User.class); + } + + // My profile + public Profile getMyProfile() { + return this.getData(this.careLinkServer(), "patient/users/me/profile", null, null, Profile.class); + } + + // Monitoring data + public MonitorData getMonitorData() { + return this.getData(this.careLinkServer(), "patient/monitor/data", null, null, MonitorData.class); + } + + // Country settings + public CountrySettings getCountrySettings(String country, String language) { + + Map queryParams = null; + + queryParams = new HashMap(); + queryParams.put("countryCode", country); + queryParams.put("language", language); + + return this.getData(this.careLinkServer(), "patient/countries/settings", queryParams, null, + CountrySettings.class); + + } + + // Old last24hours webapp data + public RecentData getLast24Hours() { //Last24Hour getLast24Hours() { + + Map queryParams = null; + + queryParams = new HashMap(); + queryParams.put("cpSerialNumber", "NONE"); + queryParams.put("msgType", "last24hours"); + queryParams.put("requestTime", String.valueOf(System.currentTimeMillis())); + + return this.getData(this.careLinkServer(), "patient/connect/data", queryParams, null, RecentData.class); + + } + + // Periodic data from CareLink Cloud + public RecentData getConnectDisplayMessage(String username, String role, String endpointUrl) { + + RequestBody requestBody = null; + Gson gson = null; + JsonObject userJson = null; + + // Build user json for request + userJson = new JsonObject(); + userJson.addProperty("username", username); + userJson.addProperty("role", role); + + gson = new GsonBuilder().create(); + + requestBody = RequestBody.create(gson.toJson(userJson), MediaType.get("application/json; charset=utf-8")); + + RecentData recentData = this.getData(HttpUrl.parse(endpointUrl), requestBody, RecentData.class); + if (recentData != null) + correctTimeInRecentData(recentData); + return recentData; + + } + + + // Helper methods + // Response parsing + protected String extractResponseData(String respBody, String groupRegex, int groupIndex) { + + String responseData = null; + + Matcher responseDataMatcher = Pattern.compile(groupRegex).matcher(respBody); + if (responseDataMatcher.find()) + responseData = responseDataMatcher.group(groupIndex); + + return responseData; + + } + + // Http header builder for requests + protected void addHttpHeaders(Request.Builder requestBuilder, RequestType type) { + + //Add common browser headers + requestBuilder.addHeader("Accept-Language", "en;q=0.9, *;q=0.8").addHeader("Connection", "keep-alive") + .addHeader("sec-ch-ua", "\"Google Chrome\";v=\"87\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"87\"") + .addHeader("User-Agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36") + //.addHeader("Connection", "keep-alive"); + ; + + //Set media type based on request type + switch (type) { + case Json: + requestBuilder.addHeader("Accept", "application/json, text/plain, */*"); + requestBuilder.addHeader("Content-Type", "application/json; charset=utf-8"); + break; + case HtmlGet: + requestBuilder.addHeader("Accept", + "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"); + break; + case HtmlPost: + requestBuilder.addHeader("Accept", + "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"); + requestBuilder.addHeader("Content-Type", "application/x-www-form-urlencoded"); + break; + } + + } + + // Data request for API calls + protected T getData(HttpUrl url, RequestBody requestBody, Class dataClass) { + + Object data = null; + + this.lastDataSuccess = false; + + // Get auth token + String authToken = this.getAuthorizationToken(); + + if (authToken != null) { + + // Create request for URL with authToken + Request.Builder requestBuilder = new Request.Builder().url(url).addHeader("Authorization", authToken); + + // Add header + if (requestBody == null) { + this.addHttpHeaders(requestBuilder, RequestType.Json); + } else { + requestBuilder.post(requestBody); + this.addHttpHeaders(requestBuilder, RequestType.HtmlPost); + } + + String responseBody = null; + + // Send request + try { + Response response = this.httpClient.newCall(requestBuilder.build()).execute(); + this.lastResponseCode = response.code(); + if (response.isSuccessful()) { + responseBody = response.body().string(); + setLastResponseBody(responseBody); + data = new GsonBuilder().create().fromJson(responseBody, dataClass); + this.lastDataSuccess = true; + } + response.close(); + } catch (Exception e) { + lastErrorMessage = e.getMessage(); + } + + } + + //Return result + if(data != null) + return dataClass.cast(data); + else + return null; + + } + + protected T getData(String host, String path, Map queryParams, RequestBody requestBody, + Class dataClass) { + + HttpUrl.Builder urlBuilder = null; + HttpUrl url = null; + + // Build url + urlBuilder = new HttpUrl.Builder().scheme("https").host(host).addPathSegments(path); + if (queryParams != null) { + for (Map.Entry param : queryParams.entrySet()) { + urlBuilder.addQueryParameter(param.getKey(), param.getValue()); + } + } + + url = urlBuilder.build(); + + return this.getData(url, requestBody, dataClass); + + } + + protected void correctTimeInRecentData(RecentData recentData){ + + if(recentData.sMedicalDeviceTime != null && recentData.lastMedicalDeviceDataUpdateServerTime > 1) { + + //Calc time diff between event time and actual local time (timezone is wrong in CareLink data) + int diffInHour = (int) Math.round(((recentData.lastMedicalDeviceDataUpdateServerTime - recentData.sMedicalDeviceTime.getTime()) / 3600000D)); + + //Correct times if server <> device time differs in hours + if (diffInHour != 0 && diffInHour < 26) { + + + recentData.medicalDeviceTimeAsString = shiftDateByHours(recentData.medicalDeviceTimeAsString, diffInHour); + recentData.sMedicalDeviceTime = shiftDateByHours(recentData.sMedicalDeviceTime, diffInHour); + recentData.lastConduitDateTime = shiftDateByHours(recentData.lastConduitDateTime, diffInHour); + recentData.lastSensorTSAsString = shiftDateByHours(recentData.lastSensorTSAsString, diffInHour); + recentData.sLastSensorTime = shiftDateByHours(recentData.sLastSensorTime, diffInHour); + //Sensor + if(recentData.sgs != null){ + for (SensorGlucose sg : recentData.sgs) { + sg.datetime = shiftDateByHours(sg.datetime, diffInHour); + } + } + //Markers + if(recentData.markers != null){ + for (Marker marker : recentData.markers) { + marker.dateTime = shiftDateByHours(marker.dateTime, diffInHour); + } + } + //Notifications + if(recentData.notificationHistory != null){ + if(recentData.notificationHistory.clearedNotifications != null) { + for (ClearedNotification notification : recentData.notificationHistory.clearedNotifications) { + notification.dateTime = shiftDateByHours(notification.dateTime, diffInHour); + notification.triggeredDateTime= shiftDateByHours(notification.triggeredDateTime, diffInHour); + } + } + if(recentData.notificationHistory.activeNotifications != null) { + for(ActiveNotification notification : recentData.notificationHistory.activeNotifications) { + notification.dateTime = shiftDateByHours(notification.dateTime, diffInHour); + } + } + } + } + } + + } + + protected Date shiftDateByHours(Date date, int hours){ + if(date != null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.HOUR_OF_DAY, hours); + return calendar.getTime(); + } else { + return null; + } + } + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/client/CountryUtils.java b/src/main/java/info/nightscout/medtronic/carelink/client/CountryUtils.java new file mode 100644 index 0000000..f49cd5c --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/client/CountryUtils.java @@ -0,0 +1,136 @@ +package info.nightscout.medtronic.carelink.client; + +import java.util.Arrays; + +public class CountryUtils { + + public static final String[] supportedCountryCodes = { + "dz", + "ba", + "eg", + "za", + "ca", + "cr", + "mx", + "ma", + "pa", + "pr", + "us", + "ar", + "br", + "cl", + "co", + "ve", + "hk", + "in", + "id", + "il", + "jp", + "kw", + "lb", + "my", + "ph", + "qa", + "sa", + "sg", + "kr", + "tw", + "th", + "tn", + "tr", + "ae", + "vn", + "at", + "be", + "bg", + "hr", + "cz", + "dk", + "ee", + "fi", + "fr", + "de", + "gr", + "hu", + "is", + "ie", + "it", + "lv", + "lt", + "lu", + "nl", + "no", + "pl", + "pt", + "ro", + "ru", + "rs", + "sk", + "si", + "es", + "se", + "ch", + "ua", + "gb", + "au", + "nz", + "bh", + "om", + "cn", + "cy", + "al", + "am", + "az", + "bs", + "bb", + "by", + "bm", + "bo", + "kh", + "do", + "ec", + "sv", + "ge", + "gt", + "hn", + "ir", + "iq", + "jo", + "xk", + "ly", + "mo", + "mk", + "mv", + "mt", + "mu", + "yt", + "md", + "me", + "na", + "nc", + "ni", + "ng", + "pk", + "py", + "mf", + "sd", + "uy", + "aw", + "ky", + "cw", + "pe" + }; + + public static boolean isSupportedCountry(String countryCode){ + return Arrays.asList(supportedCountryCodes).contains(countryCode); + } + + public static boolean isUS(String countryCode){ + return countryCode.equals("us"); + } + + public static boolean isOutsideUS(String countryCode){ + return !isUS(countryCode); + } + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/client/SimpleOkHttpCookieJar.java b/src/main/java/info/nightscout/medtronic/carelink/client/SimpleOkHttpCookieJar.java new file mode 100644 index 0000000..c02f140 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/client/SimpleOkHttpCookieJar.java @@ -0,0 +1,79 @@ +package info.nightscout.medtronic.carelink.client; + +import okhttp3.Cookie; +import okhttp3.CookieJar; +import okhttp3.HttpUrl; + +import java.util.ArrayList; +import java.util.List; + +public class SimpleOkHttpCookieJar implements CookieJar { + + private List storage = new ArrayList<>(); + + @Override + public void saveFromResponse(HttpUrl url, List cookies) { + storage.addAll(cookies); + } + + @Override + public List loadForRequest(HttpUrl url) { + + List cookies = new ArrayList<>(); + + // Remove expired Cookies + removeExpiredCookies(); + + // Only return matching Cookies + for (int i = 0; i < storage.size(); i++) { + if(storage.get(i).matches(url)) { + cookies.add(storage.get(i)); + } + } + + return cookies; + } + + public List getCookies(String name) { + + List cookies = new ArrayList<>(); + + // Remove expired Cookies + removeExpiredCookies(); + + // Only return matching Cookies + for (int i = 0; i < storage.size(); i++) { + if(storage.get(i).name().equals(name)) { + cookies.add(storage.get(i)); + } + } + + return cookies; + + } + + public boolean contains(String name) { + return (getCookies(name).size() > 0); + } + + public void deleteCookie(String name) { + for (int i = 0; i < storage.size(); i++) { + if(storage.get(i).name() == name) { + storage.remove(i); + } + } + } + + public void deleteAllCookies() { + storage.clear(); + } + + private void removeExpiredCookies(){ + for (int i = 0; i < storage.size(); i++) { + if(storage.get(i).expiresAt() < System.currentTimeMillis()) { + storage.remove(i); + } + } + } + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/ActiveInsulin.java b/src/main/java/info/nightscout/medtronic/carelink/message/ActiveInsulin.java new file mode 100644 index 0000000..a6ab632 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/ActiveInsulin.java @@ -0,0 +1,14 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; + +public class ActiveInsulin { + + public Integer code; + public Date datetime; + public int version; + public Double amount; + public String precision; + public String kind; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/ActiveNotification.java b/src/main/java/info/nightscout/medtronic/carelink/message/ActiveNotification.java new file mode 100644 index 0000000..7b460df --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/ActiveNotification.java @@ -0,0 +1,18 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; + +public class ActiveNotification { + + public String GUID; + public Date dateTime; + public String type; + public int faultId; + public int instanceId; + public String messageId; + public String pumpDeliverySuspendState; + public String pnpId; + public int relativeOffset; + public Boolean alertSilenced; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Alarm.java b/src/main/java/info/nightscout/medtronic/carelink/message/Alarm.java new file mode 100644 index 0000000..e754db8 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Alarm.java @@ -0,0 +1,19 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; + +public class Alarm { + + public int code; + public Date datetime; + public String type; + public boolean flash; + public String kind; + public long version; + public Integer instanceId; + public String messageId; + public Integer sg; + public Boolean pumpDeliverySuspendState; + public String referenceGUID; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Basal.java b/src/main/java/info/nightscout/medtronic/carelink/message/Basal.java new file mode 100644 index 0000000..081303b --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Basal.java @@ -0,0 +1,8 @@ +package info.nightscout.medtronic.carelink.message; + +public class Basal { + + public String activeBasalPattern; + public Double basalRate; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/ClearedNotification.java b/src/main/java/info/nightscout/medtronic/carelink/message/ClearedNotification.java new file mode 100644 index 0000000..6c779f5 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/ClearedNotification.java @@ -0,0 +1,20 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; + +public class ClearedNotification { + + public String GUID; + public String referenceGUID; + public Date dateTime; + public String type; + public int faultId; + public int instanceId; + public String messageId; + public String pumpDeliverySuspendState; + public String pnpId; + public int relativeOffset; + public Date triggeredDateTime; + public Boolean alertSilenced; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Countries.java b/src/main/java/info/nightscout/medtronic/carelink/message/Countries.java new file mode 100644 index 0000000..c957c5a --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Countries.java @@ -0,0 +1,9 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.List; + +public class Countries { + + public List countries; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Country.java b/src/main/java/info/nightscout/medtronic/carelink/message/Country.java new file mode 100644 index 0000000..c25aac8 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Country.java @@ -0,0 +1,10 @@ +package info.nightscout.medtronic.carelink.message; + +public class Country { + + public String countryCode; + public String countryName; + public String dialCode; + public String defaultCountryName; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/CountrySettings.java b/src/main/java/info/nightscout/medtronic/carelink/message/CountrySettings.java new file mode 100644 index 0000000..8ed61e6 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/CountrySettings.java @@ -0,0 +1,47 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.List; + +public class CountrySettings { + + public String name; + public List languages; + public String defaultLanguage; + public String defaultCountryName; + public String defaultDevice; + public String dialCode; + public boolean cpMobileAppAvailable; + public boolean uploaderAllowed; + public String techSupport; + public String techDays; + public String firstDayOfWeek; + public String techHours; + public Integer legalAge; + public String shortDateFormat; + public String shortTimeFormat; + public String mediaHost; + public String blePereodicDataEndpoint; + public String region; + //"pathDocs":{ + //"ddms.privacyStatementPdf":"https://carelink.minimed.eu/crs/ocl/14.02/media/hu/privacy_statement.pdf", + //"ddms.termsOfUsePdf":"https://carelink.minimed.eu/crs/ocl/14.02/media/hu/terms_of_use.pdf", + //"ddms.faqPdf":"https://carelink.minimed.eu/crs/ocl/14.02/media/hu/EMEA/BLE/faq.pdf", + //"ddms.analyticsToolNoticePdf":"https://carelink.minimed.eu/crs/ocl/14.02/media/hu/EMEA/analytics_tool_notice.pdf", + //"ddms.smsNoticePdf":"https://carelink.minimed.eu/crs/ocl/14.02/media/hu/sms_text_notice.pdf", + //"ddms.cookieNoticePdf":"https://carelink.minimed.eu/crs/ocl/14.02/media/hu/cookie_notice.pdf"}, + public String carbDefaultUnit; + public String bgUnits; + public String timeFormat; + public String timeUnitsDefault; + public String recordSeparator; + public String glucoseUnitsDefault; + public String carbohydrateUnitsDefault; + public Long carbExchangeRatioDefault; + public ReportDateFormat reportDateFormat; + public MfaRules mfa; + public List supportedReports; + public boolean smsSendingAllowed; + public PostalInfo postal; + public NumberFormat numberFormat; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/DataUpload.java b/src/main/java/info/nightscout/medtronic/carelink/message/DataUpload.java new file mode 100644 index 0000000..69a8177 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/DataUpload.java @@ -0,0 +1,10 @@ +package info.nightscout.medtronic.carelink.message; + +public class DataUpload { + + public long date; + public boolean mobileUploaded; + public String device; + public String serialNumber; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Language.java b/src/main/java/info/nightscout/medtronic/carelink/message/Language.java new file mode 100644 index 0000000..be269b2 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Language.java @@ -0,0 +1,8 @@ +package info.nightscout.medtronic.carelink.message; + +public class Language { + + public String name; + public String code; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Languages.java b/src/main/java/info/nightscout/medtronic/carelink/message/Languages.java new file mode 100644 index 0000000..4dde34c --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Languages.java @@ -0,0 +1,9 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.List; + +public class Languages { + + public List languages; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Limit.java b/src/main/java/info/nightscout/medtronic/carelink/message/Limit.java new file mode 100644 index 0000000..1ee412f --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Limit.java @@ -0,0 +1,11 @@ +package info.nightscout.medtronic.carelink.message; + +public class Limit { + + public int index; + public int highLimit; + public int lowLimit; + public String kind; + public int version; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Marker.java b/src/main/java/info/nightscout/medtronic/carelink/message/Marker.java new file mode 100644 index 0000000..76ad267 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Marker.java @@ -0,0 +1,36 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; + +public class Marker { + + public static final String MARKER_TYPE_MEAL = "MEAL"; + public static final String MARKER_TYPE_CALIBRATION = "CALIBRATION"; + public static final String MARKER_TYPE_BG_READING = "BG_READING"; + public static final String MARKER_TYPE_INSULIN = "INSULIN"; + public static final String MARKER_TYPE_AUTO_BASAL = "AUTO_BASAL_DELIVERY"; + public static final String MARKER_TYPE_AUTO_MODE_STATUS = "AUTO_MODE_STATUS"; + + + public String type; + public int index; + public Integer value; + public String kind; + public int version; + public Date dateTime; + public Integer relativeOffset; + public Boolean calibrationSuccess; + public Integer amount; + public Float programmedExtendedAmount; + public String activationType; + public Float deliveredExtendedAmount; + public Float programmedFastAmount; + public Integer programmedDuration; + public Float deliveredFastAmount; + public Integer effectiveDuration; + public Boolean completed; + public String bolusType; + public Boolean autoModeOn; + public Float bolusAmount; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/MfaRules.java b/src/main/java/info/nightscout/medtronic/carelink/message/MfaRules.java new file mode 100644 index 0000000..64c8286 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/MfaRules.java @@ -0,0 +1,14 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; + +public class MfaRules { + + public String status; + public String fromDate; + public int gracePeriod; + public int codeValidityDuration; + public int maxAttempts; + public int rememberPeriod; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/MonitorData.java b/src/main/java/info/nightscout/medtronic/carelink/message/MonitorData.java new file mode 100644 index 0000000..08c6726 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/MonitorData.java @@ -0,0 +1,11 @@ +package info.nightscout.medtronic.carelink.message; + +public class MonitorData { + + public String deviceFamily; + + public boolean isBleX() { + return deviceFamily.contains("BLE_X"); + } + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/NotificationHistory.java b/src/main/java/info/nightscout/medtronic/carelink/message/NotificationHistory.java new file mode 100644 index 0000000..8d218a0 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/NotificationHistory.java @@ -0,0 +1,10 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.List; + +public class NotificationHistory { + + public List activeNotifications; + public List clearedNotifications; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/NumberFormat.java b/src/main/java/info/nightscout/medtronic/carelink/message/NumberFormat.java new file mode 100644 index 0000000..d6f99f1 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/NumberFormat.java @@ -0,0 +1,8 @@ +package info.nightscout.medtronic.carelink.message; + +public class NumberFormat { + + public String decimalSeparator; + public String groupsSeparator; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/PostalInfo.java b/src/main/java/info/nightscout/medtronic/carelink/message/PostalInfo.java new file mode 100644 index 0000000..601dabe --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/PostalInfo.java @@ -0,0 +1,8 @@ +package info.nightscout.medtronic.carelink.message; + +public class PostalInfo { + + public String[] postalFormat; + public String regExpStr; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/Profile.java b/src/main/java/info/nightscout/medtronic/carelink/message/Profile.java new file mode 100644 index 0000000..97ebbb5 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/Profile.java @@ -0,0 +1,31 @@ +package info.nightscout.medtronic.carelink.message; + +public class Profile { + + public String username; + public String firstName; + public String middleName; + public String lastName; + public boolean guardianParent; + public String parentFirstName; + public String parentMiddleName; + public String parentLastName; + public String address; + public String city; + public String stateProvince; + public String postalCode; + public String country; + public String dateOfBirth; + public String phone; + public String phoneLegacy; + public String email; + public String gender; + public String diabetesType; + public String therapyType; + public String ageRange; + public String insulinType; + public String patientNickname; + public String textNotification; + public String a1C; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/PumpBannerState.java b/src/main/java/info/nightscout/medtronic/carelink/message/PumpBannerState.java new file mode 100644 index 0000000..95593e1 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/PumpBannerState.java @@ -0,0 +1,22 @@ +package info.nightscout.medtronic.carelink.message; + +public class PumpBannerState { + + public static final String STATE_DUAL_BOLUS = "DUAL_BOLUS"; + public static final String STATE_SQUARE_BOLUS = "SQUARE_BOLUS"; + public static final String STATE_LOAD_RESERVOIR = "LOAD_RESERVOIR"; + public static final String STATE_SUSPENDED_ON_LOW = "SUSPENDED_ON_LOW"; + public static final String STATE_SUSPENDED_BEFORE_LOW = "SUSPENDED_BEFORE_LOW"; + public static final String STATE_DELIVERY_SUSPEND = "DELIVERY_SUSPEND"; + public static final String STATE_BG_REQUIRED = "BG_REQUIRED"; + public static final String STATE_PROCESSING_BG = "PROCESSING_BG"; + public static final String STATE_WAIT_TO_ENTER_BG = "WAIT_TO_ENTER_BG"; + public static final String STATE_TEMP_TARGET = "TEMP_TARGET"; + public static final String STATE_TEMP_BASAL = "TEMP_BASAL"; + public static final String STATE_NO_DELIVERY = "NO_DELIVERY"; + public static final String STATE_CALIBRATION_REQUIRED = "CALIBRATION_REQUIRED"; + + public String type; + public int timeRemaining; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/RecentData.java b/src/main/java/info/nightscout/medtronic/carelink/message/RecentData.java new file mode 100644 index 0000000..f575d70 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/RecentData.java @@ -0,0 +1,110 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; +import java.util.List; + +public class RecentData { + + public static final String DEVICE_FAMILY_GUARDIAN = "GUARDIAN"; + public static final String DEVICE_FAMILY_NGP = "NGP"; + + //sensorState + public static final String SENSOR_STATE_CALIBRATION_REQUIRED = "CALIBRATION_REQUIRED"; + public static final String SENSOR_STATE_NO_DATA_FROM_PUMP = "NO_DATA_FROM_PUMP"; + public static final String SENSOR_STATE_WAIT_TO_CALIBRATE = "WAIT_TO_CALIBRATE"; + public static final String SENSOR_STATE_DO_NOT_CALIBRATE = "DO_NOT_CALIBRATE"; + public static final String SENSOR_STATE_CALIBRATING = "CALIBRATING"; + public static final String SENSOR_STATE_NO_ERROR_MESSAGE = "NO_ERROR_MESSAGE"; + public static final String SENSOR_STATE_WARM_UP = "WARM_UP"; + public static final String SENSOR_STATE_CHANGE_SENSOR = "CHANGE_SENSOR"; + public static final String SENSOR_STATE_NORMAL = "NORMAL"; + public static final String SENSOR_STATE_UNKNOWN = "UNKNOWN"; + + //systemStatusMessage + public static final String SYSTEM_STATUS_BLUETOOTH_OFF = "BLUETOOTH_OFF"; + public static final String SYSTEM_STATUS_UPDATING = "UPDATING"; + public static final String SYSTEM_STATUS_RECONNECTING_TO_PUMP = "RECONNECTING_TO_PUMP"; + public static final String SYSTEM_STATUS_PUMP_PAIRING_LOST = "PUMP_PAIRING_LOST"; + public static final String SYSTEM_STATUS_LOST_PUMP_SIGNAL = "LOST_PUMP_SIGNAL"; + public static final String SYSTEM_STATUS_PUMP_NOT_PAIRED = "PUMP_NOT_PAIRED"; + public static final String SYSTEM_STATUS_SENSOR_OFF = "SENSOR_OFF"; + public static final String SYSTEM_STATUS_NO_ERROR_MESSAGE = "NO_ERROR_MESSAGE"; + public static final String SYSTEM_STATUS_CALIBRATION_REQUIRED = "CALIBRATION_REQUIRED"; + + + public String getDeviceFamily(){ + return medicalDeviceFamily; + } + public boolean isGM(){ + return getDeviceFamily().equals(DEVICE_FAMILY_GUARDIAN); + } + public boolean isNGP(){ + return getDeviceFamily().equals(DEVICE_FAMILY_NGP); + } + + public long lastSensorTS; + public Date medicalDeviceTimeAsString; + public Date lastSensorTSAsString; + public String kind; + public int version; + public String pumpModelNumber; + public long currentServerTime; + public long lastConduitTime; + public long lastConduitUpdateServerTime; + public long lastMedicalDeviceDataUpdateServerTime; + public String firstName; + public String lastName; + public String conduitSerialNumber; + public int conduitBatteryLevel; + public String conduitBatteryStatus; + public Boolean conduitInRange; + public Boolean conduitMedicalDeviceInRange; + public Boolean conduitSensorInRange; + public String medicalDeviceFamily; + public String sensorState; + public String medicalDeviceSerialNumber; + public long medicalDeviceTime; + public Date sMedicalDeviceTime; + public int reservoirLevelPercent; + public int reservoirAmount; + public float reservoirRemainingUnits; + public int medicalDeviceBatteryLevelPercent; + public int sensorDurationHours; + public int timeToNextCalibHours; + public String calibStatus; + public String bgUnits; + public String timeFormat; + public long lastSensorTime; + public Date sLastSensorTime; + public boolean medicalDeviceSuspended; + public String lastSGTrend; + public SensorGlucose lastSG; + public Alarm lastAlarm; + public ActiveInsulin activeInsulin; + public List sgs; + public List limits; + public List markers; + public NotificationHistory notificationHistory; + public TherapyAlgorithmState therapyAlgorithmState; + public List pumpBannerState; + public Basal basal; + public String systemStatusMessage; + public int averageSG; + public int belowHypoLimit; + public int aboveHyperLimit; + public int timeInRange; + public Boolean pumpCommunicationState; + public Boolean gstCommunicationState; + public int gstBatteryLevel; + public Date lastConduitDateTime; + public float maxAutoBasalRate; + public float maxBolusAmount; + public int sensorDurationMinutes; + public int timeToNextCalibrationMinutes; + public String clientTimeZoneName; + public int sgBelowLimit; + public float averageSGFloat; + public Boolean calFreeSensor; + public Boolean finalCalibration; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/RecentUploads.java b/src/main/java/info/nightscout/medtronic/carelink/message/RecentUploads.java new file mode 100644 index 0000000..eccc535 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/RecentUploads.java @@ -0,0 +1,9 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.List; + +public class RecentUploads { + + public List recentUploads; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/ReportDataProvider.java b/src/main/java/info/nightscout/medtronic/carelink/message/ReportDataProvider.java new file mode 100644 index 0000000..a496cbf --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/ReportDataProvider.java @@ -0,0 +1,10 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.List; + +public class ReportDataProvider { + + public String category; + public List segments; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/ReportDateFormat.java b/src/main/java/info/nightscout/medtronic/carelink/message/ReportDateFormat.java new file mode 100644 index 0000000..d06a6ce --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/ReportDateFormat.java @@ -0,0 +1,13 @@ +package info.nightscout.medtronic.carelink.message; + +public class ReportDateFormat { + + public String longTimePattern12; + public String longTimePattern24; + public String shortTimePattern12; + public String shortTimePattern24; + public String shortDatePattern; + public String dateSeparator; + public String timeSeparator; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/ReportSnapshotTimelinesForCalendar.java b/src/main/java/info/nightscout/medtronic/carelink/message/ReportSnapshotTimelinesForCalendar.java new file mode 100644 index 0000000..7d6c7ed --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/ReportSnapshotTimelinesForCalendar.java @@ -0,0 +1,9 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.List; + +public class ReportSnapshotTimelinesForCalendar { + + public List dataProvider; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/ReportTimelinesRange.java b/src/main/java/info/nightscout/medtronic/carelink/message/ReportTimelinesRange.java new file mode 100644 index 0000000..9fa3308 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/ReportTimelinesRange.java @@ -0,0 +1,8 @@ +package info.nightscout.medtronic.carelink.message; + +public class ReportTimelinesRange { + + public String start; + public String end; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/SensorGlucose.java b/src/main/java/info/nightscout/medtronic/carelink/message/SensorGlucose.java new file mode 100644 index 0000000..a36bf11 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/SensorGlucose.java @@ -0,0 +1,22 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; + + +public class SensorGlucose { + + public Integer sg; + public Date datetime; + public boolean timeChange; + public String kind; + public int version; + public String sensorState; + public int relativeOffset; + + public String toS() { + String dt; + if (datetime == null) { dt = ""; } else{ dt = datetime.toString(); } + return dt + " " + String.valueOf(sg); + } + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/SupportedReport.java b/src/main/java/info/nightscout/medtronic/carelink/message/SupportedReport.java new file mode 100644 index 0000000..26791e5 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/SupportedReport.java @@ -0,0 +1,9 @@ +package info.nightscout.medtronic.carelink.message; + +public class SupportedReport { + + public String report; + public String[] onlyFor; + public String[] notFor; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/TextMap.java b/src/main/java/info/nightscout/medtronic/carelink/message/TextMap.java new file mode 100644 index 0000000..015eea3 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/TextMap.java @@ -0,0 +1,343 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.HashMap; + +public class TextMap { + + + public static final String ERROR_TEXT_PREFIX_GUARDIAN = "GM_"; + public static final String ERROR_TEXT_PREFIX_NGP = "N"; + + private static HashMap errorTextMap; + private static HashMap errorCodeMap; + + static { + + errorTextMap = new HashMap<>(); + errorTextMap.put("", ""); + errorTextMap.put("3", "Battery out limit"); + errorTextMap.put("4", "Delivery stopped. Check BG"); + errorTextMap.put("5", "Pump battery depleted. Insulin delivery stopped"); + errorTextMap.put("6", "Auto Off. Insulin delivery stopped"); + errorTextMap.put("16", "Pump reset. Insulin delivery stopped"); + errorTextMap.put("43", "Pump motor error. Insulin delivery stopped"); + errorTextMap.put("50", "Bolus stopped"); + errorTextMap.put("51", "Delivery limit exceeded. Check BG"); + errorTextMap.put("55", "Pump battery failed. Replace battery"); + errorTextMap.put("59", "Button error"); + errorTextMap.put("61", "Check settings. Insulin delivery stopped"); + errorTextMap.put("62", "Empty reservoir"); + errorTextMap.put("66", "No reservoir"); + errorTextMap.put("74", "Finish loading"); + errorTextMap.put("81", "Replace pump battery now"); + errorTextMap.put("82", "Low Reservoir"); + errorTextMap.put("83", "Check BG"); + errorTextMap.put("84", "Alarm clock"); + errorTextMap.put("85", "Max fill reached"); + errorTextMap.put("86", "Weak battery detected"); + errorTextMap.put("87", "Missed bolus"); + errorTextMap.put("88", "Silenced sensor alert. Check alarm history"); + errorTextMap.put("101", "High SG. CHECK BG"); + errorTextMap.put("102", "Low SG"); + errorTextMap.put("103", "Threshold Suspend"); + errorTextMap.put("104", "Meter BG now"); + errorTextMap.put("105", "Calibration Reminder"); + errorTextMap.put("106", "Calibration error"); + errorTextMap.put("107", "Sensor expired"); + errorTextMap.put("108", "Change sensor"); + errorTextMap.put("109", "Sensor error"); + errorTextMap.put("110", "Recharge transmitter"); + errorTextMap.put("111", "Transmitter battery low"); + errorTextMap.put("112", "Weak signal"); + errorTextMap.put("113", "Lost sensor"); + errorTextMap.put("114", "Sensor glucose approaching high limit"); + errorTextMap.put("115", "Sensor glucose approaching low limit"); + errorTextMap.put("116", "Sensor glucose rising rapidly"); + errorTextMap.put("117", "Sensor glucose falling rapidly"); + errorTextMap.put("Axx", "Pump error Anull"); + errorTextMap.put("Exx", "Pump error Enull"); + errorTextMap.put("N002", "Pump Error. Delivery Stopped"); + errorTextMap.put("N006", "Pump Battery Out Limit"); + errorTextMap.put("N007", "Delivery Stopped. Check BG"); + errorTextMap.put("N011", "Replace Pump Battery Now"); + errorTextMap.put("N012", "Auto Suspend Limit Reached. Delivery Stopped"); + errorTextMap.put("N024", "Critical Pump Error. Stop Pump Use. Use Other Treatment"); + errorTextMap.put("N025", "Pump Power Error. Record Settings"); + errorTextMap.put("N029", "Pump Restarted. Delivery Stopped"); + errorTextMap.put("N037", "Pump Motor Error. Delivery Stopped"); + errorTextMap.put("N051", "Bolus Stopped"); + errorTextMap.put("N052", "Delivery Limit Exceeded. Check BG"); + errorTextMap.put("N057", "Pump Battery Not Compatible"); + errorTextMap.put("N058", "Insert A New AA Battery"); + errorTextMap.put("N061", "Pump Button Error. Delivery Stopped"); + errorTextMap.put("N062", "New Notification Received From Pump"); + errorTextMap.put("N066", "No Reservoir Detected During Infusion Set Change"); + errorTextMap.put("N069", "Loading Incomplete During Infusion Set Change"); + errorTextMap.put("N073", "Replace Pump Battery Now"); + errorTextMap.put("N077", "Pump Settings Error. Delivery Stopped"); + errorTextMap.put("N084", "Pump Battery Removed. Replace Battery"); + errorTextMap.put("N100", "Bolus Entry Timed Out Before Delivery"); + errorTextMap.put("N103", "BG Check Reminder"); + errorTextMap.put("N104", "Replace Pump Battery Soon"); + errorTextMap.put("N105", "Reservoir Low. Change Reservoir Soon"); + errorTextMap.put("N107", "Missed Meal Bolus Reminder"); + errorTextMap.put("N109", "Set Change Reminder"); + errorTextMap.put("N110", "Silenced Sensor Alert. Check Alarm History"); + errorTextMap.put("N113", "Reservoir Empty. Change Reservoir Now"); + errorTextMap.put("N117", "Active Insulin Cleared"); + errorTextMap.put("N130", "Rewind Required. Delivery Stopped"); + errorTextMap.put("N140", "Delivery Suspended. Connect Infusion Set"); + errorTextMap.put("N775", "Calibrate Now"); + errorTextMap.put("N776", "Calibration Error"); + errorTextMap.put("N777", "Change Sensor"); + errorTextMap.put("N779", "Recharge Transmitter Now"); + errorTextMap.put("N780", "Lost Sensor Signal"); + errorTextMap.put("N784", "SG Rising Rapidly"); + errorTextMap.put("N794", "Sensor Expired. Change Sensor"); + errorTextMap.put("N795", "Lost Sensor Signal. Check Transmitter"); + errorTextMap.put("N796", "No Sensor Signal"); + errorTextMap.put("N797", "Sensor Connected"); + errorTextMap.put("N801", "Do Not Calibrate. Wait Up To 3 Hours"); + errorTextMap.put("N802", "Low Sensor Glucose"); + errorTextMap.put("N803", "Low Sensor Glucose. Check BG"); + errorTextMap.put("N805", "Alert Before Low. Check BG"); + errorTextMap.put("N807", "Basal Delivery Resumed. Check BG"); + errorTextMap.put("N809", "Suspend On Low. Delivery Stopped. Check BG"); + errorTextMap.put("N810", "Suspend Before Low. Delivery Stopped. Check BG"); + errorTextMap.put("N812", "Call Emergency Assistance"); + errorTextMap.put("N814", "Basal Resumed. SG Still Under Low Limit. Check BG"); + errorTextMap.put("N815", "Low Limit Changed. Basal Manually Resumed. Check BG"); + errorTextMap.put("N816", "High Sensor Glucose"); + errorTextMap.put("N817", "Alert Before High. Check BG"); + errorTextMap.put("N819", "Auto Mode Exit. Basal Delivery Started. BG Required"); + errorTextMap.put("N821", "Minimum Delivery Timeout. BG Required"); + errorTextMap.put("N822", "Maximum Delivery Timeout. BG Required"); + errorTextMap.put("N823", "High Sensor Glucose For Over 1 Hour"); + errorTextMap.put("N827", "Urgent Low Sensor Glucose. Check BG"); + errorTextMap.put("N829", "BG Required"); + errorTextMap.put("N832", "Calibration Required"); + errorTextMap.put("N833", "Correction Bolus Recommended"); + errorTextMap.put("N869", "Calibration Reminder"); + errorTextMap.put("N870", "Recharge Transmitter Soon"); + errorTextMap.put("Nnodata1", "Reconnecting To Pump"); + errorTextMap.put("Nnodata2", "Lost Signal. Check Mobile Application"); + errorTextMap.put("GM_alert.sg.threshold.low.urgent", "Urgent Low Sensor Glucose"); + errorTextMap.put("GM_alert.sg.threshold.low", "Low Sensor Glucose"); + errorTextMap.put("GM_alert.sg.predictive.low", "Low Predicted"); + errorTextMap.put("GM_alert.sg.rate.falling", "Fall Alert"); + errorTextMap.put("GM_alert.sg.threshold.high", "High Sensor Glucose"); + errorTextMap.put("GM_alert.sg.predictive.high", "High Predicted"); + errorTextMap.put("GM_alert.sg.rate.rising", "Rise Alert"); + errorTextMap.put("GM_alert.transmitter.battery", "Transmitter Battery Empty"); + errorTextMap.put("GM_alert.sensor.replace.calibrationError", "Change Sensor"); + errorTextMap.put("GM_alert.sensor.replace.sensorError", "Change Sensor"); + errorTextMap.put("GM_alert.sensor.replace.lifetime", "Sensor End of Life"); + errorTextMap.put("GM_alert.transmitter.signal", "Lost Sensor Communication"); + errorTextMap.put("GM_alert.sensor.connection", "Sensor Connected"); + errorTextMap.put("GM_alert.sensor.calibration.rejected", "Calibration Not Accepted"); + errorTextMap.put("GM_alert.sensor.calibration.calibrate_now", "Calibrate Now"); + errorTextMap.put("GM_alert.sensor.error", "Sensor Glucose Not Available"); + errorTextMap.put("GM_alert.calibration.reminder", "Calibration Reminder"); + errorTextMap.put("GM_alert.transmitter.error", "Transmitter Error"); + errorTextMap.put("GM_alert.receiver.battery.low", "Mobile Device Battery Low"); + errorTextMap.put("Nalert.sg.threshold.low.urgent", "Urgent Low Sensor Glucose"); + errorTextMap.put("Nalert.sg.threshold.low", "Low Sensor Glucose"); + errorTextMap.put("Nalert.sg.predictive.low", "Low Predicted"); + errorTextMap.put("Nalert.sg.rate.falling", "Fall Alert"); + errorTextMap.put("Nalert.sg.threshold.high", "High Sensor Glucose"); + errorTextMap.put("Nalert.sg.predictive.high", "High Predicted"); + errorTextMap.put("Nalert.sg.rate.rising", "Rise Alert"); + errorTextMap.put("Nalert.transmitter.battery", "Transmitter Battery Empty"); + errorTextMap.put("Nalert.sensor.replace.calibrationError", "Change Sensor"); + errorTextMap.put("Nalert.sensor.replace.sensorError", "Change Sensor"); + errorTextMap.put("Nalert.sensor.replace.lifetime", "Sensor End of Life"); + errorTextMap.put("Nalert.transmitter.signal", "Lost Sensor Communication"); + errorTextMap.put("Nalert.sensor.connection", "Sensor Connected"); + errorTextMap.put("Nalert.sensor.calibration.rejected", "Calibration Not Accepted"); + errorTextMap.put("Nalert.sensor.calibration.calibrate_now", "Calibrate Now"); + errorTextMap.put("Nalert.sensor.error", "Sensor Glucose Not Available"); + errorTextMap.put("Nalert.calibration.reminder", "Calibration Reminder"); + errorTextMap.put("Nalert.transmitter.error", "Transmitter Error"); + errorTextMap.put("Nalert.receiver.battery.low", "Mobile Device Battery Low"); + + errorCodeMap = new HashMap<>(); + errorCodeMap.put("002", "002"); + errorCodeMap.put("003", "002"); + errorCodeMap.put("004", "002"); + errorCodeMap.put("013", "002"); + errorCodeMap.put("014", "002"); + errorCodeMap.put("015", "002"); + errorCodeMap.put("016", "002"); + errorCodeMap.put("017", "002"); + errorCodeMap.put("018", "002"); + errorCodeMap.put("019", "002"); + errorCodeMap.put("020", "002"); + errorCodeMap.put("022", "002"); + errorCodeMap.put("023", "002"); + errorCodeMap.put("026", "002"); + errorCodeMap.put("027", "002"); + errorCodeMap.put("028", "002"); + errorCodeMap.put("030", "002"); + errorCodeMap.put("031", "002"); + errorCodeMap.put("033", "002"); + errorCodeMap.put("034", "002"); + errorCodeMap.put("044", "002"); + errorCodeMap.put("045", "002"); + errorCodeMap.put("046", "002"); + errorCodeMap.put("049", "002"); + errorCodeMap.put("053", "002"); + errorCodeMap.put("054", "002"); + errorCodeMap.put("060", "002"); + errorCodeMap.put("063", "002"); + errorCodeMap.put("064", "002"); + errorCodeMap.put("065", "002"); + errorCodeMap.put("067", "002"); + errorCodeMap.put("068", "002"); + errorCodeMap.put("074", "002"); + errorCodeMap.put("075", "002"); + errorCodeMap.put("076", "002"); + errorCodeMap.put("079", "002"); + errorCodeMap.put("080", "002"); + errorCodeMap.put("081", "002"); + errorCodeMap.put("082", "002"); + errorCodeMap.put("117", "117"); + errorCodeMap.put("817", "817"); + errorCodeMap.put("805", "805"); + errorCodeMap.put("819", "819"); + errorCodeMap.put("820", "819"); + errorCodeMap.put("012", "012"); + errorCodeMap.put("807", "807"); + errorCodeMap.put("808", "807"); + errorCodeMap.put("814", "814"); + errorCodeMap.put("103", "103"); + errorCodeMap.put("829", "829"); + errorCodeMap.put("830", "829"); + errorCodeMap.put("831", "829"); + errorCodeMap.put("100", "100"); + errorCodeMap.put("051", "051"); + errorCodeMap.put("775", "775"); + errorCodeMap.put("776", "776"); + errorCodeMap.put("869", "869"); + errorCodeMap.put("832", "832"); + errorCodeMap.put("812", "812"); + errorCodeMap.put("777", "777"); + errorCodeMap.put("778", "777"); + errorCodeMap.put("789", "777"); + errorCodeMap.put("833", "833"); + errorCodeMap.put("024", "024"); + errorCodeMap.put("035", "024"); + errorCodeMap.put("040", "024"); + errorCodeMap.put("047", "024"); + errorCodeMap.put("048", "024"); + errorCodeMap.put("050", "024"); + errorCodeMap.put("055", "024"); + errorCodeMap.put("131", "024"); + errorCodeMap.put("052", "052"); + errorCodeMap.put("007", "007"); + errorCodeMap.put("008", "007"); + errorCodeMap.put("140", "140"); + errorCodeMap.put("801", "801"); + errorCodeMap.put("816", "816"); + errorCodeMap.put("823", "823"); + errorCodeMap.put("824", "823"); + errorCodeMap.put("058", "058"); + errorCodeMap.put("069", "069"); + errorCodeMap.put("780", "780"); + errorCodeMap.put("781", "780"); + errorCodeMap.put("795", "795"); + errorCodeMap.put("815", "815"); + errorCodeMap.put("802", "802"); + errorCodeMap.put("803", "803"); + errorCodeMap.put("822", "822"); + errorCodeMap.put("821", "821"); + errorCodeMap.put("107", "107"); + errorCodeMap.put("066", "066"); + errorCodeMap.put("796", "796"); + errorCodeMap.put("057", "057"); + errorCodeMap.put("006", "006"); + errorCodeMap.put("084", "084"); + errorCodeMap.put("061", "061"); + errorCodeMap.put("037", "037"); + errorCodeMap.put("038", "037"); + errorCodeMap.put("039", "037"); + errorCodeMap.put("041", "037"); + errorCodeMap.put("042", "037"); + errorCodeMap.put("043", "037"); + errorCodeMap.put("025", "025"); + errorCodeMap.put("029", "029"); + errorCodeMap.put("077", "077"); + errorCodeMap.put("779", "779"); + errorCodeMap.put("870", "870"); + errorCodeMap.put("011", "011"); + errorCodeMap.put("073", "011"); + errorCodeMap.put("104", "104"); + errorCodeMap.put("113", "113"); + errorCodeMap.put("105", "105"); + errorCodeMap.put("106", "105"); + errorCodeMap.put("130", "130"); + errorCodeMap.put("797", "797"); + errorCodeMap.put("798", "797"); + errorCodeMap.put("794", "794"); + errorCodeMap.put("109", "109"); + errorCodeMap.put("784", "784"); + errorCodeMap.put("110", "110"); + errorCodeMap.put("810", "810"); + errorCodeMap.put("811", "810"); + errorCodeMap.put("809", "809"); + errorCodeMap.put("062", "062"); + errorCodeMap.put("070", "062"); + errorCodeMap.put("071", "062"); + errorCodeMap.put("072", "062"); + errorCodeMap.put("108", "062"); + errorCodeMap.put("114", "062"); + errorCodeMap.put("786", "062"); + errorCodeMap.put("787", "062"); + errorCodeMap.put("788", "062"); + errorCodeMap.put("799", "062"); + errorCodeMap.put("806", "062"); + errorCodeMap.put("825", "062"); + errorCodeMap.put("828", "062"); + errorCodeMap.put("827", "827"); + + } + + public static String getAlarmMessage(String deviceFamily, Alarm alarm){ + + return getErrorMessage(deviceFamily, alarm.kind, alarm.code); + + } + + public static String getNotificationMessage(String deviceFamily, ClearedNotification notification){ + + return getErrorMessage(deviceFamily, notification.messageId, notification.faultId); + + } + + protected static String getErrorMessage(String deviceFamily, String guardianErrorCode, int ngpErrorCode) + { + String errorTextId; + String internalEC; + + if(deviceFamily.equals(RecentData.DEVICE_FAMILY_GUARDIAN)){ + if(guardianErrorCode != null) + errorTextId = ERROR_TEXT_PREFIX_GUARDIAN + guardianErrorCode; + else + errorTextId = null; + } else if (deviceFamily.equals(RecentData.DEVICE_FAMILY_NGP)){ + String formattedEC = String.format("%03d", ngpErrorCode); + if(errorCodeMap.containsKey(formattedEC)) + internalEC = errorCodeMap.get(formattedEC); + else + internalEC = formattedEC; + errorTextId = ERROR_TEXT_PREFIX_NGP + internalEC; + } else { + errorTextId = null; + } + + if(errorTextId != null && errorTextMap.containsKey(errorTextId)) + return errorTextMap.get(errorTextId); + else + return ""; + } + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/TherapyAlgorithmState.java b/src/main/java/info/nightscout/medtronic/carelink/message/TherapyAlgorithmState.java new file mode 100644 index 0000000..89d3332 --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/TherapyAlgorithmState.java @@ -0,0 +1,11 @@ +package info.nightscout.medtronic.carelink.message; + +public class TherapyAlgorithmState { + + public String autoModeShieldState; + public String autoModeReadinessState; + public String plgmLgsState; + public int safeBasalDuration; + public int waitToCalibrateDuration; + +} diff --git a/src/main/java/info/nightscout/medtronic/carelink/message/User.java b/src/main/java/info/nightscout/medtronic/carelink/message/User.java new file mode 100644 index 0000000..3fa3d9d --- /dev/null +++ b/src/main/java/info/nightscout/medtronic/carelink/message/User.java @@ -0,0 +1,39 @@ +package info.nightscout.medtronic.carelink.message; + +import java.util.Date; + +public class User { + + public static final String ROLE_CARE_PARTNER_US = "CARE_PARTNER"; + public static final String ROLE_CARE_PARTNER_OUS = "CARE_PARTNER_OUS"; + public static final String ROLE_CARE_PATIENT_US = "CARE_PARTNER"; + public static final String ROLE_CARE_PATIENT_OUS = "CARE_PARTNER_OUS"; + public static final String USER_ROLE_CARE_PARTNER = "carepartner"; + public static final String USER_ROLE_PATIENT = "patient"; + + public Date loginDateUTC; + public String id; + public String country; + public String language; + public String lastName; + public String firstName; + public Integer accountId; + public String role; + public String cpRegistrationStatus; + public String accountSuspended; + public boolean needToReconsent; + public boolean mfaRequired; + public boolean mfaEnabled; + + public boolean isCarePartner() { + return(this.role.equals(ROLE_CARE_PARTNER_US) || this.role.equals(ROLE_CARE_PARTNER_OUS)); + } + + public String getUserRole() { + if(isCarePartner()) + return USER_ROLE_CARE_PARTNER; + else + return USER_ROLE_PATIENT; + } + +} diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..1284dc5 --- /dev/null +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Main-Class: info.nightscout.medtronic.carelink.cli.CareLinkClientCLI +Class-Path: annotations-13.0.jar commons-cli-1.4.jar gson-2.8.6.jar kotl + in-stdlib-1.4.10.jar kotlin-stdlib-common-1.4.10.jar okhttp-4.9.1.jar o + kio-2.8.0.jar okio-jvm-2.8.0.jar +