Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team

I am still new to things network, i have the jquery code and want to do a POST method to an existing things network to send message. Kindly please guide to this as i am still new and my logic is as below.

What I have tried:

HTML
<pre> <!-----Toggle switch button On/Off.
     --->
  <div class = "wrapper" align = "center">
  <div class="btn-group" id="toggle_event_editing">
  <button type="button" class="btn btn-danger locked_active">OFF</button>
 <button type="button" class="btn btn-success unlocked_inactive">ON</button>
</div> 
<div class="alert alert-danger" id="switch_status">Switched off.</div>
  </div>

// button for switch functionality on/off.
$(document).ready(function() {
  $('#toggle_event_editing button').click(function(){
    if($(this).hasClass('locked_active')) {
    $('#switch_status').html('Switched off');
      $.ajax({
        url:'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0',
        type:'POST',
        data:{
        format:'text',
          device_id:'mkr1300',
          payload_raw:'AAA'
        },
       success:function(response){
       alert(response);
        },
       error:function() {
         $('#error').text("There was an error while processing your request. Please try again");
        }
      });

  }else{
  $('#switch_status').html('Switched on.');
  $.ajax({
    url:'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0',
    type:'POST',
    data:{
      format:'text',
      device_id:'mkr1300',
      payload_raw:'AAE'
    },
    success:function(response) {
    alert(response);
    },
    error:function() {
    $('#error').text("There was an error while processing your request.Please try again");
    }
  });
  }
  });
});
Posted
Updated 12-Dec-19 20:17pm

1 solution

In theory yes, although you need a gateway in the middle, and fair access policy limits the number of downlinks you may send.
 
Share this answer
 
Comments
gcogco10 13-Dec-19 2:19am    
Mate can you give me at least an example to have an idea. access policy?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900