• sha1 implementation

    2
    0 Votes
    2 Posts
    986 Views
    J
    Found myself : #!/usr/bin/env python import struct def leftrotate(i, n): return ((i << n) & 0xffffffff) | (i >> (32 - n)) class SHA1(object): def __init__(self, data=b""): self.h = [ 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 ] self.remainder = data self.count = 0 def _add_chunk(self, chunk): self.count += 1 w = list( struct.unpack(">16I", chunk) + (None,) * (80-16) ) for i in range(16, 80): n = w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16] w[i] = leftrotate(n, 1) a,b,c,d,e = self.h for i in range(80): f = None k = None if i < 20: f = (b & c) ^ (~b & d) k = 0x5A827999 elif i < 40: f = b ^ c ^ d k = 0x6ED9EBA1 elif i < 60: f = (b & c) ^ (b & d) ^ (c & d) k = 0x8F1BBCDC else: f = b ^ c ^ d k = 0xCA62C1D6 temp = (leftrotate(a,5) + f + e + k + w[i]) % 2**32 e = d d = c c = leftrotate(b, 30) b = a a = temp self.h[0] = (self.h[0] + a) % 2**32 self.h[1] = (self.h[1] + b) % 2**32 self.h[2] = (self.h[2] + c) % 2**32 self.h[3] = (self.h[3] + d) % 2**32 self.h[4] = (self.h[4] + e) % 2**32 def add(self, data): message = self.remainder + data r = len(message) % 64 if r != 0: self.remainder = message[-r:] else: self.remainder = b"" for chunk in range(0, len(message)-r, 64): self._add_chunk( message[chunk:chunk+64] ) return self def finish(self): l = len(self.remainder) + 64 * self.count #ll = struct.pack(">Q", l * 8) #FIXED ll2 = struct.pack('>II', (l*8)>>32,l*8) self.add( b"\x80" + b"\x00" * ((55 - l) % 64) + ll2 ) h = tuple(x for x in self.h) self.__init__() return struct.pack(">5I", *h) def main(): s=SHA1(b"test") print(s.finish()) if __name__ == '__main__': main() So now have websocket working !!! Cheers
  • Problem Upgrading Firmware in Mac

    7
    0 Votes
    7 Posts
    2k Views
    J
    @Roberto Thanks, it did work for me. A simple thing, but on the one instruction screen, you might add as the last item, "turn device on". That way when "Continue" is pressed, the device will show up in the drop down list on the next screen. No big deal though, as I just hit "Go back" and then plugged it in.
  • Should this really cause a CPU shutdown?

    2
    0 Votes
    2 Posts
    828 Views
    R
    It seems like we've been seeing a lot of watchdog timer issues on the latest firmware. Personally, I can't use my WiPy right now because my boot.py is causing a watchdog reset somehow.
  • Test ping/pong

    4
    3 Votes
    4 Posts
    2k Views
    C
    No long distance tests yet. Played with some parameters and found these max working distance settings work around the house: tx_power=20 (US 915 band) bandwidth=LoRa.BW_125KHZ sf=12 coding_rate=LoRa.CODING_4_8 Changing BWto LoRa.BW_125KHZ results in faster data rate and in theory lower receiver sensitivity. Just found another great write up of LoRa modulation at https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5038744/
  • LoPy pinout (work in progress)

    37
    3 Votes
    37 Posts
    21k Views
    X
    @bartvandeenen said in LoPy pinout (work in progress): I plan to build an open-source wireless house thermostat Wouldn't a thermostat chip like the DS1620 be easier in this case?
  • Watchdog trigger when starting wlan in WLAN.STA mode

    4
    0 Votes
    4 Posts
    2k Views
    B
    @bmarkus your suggestion is correct, and resolves the issue! So the good solution is: while not wlan.isconnected(): tim.sleep_ms(50) But pass or machine.idle() in the while loop trigger watchdog expiry!
  • Using Non-Standard LoRaWAN Frequencies

    Moved
    4
    0 Votes
    4 Posts
    2k Views
    K
    @mossynz said in Using Non-Standard LoRaWAN Frequencies: Hi Alex, good to chat to you, as discussed Daniel and team should have the documentation updated about using the new API in this new firmware release. Cheers good luck - Mossy @mossynz can you email your contact details to: kiwi64ajs at gmail.com Regards Alex Shepherd
  • Reading PIR

    9
    0 Votes
    9 Posts
    3k Views
    L
    @Ralph Thanks, for the posting, I will definitely try it out.
  • Simple MQTT Guide

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Trouble using Brocaars LoRaServer

    5
    0 Votes
    5 Posts
    1k Views
    bmarkusB
    @iotGeek said in Trouble using Brocaars LoRaServer: @bmarkus Loraserver is an open-source LoRaWAN network server https://github.com/brocaar/loraserver Documentation can be found under https://docs.loraserver.io/loraserver/ Thanks!
  • Bluetooth

    Moved
    4
    0 Votes
    4 Posts
    2k Views
    C
    @abilio thanks. Im looking forward to the next release!
  • Watchdog

    6
    1 Votes
    6 Posts
    2k Views
    M
    It seems like the watchdog is being used by the internal threading that is managing the FTP server and WLAN connections. In my recent encounter with the watchdog, I found that if I created a couple threads, then had my main thread loop while true and do some extensive exception handling, the watch dog timer would not get serviced and the CPU would halt. Still trying to figure out more about this, but the watchdog is most definitely present on the LoPy. Just perhaps not accessible to us yet. It would be nice if we could configure the watch dog to reset the device as opposed to halting the CPU.
  • FW update over serial

    3
    0 Votes
    3 Posts
    1k Views
    W
    Tnx for reply. DB9 is on this USB -> Serial converter. I'll try to get USB -> UART cable. That is most obvious reason why it doesnt work.
  • Failed to retrieve directory listing through FTP

    Locked
    5
    0 Votes
    5 Posts
    2k Views
    R
    Yes, it is working. Thanks
  • This topic is deleted!

    Moved
    1
    0 Votes
    1 Posts
    23 Views
    No one has replied
  • UART HANG

    10
    0 Votes
    10 Posts
    3k Views
    J
    @jobbyworld said in UART HANG: I will test with next firmware. Seems fixed in 0.9.3.b1 Cheers
  • [SOLVED] LoPy Bricked?

    6
    0 Votes
    6 Posts
    2k Views
    R
    @stevie Nice you solved this! We've noticed this reverse DNS lookup issue as well on the mac, which is not only annoying but can very easily be mistaken for other problems. We'll add a note to our documentation about it and try to figure out if there is a way to solve the issue itself.
  • Unable to telnet with Virgin LoPys

    6
    0 Votes
    6 Posts
    2k Views
    L
    @stevie Thanks for that info. I noticed the slowness, but I hadn't figured out the pattern. I definately think it could be the explanation for what I was running into. I just didn;t wait long enough.
  • ABP 'working' Example

    7
    0 Votes
    7 Posts
    3k Views
    D
    Hello, If it doesn't transmit at all, could it be that you have something connected to the NC pins of the LoPy? https://docs.pycom.io/lopy/lopy/quickref.html We have added a set socket option API in order to select the data rate (expect it on Friday). Cheers, Daniel

Pycom on Twitter